[ckan-changes] commit/ckan: 2 new changesets
Bitbucket
commits-noreply at bitbucket.org
Tue Aug 2 14:53:08 UTC 2011
2 new changesets in ckan:
http://bitbucket.org/okfn/ckan/changeset/91fe3efcfd8e/
changeset: 91fe3efcfd8e
user: John Glover
date: 2011-08-02 16:50:13
summary: [merge] feature-816-format-autocomplete
affected #: 4 files (1.6 KB)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/ckan/public/scripts/formatautocomplete.js Tue Aug 02 15:50:13 2011 +0100
@@ -0,0 +1,37 @@
+(function($){
+ var url = "";
+
+ function extractDataAttributes(){
+ var el = $(this);
+ $.each(this.attributes, function(){
+ // get the autocomplete API URL
+ if(this.name === 'data-format-autocomplete-url'){
+ url = this.value;
+ }
+ });
+ }
+
+ function autoCompleteList(request, response){
+ var requestData = {'incomplete': request.term};
+
+ $.ajax({
+ url: url,
+ data: requestData,
+ dataType: 'jsonp',
+ type: 'get',
+ jsonpCallback: 'callback',
+ success: function(json){
+ var formats = [];
+ $.each(json["ResultSet"]["Result"], function(){
+ formats.push(this["Format"]);
+ });
+ response(formats);
+ },
+ });
+ }
+
+ $(document).ready(function(){
+ $('.format-autocomplete').focus(extractDataAttributes)
+ .autocomplete({source: autoCompleteList});
+ });
+})(jQuery);
--- a/ckan/templates/package/edit.html Fri Jul 29 19:04:17 2011 +0200
+++ b/ckan/templates/package/edit.html Tue Aug 02 15:50:13 2011 +0100
@@ -17,6 +17,9 @@
<!-- Tagcomplete --><script type="text/javascript" src="${g.site_url}/scripts/tagcomplete.js"></script><link rel="stylesheet" href="${g.site_url}/css/tagcomplete.css" />
+
+ <!-- Format field autocomplete -->
+ <script type="text/javascript" src="${g.site_url}/scripts/formatautocomplete.js"></script></py:def><div py:match="content" class="package">
--- a/ckan/templates/package/new_package_form.html Fri Jul 29 19:04:17 2011 +0200
+++ b/ckan/templates/package/new_package_form.html Tue Aug 02 15:50:13 2011 +0100
@@ -78,8 +78,11 @@
<py:for each="num, res in enumerate(data.get('resources', []) + [{}])"><tr><py:for each="col in c.resource_columns">
- <td class="resource-${col}">
- <input name="resources__${num}__${col}" type="text" value="${res.get(col, '')}" class="${'medium-width' if col=='description' else 'short'}" />
+ <td py:choose="" class="resource-${col}">
+ <input py:when="col == 'format'" name="resources__${num}__${col}"
+ type="text" value="${res.get(col, '')}" class="format-autocomplete short"
+ data-format-autocomplete-url="/api/2/util/resource/format_autocomplete" />
+ <input py:otherwise="" name="resources__${num}__${col}" type="text" value="${res.get(col, '')}" class="${'medium-width' if col=='description' else 'short'}" /></td></py:for><td class="resource-id"><input name="resources__${num}__id" type="hidden" value="${res.get('id', '')}" /></td>
--- a/doc/api.rst Fri Jul 29 19:04:17 2011 +0200
+++ b/doc/api.rst Tue Aug 02 15:50:13 2011 +0100
@@ -535,3 +535,16 @@
::
{"ResultSet": {"Result": [{"Name": "russian"}]}}
+
+Similarly, there is an autocomplete API for the resource format field
+which is available at:
+
+::
+
+ /api/2/util/resource/format_autocomplete?incomplete=cs
+
+This returns:
+
+::
+
+ {"ResultSet": {"Result": [{"Format": "csv"}]}}
http://bitbucket.org/okfn/ckan/changeset/0ac2d388e9c1/
changeset: 0ac2d388e9c1
branch: feature-816-format-autocomplete
user: John Glover
date: 2011-08-02 16:51:31
summary: [close] Ticket closed
affected #: 0 files (0 bytes)
Repository URL: https://bitbucket.org/okfn/ckan/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list