From 6a9bd77845b5988cb02c8f44f13d4517efd00588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20=20MENAGER?= <herve.menager@pasteur.fr> Date: Sun, 25 Feb 2018 22:29:20 +0100 Subject: [PATCH] correct behavior of "selected" badges in compound query Former-commit-id: db89cc1679ff6b98144a467586a68dedcde79138 --- ippisite/ippidb/templates/base.html | 9 +++++++-- ippisite/ippidb/templates/compound_list.html | 8 ++++---- ippisite/ippidb/templates/selected_badge.html | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ippisite/ippidb/templates/base.html b/ippisite/ippidb/templates/base.html index cc89079a..47710d4f 100644 --- a/ippisite/ippidb/templates/base.html +++ b/ippisite/ippidb/templates/base.html @@ -8,7 +8,7 @@ <link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" href="/static/css/ippidb.css"> - + <script src="/static/jquery/jquery-3.3.1.min.js"></script> <script src="/static/popper/popper.min.js"></script> <script src="/static/bootstrap/js/bootstrap.min.js"></script> @@ -38,7 +38,12 @@ var changeSelection = function(paramName){ var selectedFields = $('input[name='+ paramName +']:checked').map(function(_, el) { return $(el).val(); }).get(); modifyUrl(paramName, selectedFields); - } + } + var removeFromSelection = function(paramName, value){ + var selectedFields = $('input[name='+ paramName +']:checked').map(function(_, el) { return $(el).val(); }).get(); + selectedFields.remove(value); + modifyUrl(paramName, selectedFields); + } </script> </head> diff --git a/ippisite/ippidb/templates/compound_list.html b/ippisite/ippidb/templates/compound_list.html index 21abc5ec..18ec47ec 100644 --- a/ippisite/ippidb/templates/compound_list.html +++ b/ippisite/ippidb/templates/compound_list.html @@ -44,22 +44,22 @@ <span> - filters: </span> {% if selected_ppis %} {% for selected in selected_ppis %} - {% include "selected_badge.html" with selected=selected %} + {% include "selected_badge.html" with param_name="ppi" selected=selected %} {% endfor %} {% endif %} {% if selected_diseases %} {% for selected in selected_diseases %} - {% include "selected_badge.html" with selected=selected %} + {% include "selected_badge.html" with param_name="disease" selected=selected %} {% endfor %} {% endif %} {% if selected_taxonomies %} {% for selected in selected_taxonomies %} - {% include "selected_badge.html" with selected=selected %} + {% include "selected_badge.html" with param_name="taxonomy" selected=selected %} {% endfor %} {% endif %} {% if selected_boundcomplexes %} {% for selected in selected_boundcomplexes %} - {% include "selected_badge.html" with selected=selected %} + {% include "selected_badge.html" with param_name="boundcomplex" selected=selected %} {% endfor %} {% endif %} {% endif %} diff --git a/ippisite/ippidb/templates/selected_badge.html b/ippisite/ippidb/templates/selected_badge.html index d5a69cac..69f8955b 100644 --- a/ippisite/ippidb/templates/selected_badge.html +++ b/ippisite/ippidb/templates/selected_badge.html @@ -1,3 +1,3 @@ <span class="badge badge-info" style="font-size: 100%">{{ selected.name }} - <a href="#" style="color: white;" onclick="$('#selected-{{ selected.id}}')[0].click();"><i class="remove fa fa-times-circle"></i></a> + <a href="#" style="color: white;" onclick="removeFromSelection('{{ param_name }}', '{{ selected.id }}')"><i class="remove fa fa-times-circle"></i></a> </span> -- GitLab