From 366fac5a57abfeab450c0c27a3eac43f5c3c8a19 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 01 2017 21:35:23 +0000 Subject: Add a way to easily select multiple tags in the issues list and roadmap With this patch, it is trivial to filter issues by selecting one or more tags, clicking on a selected tag will then take it out of the filtering criteria. Bonus point: it also simplifies the logic in the HTML nicely --- diff --git a/pagure/templates/issues.html b/pagure/templates/issues.html index de86ccb..298fbbd 100644 --- a/pagure/templates/issues.html +++ b/pagure/templates/issues.html @@ -124,38 +124,17 @@ {% for tag in tag_list %} - {% if tag.tag in tags %} - {% if status and status != 'Open' %} - - {% else %} - - {% endif %} - {% else %} - {% endif %} {{ tag.tag }} {% endfor %} diff --git a/pagure/templates/roadmap.html b/pagure/templates/roadmap.html index 94eaac7..589b883 100644 --- a/pagure/templates/roadmap.html +++ b/pagure/templates/roadmap.html @@ -132,28 +132,16 @@ {% for tag in tag_list %} - {% if tag in tags %} - - {% else %} - {% endif %} {{ tag }} {% endfor %} diff --git a/pagure/ui/filters.py b/pagure/ui/filters.py index 647ab30..ae5e36f 100644 --- a/pagure/ui/filters.py +++ b/pagure/ui/filters.py @@ -572,3 +572,15 @@ def combine_url(url, page, pagetitle, **kwargs): query[pagetitle] = page query.update(kwargs) return url + '?' + '&'.join(['%s=%s' % (k, query[k]) for k in query]) + + +@APP.template_filter('add_or_remove') +def add_or_remove(item, items): + """ Adds the item to the list if it is not in there and remove it + otherwise. + """ + if item in items: + items.remove(item) + else: + items.append(item) + return items