diff options
Diffstat (limited to '')
-rw-r--r-- | server/templates/server/doc_list.html | 58 | ||||
-rw-r--r-- | server/templates/server/doc_list_readonly.html | 57 | ||||
-rw-r--r-- | server/views.py | 12 | ||||
-rw-r--r-- | version.txt | 2 |
4 files changed, 126 insertions, 3 deletions
diff --git a/server/templates/server/doc_list.html b/server/templates/server/doc_list.html index 064aeb8..be18abf 100644 --- a/server/templates/server/doc_list.html +++ b/server/templates/server/doc_list.html @@ -132,9 +132,30 @@ <input type="hidden" name="owner" id="owner"> <input type="hidden" name="type" id="type"> <input type="hidden" name="groups" id="groups"> +<div class="row"> + <a href="#!"><div class="chip" onClick="showAll()"> + {{total_count}} Tutti + </div></a> + <a href="#!"><div id="colonia_filter" class="chip {{color}} white-text" onClick="filterResults('colonia')"> + {{colonia_count}} Colonia + </div></a> + <a href="#!"><div id="muta_filter" class="chip {{color}} white-text" onClick="filterResults('muta')"> + {{muta_count}} Muta + </div></a> + <a href="#!"><div id="reparto_filter" class="chip {{color}} white-text" onClick="filterResults('reparto')"> + {{reparto_count}} Reparto + </div></a> + <a href="#!"><div id="posto_filter" class="chip {{color}} white-text" onClick="filterResults('posto')"> + {{posto_count}} Posto + </div></a> + <a href="#!"><div id="clan_filter" class="chip {{color}} white-text" onClick="filterResults('clan')"> + {{clan_count}} Clan + </div></a> +</div> <ul class="collapsible"> {% for doc in docs %} - <li> + <li class="item"> + <input value="{{doc.user|user_primary_group}}" type="hidden"> <div class="collapsible-header"> <label> <input name={{doc.id}} type="checkbox" class="filled-in allselect"/> @@ -631,4 +652,39 @@ var options = { labelYearSelect: 'Seleziona un anno' } } + +function filterResults(group_name) { + var items = document.getElementsByClassName("item"); + var btn = document.getElementById(group_name + "_filter"); + var action = "none"; + if (btn.className == "chip") { + btn.className = "chip {{color}} white-text"; + action = ""; + } else { + btn.className = "chip"; + action = "none"; + } + + for (i = 0; i < items.length; i++) { + var a = items[i].children[0]; + var txtValue = a.value; + if (txtValue == group_name) { + items[i].style.display = action; + } + } +} + +function showAll() { + var items = document.getElementsByClassName("item"); + document.getElementById("colonia_filter").className = "chip {{color}} white-text"; + document.getElementById("muta_filter").className = "chip {{color}} white-text"; + document.getElementById("reparto_filter").className = "chip {{color}} white-text"; + document.getElementById("posto_filter").className = "chip {{color}} white-text"; + document.getElementById("clan_filter").className = "chip {{color}} white-text"; + + for (i = 0; i < items.length; i++) { + items[i].style.display = ""; + } +} + {% endblock %}
\ No newline at end of file diff --git a/server/templates/server/doc_list_readonly.html b/server/templates/server/doc_list_readonly.html index bd2c3bf..6db49c8 100644 --- a/server/templates/server/doc_list_readonly.html +++ b/server/templates/server/doc_list_readonly.html @@ -113,9 +113,30 @@ <input type="hidden" name="owner" id="owner"> <input type="hidden" name="type" id="type"> <input type="hidden" name="groups" id="groups"> +<div class="row"> + <a href="#!"><div class="chip" onClick="showAll()"> + {{total_count}} Tutti + </div></a> + <a href="#!"><div id="colonia_filter" class="chip {{color}} white-text" onClick="filterResults('colonia')"> + {{colonia_count}} Colonia + </div></a> + <a href="#!"><div id="muta_filter" class="chip {{color}} white-text" onClick="filterResults('muta')"> + {{muta_count}} Muta + </div></a> + <a href="#!"><div id="reparto_filter" class="chip {{color}} white-text" onClick="filterResults('reparto')"> + {{reparto_count}} Reparto + </div></a> + <a href="#!"><div id="posto_filter" class="chip {{color}} white-text" onClick="filterResults('posto')"> + {{posto_count}} Posto + </div></a> + <a href="#!"><div id="clan_filter" class="chip {{color}} white-text" onClick="filterResults('clan')"> + {{clan_count}} Clan + </div></a> +</div> <ul class="collapsible"> {% for doc in docs %} - <li> + <li class="item"> + <input value="{{doc.user|user_primary_group}}" type="hidden"> <div class="collapsible-header"> <label> <input name={{doc.id}} type="checkbox" class="filled-in allselect"/> @@ -612,4 +633,38 @@ var options = { labelYearSelect: 'Seleziona un anno' } } + +function filterResults(group_name) { + var items = document.getElementsByClassName("item"); + var btn = document.getElementById(group_name + "_filter"); + var action = "none"; + if (btn.className == "chip") { + btn.className = "chip {{color}} white-text"; + action = ""; + } else { + btn.className = "chip"; + action = "none"; + } + + for (i = 0; i < items.length; i++) { + var a = items[i].children[0]; + var txtValue = a.value; + if (txtValue == group_name) { + items[i].style.display = action; + } + } +} + +function showAll() { + var items = document.getElementsByClassName("item"); + document.getElementById("colonia_filter").className = "chip {{color}} white-text"; + document.getElementById("muta_filter").className = "chip {{color}} white-text"; + document.getElementById("reparto_filter").className = "chip {{color}} white-text"; + document.getElementById("posto_filter").className = "chip {{color}} white-text"; + document.getElementById("clan_filter").className = "chip {{color}} white-text"; + + for (i = 0; i < items.length; i++) { + items[i].style.display = ""; + } +} {% endblock %}
\ No newline at end of file diff --git a/server/views.py b/server/views.py index 68c1e77..601bd0f 100644 --- a/server/views.py +++ b/server/views.py @@ -1050,6 +1050,12 @@ def doclist(request): 'error': error,
'error_text': error_text,
'settings': settings,
+ 'total_count': documents.count,
+ 'colonia_count': documents.filter(user__groups__name__contains="colonia").count,
+ 'muta_count': documents.filter(user__groups__name__contains="muta").count,
+ 'reparto_count': documents.filter(user__groups__name__contains="reparto").count,
+ 'posto_count': documents.filter(user__groups__name__contains="posto").count,
+ 'clan_count': documents.filter(user__groups__name__contains="clan").count,
}
# check if download multiple documents
@@ -1274,6 +1280,12 @@ def doclist_readonly(request): 'error': error,
'error_text': error_text,
'settings': settings,
+ 'total_count': documents.count,
+ 'colonia_count': documents.filter(user__groups__name__contains="colonia").count,
+ 'muta_count': documents.filter(user__groups__name__contains="muta").count,
+ 'reparto_count': documents.filter(user__groups__name__contains="reparto").count,
+ 'posto_count': documents.filter(user__groups__name__contains="posto").count,
+ 'clan_count': documents.filter(user__groups__name__contains="clan").count,
}
# check if download multiple documents
diff --git a/version.txt b/version.txt index 3a5ff63..99b2087 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ version=0.5 -rev=28 +rev=29 |