From b0cf9ee7254a18fe72f4d38ddb8b18535a725da3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Herv=C3=A9=20=20MENAGER?= <herve.menager@pasteur.fr>
Date: Tue, 30 Jan 2018 22:35:05 +0100
Subject: [PATCH] add grid/list switch for compounds list view

Former-commit-id: 1e14d69cb89f7c42b4ebb07a10a02e608590b4cd
---
 ippisite/ippidb/templates/compound_list.html | 14 ++++++++++++--
 ippisite/ippidb/views.py                     |  4 +++-
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/ippisite/ippidb/templates/compound_list.html b/ippisite/ippidb/templates/compound_list.html
index 41f9c97d..accb8284 100644
--- a/ippisite/ippidb/templates/compound_list.html
+++ b/ippisite/ippidb/templates/compound_list.html
@@ -40,7 +40,8 @@
 
 <main class="col-12 col-md-9 col-xl-10 pl-md-5 bd-content" role="main">
     <form>
-        <div class="row m-2 border border-bg-light"><span>{{ count }} compounds</span>
+        <div class="">
+        <span class="m-2"><span>{{ count }} compounds</span>
             {% if selected_ppis or selected_diseases or selected_taxonomies or selected_boundcomplexes %}
                 <span>&nbsp;-&nbsp;filters:&nbsp;</span>
                 {% if selected_ppis %}
@@ -64,10 +65,19 @@
                     {% endfor %}
                 {% endif %}
             {% endif %}
+        </span>
+        <span class="btn-group float-right">
+            <a class="btn btn-default btn-outline-primary {% if not display_list %}active{% endif %}" href="#" {% if display_list %}onclick="modifyUrl('display_list', null)"{% endif %}>
+                <i class="fa fa-th" title="Vignettes"></i>
+            </a>
+            <a class="btn btn-default btn-outline-primary {% if display_list %}active{% endif %}" href="#" {% if not display_list %}onclick="modifyUrl('display_list', true)"{% endif %}>
+                <i class="fa fa-bars" title="List"></i>
+            </a>
+        </span>
         </div>
     </form>
 {% if compounds %}
-    {% if display_table %}
+    {% if display_list %}
         {% for compound in compounds %}
             {% include "compound_table_item.html" with compound=compound %}
         {% endfor %}
diff --git a/ippisite/ippidb/views.py b/ippisite/ippidb/views.py
index 235eea2e..c1753120 100644
--- a/ippisite/ippidb/views.py
+++ b/ippisite/ippidb/views.py
@@ -211,6 +211,7 @@ 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)
+    display_list = request.GET.get('display_list')
     return render(request, 'compound_list.html', {'compounds': compounds,
                                                   'count': count,
                                                   'selected_ppis': selected_ppis,
@@ -224,7 +225,8 @@ def compound_list(request):
                                                   'taxonomies_all': taxonomies_all,
                                                   'selected_boundcomplexes': selected_boundcomplexes,
                                                   'boundcomplexes': boundcomplexes,
-                                                  'boundcomplexes_all': boundcomplexes_all
+                                                  'boundcomplexes_all': boundcomplexes_all,
+                                                  'display_list': display_list
                                                 })
 
 def compound_card(request, compound_id):
-- 
GitLab