[ckan-changes] commit/ckan: 2 new changesets

Bitbucket commits-noreply at bitbucket.org
Tue Aug 2 14:13:06 UTC 2011


2 new changesets in ckan:

http://bitbucket.org/okfn/ckan/changeset/a8335ae102ac/
changeset:   a8335ae102ac
branch:      feature-816-format-autocomplete
user:        John Glover
date:        2011-08-02 12:59:30
summary:     [doc] Add note about new format autocomplete API
affected #:  1 file (229 bytes)

--- a/doc/api.rst	Fri Jul 29 19:04:17 2011 +0200
+++ b/doc/api.rst	Tue Aug 02 11:59:30 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/627fae1d47d2/
changeset:   627fae1d47d2
branch:      feature-816-format-autocomplete
user:        John Glover
date:        2011-08-02 16:07:20
summary:     [ui] Add JQueryUI autocomplete to resource format field
affected #:  3 files (1.4 KB)

--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ckan/public/scripts/formatautocomplete.js	Tue Aug 02 15:07:20 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	Tue Aug 02 11:59:30 2011 +0100
+++ b/ckan/templates/package/edit.html	Tue Aug 02 15:07:20 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	Tue Aug 02 11:59:30 2011 +0100
+++ b/ckan/templates/package/new_package_form.html	Tue Aug 02 15:07:20 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>

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