[ckan-changes] commit/ckanext-todo: 5 new changesets

Bitbucket commits-noreply at bitbucket.org
Wed Oct 19 09:29:45 UTC 2011


5 new changesets in ckanext-todo:

http://bitbucket.org/okfn/ckanext-todo/changeset/a144b5060ec4/
changeset:   a144b5060ec4
user:        snhmnd
date:        2011-10-18 12:29:45
summary:     Fix 'Todo' link in menu bar
affected #:  2 files (-1 bytes)

--- a/ckanext/todo/html.py	Wed Jun 01 10:58:47 2011 +0100
+++ b/ckanext/todo/html.py	Tue Oct 18 12:29:45 2011 +0200
@@ -56,5 +56,5 @@
 """
 
 MENU_CODE = """
-<li>%(href)s</li>
+%(href)s
 """


--- a/ckanext/todo/plugin.py	Wed Jun 01 10:58:47 2011 +0100
+++ b/ckanext/todo/plugin.py	Tue Oct 18 12:29:45 2011 +0200
@@ -106,7 +106,7 @@
             h.link_to("Todo", h.url_for('todo_page'), 
                 class_ = ('active' if c.controller == 'ckanext.todo.controller:TodoController' else ''))}
 
-        stream = stream | Transformer('body//div[@class="menu"]/ul]')\
+        stream = stream | Transformer('body//div[@id="mainmenu"]')\
             .append(HTML(html.MENU_CODE % menu_data))
 
         # if this is the read action of a package, show todo info


http://bitbucket.org/okfn/ckanext-todo/changeset/05dfacdfae37/
changeset:   05dfacdfae37
user:        snhmnd
date:        2011-10-18 12:52:09
summary:     Fix the package todo count button.

Update to handle changed ckan templates
affected #:  2 files (-1 bytes)

--- a/ckanext/todo/html.py	Tue Oct 18 12:29:45 2011 +0200
+++ b/ckanext/todo/html.py	Tue Oct 18 12:52:09 2011 +0200
@@ -22,9 +22,9 @@
 """
 
 TODO_COUNT_CODE = """
-<span id="todo-count">
-<a id="package-todo-count"></a>
-</span>
+<li id="todo-count">
+  <a id="package-todo-count"></a>
+</li>
 """
 
 TODO_CODE = """


--- a/ckanext/todo/plugin.py	Tue Oct 18 12:29:45 2011 +0200
+++ b/ckanext/todo/plugin.py	Tue Oct 18 12:52:09 2011 +0200
@@ -121,7 +121,7 @@
             # add jquery and todo.js links
             stream = stream | Transformer('body').append(HTML(html.BODY_CODE % data))
             # add the todo count to the package title, after the RSS 'subscribe' link
-            stream = stream | Transformer('body//div[@id="package"]//h2[@class="head"]')\
+            stream = stream | Transformer('//div[@id="minornavigation"]//ul[@class="tabbed"]')\
                 .append(HTML(html.TODO_COUNT_CODE))
             # add todo subsection
             stream = stream | Transformer('body//div[@id="package"]')\


http://bitbucket.org/okfn/ckanext-todo/changeset/1dc545fa6268/
changeset:   1dc545fa6268
user:        snhmnd
date:        2011-10-18 13:08:39
summary:     Fix the todo subsection

Update to match changed ckan templates
affected #:  1 file (-1 bytes)

--- a/ckanext/todo/plugin.py	Tue Oct 18 12:52:09 2011 +0200
+++ b/ckanext/todo/plugin.py	Tue Oct 18 13:08:39 2011 +0200
@@ -124,6 +124,6 @@
             stream = stream | Transformer('//div[@id="minornavigation"]//ul[@class="tabbed"]')\
                 .append(HTML(html.TODO_COUNT_CODE))
             # add todo subsection
-            stream = stream | Transformer('body//div[@id="package"]')\
+            stream = stream | Transformer('//div[@id="minornavigation"]')\
                 .append(HTML(html.TODO_CODE))
         return stream


http://bitbucket.org/okfn/ckanext-todo/changeset/6c777501bd1c/
changeset:   6c777501bd1c
user:        snhmnd
date:        2011-10-18 16:48:17
summary:     Change to jQuery UI for todo category autocompletion

Change the autocomplete() method in TodoController to return a list of
autocomplete suggestions in the format expected by jQuery UI.

Changed the name of the CSS class in ckanext/todo/html.py from
"todo-category-autocomplete" to "autocomplete-todo-category" (matches the
format of autocomplete CSS class names elsewhere in ckan).

Remove the old autocomplete stuff from todo.js, replace with a call to jQuery
UI's .autocomplete()
affected #:  3 files (-1 bytes)

--- a/ckanext/todo/controller.py	Tue Oct 18 13:08:39 2011 +0200
+++ b/ckanext/todo/controller.py	Tue Oct 18 16:48:17 2011 +0200
@@ -246,24 +246,18 @@
         """
         Todo autocomplete API
         """
-        incomplete = request.params.get("incomplete")
-        if incomplete:
-            query = model.TodoCategory.search(incomplete)
+        # Get the "term" (what the user has typed so far in the input box) from
+        # jQuery UI
+        term = request.params.get("term")
+
+        if term:
+            # Make a list of categories that match the term and return it
+            query = model.TodoCategory.search(term)
             category_names = [cat.name for cat in query]
+            return category_names[:AUTOCOMPLETE_LIMIT]
         else:
-            category_names = []
-        result_set = {
-            "ResultSet": {
-                "Result": []
-            }
-        }
-
-        for name in category_names[:AUTOCOMPLETE_LIMIT]:
-            result = {
-                "Name": name
-            }
-            result_set["ResultSet"]["Result"].append(result)
-        return result_set
+            # No categories match what the user has typed.
+            return []
 
     def todo_page(self):
         """


--- a/ckanext/todo/html.py	Tue Oct 18 13:08:39 2011 +0200
+++ b/ckanext/todo/html.py	Tue Oct 18 16:48:17 2011 +0200
@@ -36,7 +36,7 @@
         <form name="todo-add-form" method="post"><div><label for="category_name">Category</label>
-                <input name="category_name" class="todo-category-autocomplete" type="text" />
+                <input name="category_name" class="autocomplete-todo-category" type="text" /></div><div><label for="description">Description</label>


--- a/ckanext/todo/public/ckanext-todo/todo.js	Tue Oct 18 13:08:39 2011 +0200
+++ b/ckanext/todo/public/ckanext-todo/todo.js	Tue Oct 18 16:48:17 2011 +0200
@@ -9,11 +9,7 @@
         this.todoCount = 0;
         this.showTodo();
         // autocomplete
-        $('.todo-category-autocomplete')
-            .after('<div id="category-autocomplete-suggestions"' +
-                   'class="categories small"></div>')
-            .keyup(this.updateCategories)
-            .keydown(this.doComplete);
+        $('.autocomplete-todo-category').autocomplete({source:'/api/2/todo/autocomplete'});
     },
 
     // show the todo count
@@ -218,59 +214,4 @@
                 $('div#todo-error').replaceWith(errorHtml);
         });
     },
-
-    updateCategories:function(e){
-        var incomplete = $(this).val();
-        var container = $(this).next('.categories');
-
-        // If we're not in the middle of typing a tag, return.
-        if(incomplete[incomplete.length - 1] === ' '){
-            return;
-        }
-
-        // callback function for new autocomplete suggestions
-        var newCategories = function(json){
-            $(container).empty();
-
-            // add links to the autocomplete container
-            $.each(json["ResultSet"]["Result"], function(){
-                $(container).append('<a>' + this["Name"] + '</a>');
-            });
-
-            // set active link
-            $(container).children().first().addClass('active')
-                .end().hover(function(){
-                    $(this).addClass('active').siblings().removeClass('active');
-            });
-
-            // add click handler for autocomplete links
-            $(container).children().click(function(){
-                var input = $(container).prev('.todo-category-autocomplete');
-                $(input).val($(this).text());
-                $(this).parent().empty();
-            }); 
-        }
-        
-        // get latest autocomplete suggestions
-        $.ajax({
-            url: "/api/2/todo/autocomplete",
-            data: "incomplete=" + incomplete,
-            dataType: 'json',
-            type: 'get',
-            success: newCategories
-        });
-    },
-
-    doComplete:function(e){
-        var list = $(this).next('.categories');
-        var active = list.find('a.active');
-
-        // Complete tag on {tab, return, right-arrow}.
-        if(active[0] && ($.inArray(e.keyCode, [9, 13, 39]) !== -1)){
-          $(this).val(active.text() + " ");
-          console.log(list);
-          list.empty();
-          return false;
-        }
-    }
 };


http://bitbucket.org/okfn/ckanext-todo/changeset/1fb66b1c9d28/
changeset:   1fb66b1c9d28
user:        snhmnd
date:        2011-10-18 17:45:24
summary:     Tidy up the todo stuff in the dataset View tab

More fixing up due to changes in the ckan templates:

Move the todo list into the right place

Remove the todo count button. It doesn't fit nicely with the new ckan
templates. Perhaps it can be revived elsewhere later, e.g. in the sidebar on
the right.
affected #:  2 files (-1 bytes)

--- a/ckanext/todo/html.py	Tue Oct 18 16:48:17 2011 +0200
+++ b/ckanext/todo/html.py	Tue Oct 18 17:45:24 2011 +0200
@@ -21,12 +21,6 @@
 </script>
 """
 
-TODO_COUNT_CODE = """
-<li id="todo-count">
-  <a id="package-todo-count"></a>
-</li>
-"""
-
 TODO_CODE = """
 <div id="todo" class="subsection"><h3>Todo</h3>


--- a/ckanext/todo/plugin.py	Tue Oct 18 16:48:17 2011 +0200
+++ b/ckanext/todo/plugin.py	Tue Oct 18 17:45:24 2011 +0200
@@ -120,10 +120,7 @@
             stream = stream | Transformer('head').append(HTML(html.HEAD_CODE))
             # add jquery and todo.js links
             stream = stream | Transformer('body').append(HTML(html.BODY_CODE % data))
-            # add the todo count to the package title, after the RSS 'subscribe' link
-            stream = stream | Transformer('//div[@id="minornavigation"]//ul[@class="tabbed"]')\
-                .append(HTML(html.TODO_COUNT_CODE))
             # add todo subsection
-            stream = stream | Transformer('//div[@id="minornavigation"]')\
+            stream = stream | Transformer('//div[@id="dataset"]')\
                 .append(HTML(html.TODO_CODE))
         return stream

Repository URL: https://bitbucket.org/okfn/ckanext-todo/

--

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