allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [01/38] git commit: [#4019] ticket:481 JS for filters
Date Wed, 30 Apr 2014 18:15:33 GMT
Repository: allura
Updated Branches:
  refs/heads/master 04305692f -> 19b4b8a78


[#4019] ticket:481 JS for filters


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/6fd29329
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/6fd29329
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/6fd29329

Branch: refs/heads/master
Commit: 6fd29329ed5f7209ff38d3c9266a11442ceea086
Parents: bab54f1
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Tue Dec 17 13:49:17 2013 +0200
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed Apr 30 15:55:08 2014 +0000

----------------------------------------------------------------------
 ForgeTracker/forgetracker/model/ticket.py       |  5 +++-
 .../forgetracker/templates/tracker/index.html   |  1 +
 .../templates/tracker/milestone.html            |  1 +
 .../forgetracker/templates/tracker/search.html  |  1 +
 .../tracker_widgets/ticket_search_results.html  |  3 +-
 ForgeTracker/forgetracker/tracker_main.py       | 11 ++++----
 .../widgets/resources/js/ticket-list.js         | 29 +++++++++++++++++++-
 7 files changed, 43 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/6fd29329/ForgeTracker/forgetracker/model/ticket.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index b308416..5ad9f3a 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -1123,7 +1123,8 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
             **kw)
 
     @classmethod
-    def paged_search(cls, app_config, user, q, limit=None, page=0, sort=None, show_deleted=False,
**kw):
+    def paged_search(cls, app_config, user, q, limit=None, page=0, sort=None, show_deleted=False,
+                     filter=None, **kw):
         """Query tickets from Solr, filtering for 'read' permission, sorting and paginating
the result.
 
         See also paged_query which does a mongo search.
@@ -1147,6 +1148,7 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
         limit, page, start = g.handle_paging(limit, page, default=25)
         count = 0
         tickets = []
+        if filter is None: filter = {}
         refined_sort = sort if sort else 'ticket_num_i desc'
         if 'ticket_num_i' not in refined_sort:
             refined_sort += ',ticket_num_i asc'
@@ -1185,6 +1187,7 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
                         count = count - 1
         return dict(tickets=tickets,
                     count=count, q=q, limit=limit, page=page, sort=sort,
+                    filter=json.dumps(filter),
                     solr_error=solr_error, **kw)
 
     def get_mail_footer(self, notification, toaddr):

http://git-wip-us.apache.org/repos/asf/allura/blob/6fd29329/ForgeTracker/forgetracker/templates/tracker/index.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker/index.html b/ForgeTracker/forgetracker/templates/tracker/index.html
index a9f803e..16f3bc8 100644
--- a/ForgeTracker/forgetracker/templates/tracker/index.html
+++ b/ForgeTracker/forgetracker/templates/tracker/index.html
@@ -61,6 +61,7 @@
       count=count,
       limit=limit,
       query=q,
+      filter=filter,
       tickets=tickets,
       sortable_custom_fields=sortable_custom_fields,
       columns=columns,

http://git-wip-us.apache.org/repos/asf/allura/blob/6fd29329/ForgeTracker/forgetracker/templates/tracker/milestone.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker/milestone.html b/ForgeTracker/forgetracker/templates/tracker/milestone.html
index e9e6c35..07d6969 100644
--- a/ForgeTracker/forgetracker/templates/tracker/milestone.html
+++ b/ForgeTracker/forgetracker/templates/tracker/milestone.html
@@ -69,6 +69,7 @@
     count=count,
     limit=limit,
     query=q,
+    filter=filter,
     tickets=tickets,
     sortable_custom_fields=sortable_custom_fields,
     columns=columns,

http://git-wip-us.apache.org/repos/asf/allura/blob/6fd29329/ForgeTracker/forgetracker/templates/tracker/search.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker/search.html b/ForgeTracker/forgetracker/templates/tracker/search.html
index c355f47..a7c11f8 100644
--- a/ForgeTracker/forgetracker/templates/tracker/search.html
+++ b/ForgeTracker/forgetracker/templates/tracker/search.html
@@ -83,6 +83,7 @@
   count=count,
   limit=limit,
   query=q,
+  filter=filter,
   tickets=tickets,
   sortable_custom_fields=sortable_custom_fields,
   columns=columns,

http://git-wip-us.apache.org/repos/asf/allura/blob/6fd29329/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_search_results.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_search_results.html
b/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_search_results.html
index 41e4bfd..f16f33e 100644
--- a/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_search_results.html
+++ b/ForgeTracker/forgetracker/templates/tracker_widgets/ticket_search_results.html
@@ -50,7 +50,7 @@
                       <option value="{{o['value']}}"{% if o['selected'] %} selected="selected"{%
endif %}>{{o['label']}}</label>
                     {% endfor %}
                   </select>
-                  <input type="submit" value="Ok" name="filter-{{col['name']}}">
+                  <input type="button" value="Ok" class="apply-filters">
                   <a href="#" class="close btn link">Cancel</a>
                 </p>
                 <div style="clear:both;"></div>
@@ -131,6 +131,7 @@
   {{widget.fields['page_list'].display(limit=limit, page=page, count=count)}}
   <script type="text/javascript">
     var q="{{query and h.urlquoteplus(query) or ''}}", count={{count}}, limit={{limit}},
page={{page}}, sort="{{sort}}";
+    var filter = {{ filter|safe or {} }};
   </script>
 </div>
 {% block wiki_extra_css %}

http://git-wip-us.apache.org/repos/asf/allura/blob/6fd29329/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 87a72c0..e149af5 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -81,6 +81,7 @@ search_validators = dict(
     limit=validators.Int(if_invalid=None),
     page=validators.Int(if_empty=0, if_invalid=0),
     sort=validators.UnicodeString(if_empty=None),
+    filter=V.JsonConverter(if_empty={}),
     deleted=validators.StringBool(if_empty=False))
 
 
@@ -743,7 +744,8 @@ class RootController(BaseController, FeedController):
     @h.vardec
     @expose('jinja:forgetracker:templates/tracker/search.html')
     @validate(validators=search_validators)
-    def search(self, q=None, query=None, project=None, columns=None, page=0, sort=None, deleted=False,
**kw):
+    def search(self, q=None, query=None, project=None, columns=None, page=0, sort=None,
+               deleted=False, filter=None, **kw):
         require(has_access(c.app, 'read'))
 
         if query and not q:
@@ -754,10 +756,9 @@ class RootController(BaseController, FeedController):
             bin = TM.Bin.query.find(
                 dict(app_config_id=c.app.config._id, terms=q)).first()
         if project:
-            redirect(c.project.url() + 'search?' +
-                     urlencode(dict(q=q, history=kw.get('history'))))
-        result = TM.Ticket.paged_search(
-            c.app.config, c.user, q, page=page, sort=sort, show_deleted=deleted, **kw)
+            redirect(c.project.url() + 'search?' + urlencode(dict(q=q, history=kw.get('history'))))
+        result = TM.Ticket.paged_search(c.app.config, c.user, q, page=page, sort=sort,
+                                        show_deleted=deleted, filter=filter, **kw)
         result['columns'] = columns or solr_columns()
         result[
             'sortable_custom_fields'] = c.app.globals.sortable_custom_fields_shown_in_search()

http://git-wip-us.apache.org/repos/asf/allura/blob/6fd29329/ForgeTracker/forgetracker/widgets/resources/js/ticket-list.js
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/widgets/resources/js/ticket-list.js b/ForgeTracker/forgetracker/widgets/resources/js/ticket-list.js
index 50c0378..558a9fb 100644
--- a/ForgeTracker/forgetracker/widgets/resources/js/ticket-list.js
+++ b/ForgeTracker/forgetracker/widgets/resources/js/ticket-list.js
@@ -27,7 +27,8 @@
         window.location = '?q=' + q +
                           '&limit=' + limit +
                           '&page=' + page +
-                          '&sort=' + encodeURIComponent(sort);
+                          '&sort=' + encodeURIComponent(sort) +
+                          '&filter=' + encodeURIComponent(JSON.stringify(filter));
     }
 
     $('.ticket-filter a[data-sort]').click(function(){
@@ -74,4 +75,30 @@
       e.preventDefault();
       $('.ticket-filter').hide();
     });
+    $('.ticket-filter .apply-filters').click(function() {
+      filter = {};
+      $('.ticket-filter select').each(function() {
+        var val = $(this).val();
+        if (val) {
+          var name = this.name.replace(/^filter-/, '');
+          filter[name] = val;
+        }
+      });
+      requery();
+    });
+
+    function select_active_filter() {
+      for (var name in filter) {
+        var fname = 'filter-' + name;
+        var $select = $('select[name="' + fname + '"]');
+        var $options = $select.find('option');
+        $options.each(function() {
+          if (filter[name].indexOf($(this).val()) != -1) {
+            $(this).attr("selected", "selected");
+          }
+        });
+        $select.multiselect('refresh');
+      }
+    }
+    select_active_filter();
 })();


Mime
View raw message