From 6c2e849c55e10c2f9a9514c14b45e2943459b0a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20=20MENAGER?= <herve.menager@pasteur.fr> Date: Wed, 24 Jan 2018 22:32:26 +0100 Subject: [PATCH] add a "remove from selection" link to the "selected filter" badge Former-commit-id: f2f98b47d22fbc69638ac08c0fd8dbfc32821f86 --- ippisite/ippidb/templates/base.html | 1 + ippisite/ippidb/templates/compound_list.html | 50 ++++++++++--------- .../templates/multiselection_list_menu.html | 2 +- ippisite/ippidb/templates/selected_badge.html | 3 ++ 4 files changed, 31 insertions(+), 25 deletions(-) create mode 100644 ippisite/ippidb/templates/selected_badge.html diff --git a/ippisite/ippidb/templates/base.html b/ippisite/ippidb/templates/base.html index 527c0626..d4d687e6 100644 --- a/ippisite/ippidb/templates/base.html +++ b/ippisite/ippidb/templates/base.html @@ -7,6 +7,7 @@ <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous"></script> + <script defer src="https://use.fontawesome.com/releases/v5.0.4/js/all.js"></script> <script type="text/javascript" src="/static/Kekule.js-master/release/kekule.js?modules=chemWidget,openbabel,indigo"></script> <script src="/static/js/ippidb.js" type="text/javascript"></script> <script type="text/javascript"> diff --git a/ippisite/ippidb/templates/compound_list.html b/ippisite/ippidb/templates/compound_list.html index 351af226..dd499185 100644 --- a/ippisite/ippidb/templates/compound_list.html +++ b/ippisite/ippidb/templates/compound_list.html @@ -42,31 +42,33 @@ </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 %} + <form> + <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 %} + {% include "selected_badge.html" with selected=selected %} + {% endfor %} + {% endif %} + {% if selected_diseases %} + {% for selected in selected_diseases %} + {% include "selected_badge.html" with selected=selected %} + {% endfor %} + {% endif %} + {% if selected_taxonomies %} + {% for selected in selected_taxonomies %} + {% include "selected_badge.html" with selected=selected %} + {% endfor %} + {% endif %} + {% if selected_boundcomplexes %} + {% for selected in selected_boundcomplexes %} + {% include "selected_badge.html" with selected=selected %} + {% endfor %} + {% endif %} {% 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> + </div> + </form> {% if compounds %} {% for compound in compounds %} {% include "compound_abstract.html" with compound=compound %} diff --git a/ippisite/ippidb/templates/multiselection_list_menu.html b/ippisite/ippidb/templates/multiselection_list_menu.html index 7f5f77fa..6e4cdb26 100644 --- a/ippisite/ippidb/templates/multiselection_list_menu.html +++ b/ippisite/ippidb/templates/multiselection_list_menu.html @@ -13,7 +13,7 @@ {% for element in selected_list %} <div class="form-check col-12"> <label class="form-check-label"> - <input class="form-check-input text-right" type="checkbox" checked value="{{ element.id }}" onchange="this.form.submit()" name="{{ param_name }}" style="width: auto; margin-right: 1em;"> + <input id="selected-{{ element.id }}" class="form-check-input text-right" type="checkbox" checked value="{{ element.id }}" onchange="this.form.submit()" name="{{ param_name }}" style="width: auto; margin-right: 1em;"> {{ element.name }} </label> </div> diff --git a/ippisite/ippidb/templates/selected_badge.html b/ippisite/ippidb/templates/selected_badge.html new file mode 100644 index 00000000..d5a69cac --- /dev/null +++ b/ippisite/ippidb/templates/selected_badge.html @@ -0,0 +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> +</span> -- GitLab