From 4d26c3ad7a4b9298064dbefaadc28cd9e56102fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20=20MENAGER?= <herve.menager@pasteur.fr> Date: Thu, 7 Dec 2017 09:53:39 +0100 Subject: [PATCH] add badges for filters and matches count in compounds list (WIP) Former-commit-id: 20733216244f5b9ba737f1d8cd52c009199e92b6 --- ippisite/ippidb/templates/compound_list.html | 26 ++++++++++++++++++++ ippisite/ippidb/views.py | 4 ++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/ippisite/ippidb/templates/compound_list.html b/ippisite/ippidb/templates/compound_list.html index 230aeb30..351af226 100644 --- a/ippisite/ippidb/templates/compound_list.html +++ b/ippisite/ippidb/templates/compound_list.html @@ -40,7 +40,33 @@ {% include "multiselection_list_menu.html" with label="Bound complex" selected_list=selected_boundcomplexes unselected_list=boundcomplexes param_name="boundcomplex" all_param_name="boundcomplexes_all" all_param_value=boundcomplexes_all %} </form> </div> + <main class="col-12 col-md-9 col-xl-10 pl-md-5 bd-content" role="main"> + <div class="row m-2 border border- bg-light"><span>{{ count }} compounds</span> + {% if selected_ppis or selected_diseases or selected_taxonomies or selected_boundcomplexes %} + <span> - filters: </span> + {% if selected_ppis %} + {% for selected in selected_ppis %} + <span class="badge badge-info" style="font-size: 100%">{{ selected.name }}</span> + {% endfor %} + {% endif %} + {% if selected_diseases %} + {% for selected in selected_diseases %} + <span class="badge badge-info" style="font-size: 100%">{{ selected.name }}</span> + {% endfor %} + {% endif %} + {% if selected_taxonomies %} + {% for selected in selected_taxonomies %} + <span class="badge badge-info" style="font-size: 100%">{{ selected.name }}</span> + {% endfor %} + {% endif %} + {% if selected_boundcomplexes %} + {% for selected in selected_boundcomplexes %} + <span class="badge badge-info" style="font-size: 100%">{{ selected.name }}</span> + {% endfor %} + {% endif %} + {% endif %} + </div> {% if compounds %} {% for compound in compounds %} {% include "compound_abstract.html" with compound=compound %} diff --git a/ippisite/ippidb/views.py b/ippisite/ippidb/views.py index f31daedb..2ff403f1 100644 --- a/ippisite/ippidb/views.py +++ b/ippisite/ippidb/views.py @@ -219,6 +219,7 @@ def compound_list(request): boundcomplexes = ProteinDomainBoundComplex.objects.exclude(id__in=request.GET.getlist('boundcomplex')) if boundcomplexes_all is None: boundcomplexes = boundcomplexes[:5] + count = compounds.count() # handle pagination in compounds list paginator = Paginator(compounds, 5) page = request.GET.get('page') @@ -230,7 +231,8 @@ def compound_list(request): except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. compounds = paginator.page(paginator.num_pages) - return render(request, 'compound_list.html', {'compounds': compounds, + return render(request, 'compound_list.html', {'compounds': compounds, + 'count': count, 'selected_ppis': selected_ppis, 'ppis': ppis, 'ppis_all': ppis_all, -- GitLab