core: add macro that selects/unselect all checkbox

This commit is contained in:
Antoine Bartuccio 2019-04-22 14:59:32 +02:00
parent 96e33815f5
commit 2ae10ee2fb
Signed by: klmp200
GPG Key ID: E7245548C53F904B
3 changed files with 36 additions and 10 deletions

View File

@ -1,4 +1,5 @@
{% extends "core/base.jinja" %} {% extends "core/base.jinja" %}
{% from "core/macros.jinja" import select_all_checkbox %}
{% block title %} {% block title %}
{% trans %}Group detail{% endtrans %} {% trans %}Group detail{% endtrans %}
@ -11,6 +12,8 @@
<p>{% trans %}No user in this group{% endtrans %}</p> <p>{% trans %}No user in this group{% endtrans %}</p>
{% else %} {% else %}
<form action="{{ url('core:group_detail', object.id) }}" method="post" id="add_users"> <form action="{{ url('core:group_detail', object.id) }}" method="post" id="add_users">
{{ select_all_checkbox("add_users") }}
<hr>
{% csrf_token %} {% csrf_token %}
<label for="{{ form.users_removed.id_for_label }}">{{ form.users_removed.label }} :</label> <label for="{{ form.users_removed.id_for_label }}">{{ form.users_removed.label }} :</label>
{{ form.users_removed.errors }} {{ form.users_removed.errors }}

View File

@ -132,3 +132,18 @@
<span class="disabled">{% trans %}Next{% endtrans %}</span> <span class="disabled">{% trans %}Next{% endtrans %}</span>
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}
{% macro select_all_checkbox(form_id) %}
<script type="text/javascript">
function checkbox_{{form_id}}(value) {
list = document.getElementById("{{ form_id }}").getElementsByTagName("input");
for (let element of list){
if (element.type == "checkbox"){
element.checked = value;
}
}
}
</script>
<button type="button" onclick="checkbox_{{form_id}}(true);">{% trans %}Select All{% endtrans %}</button>
<button type="button" onclick="checkbox_{{form_id}}(false);">{% trans %}Unselect All{% endtrans %}</button>
{% endmacro %}

View File

@ -6,7 +6,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-04-11 01:41+0200\n" "POT-Creation-Date: 2019-04-22 14:57+0200\n"
"PO-Revision-Date: 2016-07-18\n" "PO-Revision-Date: 2016-07-18\n"
"Last-Translator: Skia <skia@libskia.so>\n" "Last-Translator: Skia <skia@libskia.so>\n"
"Language-Team: AE info <ae.info@utbm.fr>\n" "Language-Team: AE info <ae.info@utbm.fr>\n"
@ -361,8 +361,8 @@ msgstr "Compte en banque : "
#: com/templates/com/weekmail.jinja:62 core/templates/core/file_detail.jinja:25 #: com/templates/com/weekmail.jinja:62 core/templates/core/file_detail.jinja:25
#: core/templates/core/file_detail.jinja:62 #: core/templates/core/file_detail.jinja:62
#: core/templates/core/file_moderation.jinja:24 #: core/templates/core/file_moderation.jinja:24
#: core/templates/core/group_detail.jinja:23 #: core/templates/core/group_detail.jinja:26
#: core/templates/core/group_list.jinja:22 core/templates/core/macros.jinja:93 #: core/templates/core/group_list.jinja:25 core/templates/core/macros.jinja:93
#: core/templates/core/macros.jinja:112 core/templates/core/page_prop.jinja:14 #: core/templates/core/macros.jinja:112 core/templates/core/page_prop.jinja:14
#: core/templates/core/user_account_detail.jinja:38 #: core/templates/core/user_account_detail.jinja:38
#: core/templates/core/user_detail.jinja:178 #: core/templates/core/user_detail.jinja:178
@ -418,7 +418,7 @@ msgstr "Nouveau compte club"
#: com/templates/com/poster_list.jinja:45 #: com/templates/com/poster_list.jinja:45
#: com/templates/com/screen_list.jinja:26 com/templates/com/weekmail.jinja:32 #: com/templates/com/screen_list.jinja:26 com/templates/com/weekmail.jinja:32
#: com/templates/com/weekmail.jinja:61 core/templates/core/file.jinja:38 #: com/templates/com/weekmail.jinja:61 core/templates/core/file.jinja:38
#: core/templates/core/group_list.jinja:21 core/templates/core/page.jinja:35 #: core/templates/core/group_list.jinja:24 core/templates/core/page.jinja:35
#: core/templates/core/poster_list.jinja:40 #: core/templates/core/poster_list.jinja:40
#: core/templates/core/user_tools.jinja:42 core/views/user.py:237 #: core/templates/core/user_tools.jinja:42 core/views/user.py:237
#: counter/templates/counter/cash_summary_list.jinja:53 #: counter/templates/counter/cash_summary_list.jinja:53
@ -1033,7 +1033,7 @@ msgstr "Rôle"
#: club/templates/club/club_members.jinja:10 #: club/templates/club/club_members.jinja:10
#: club/templates/club/club_old_members.jinja:10 #: club/templates/club/club_old_members.jinja:10
#: core/templates/core/group_list.jinja:14 #: core/templates/core/group_list.jinja:15
#: core/templates/core/user_clubs.jinja:17 #: core/templates/core/user_clubs.jinja:17
#: core/templates/core/user_clubs.jinja:43 #: core/templates/core/user_clubs.jinja:43
msgid "Description" msgid "Description"
@ -2575,16 +2575,16 @@ msgstr "Modération des fichiers"
msgid "Full name: " msgid "Full name: "
msgstr "Nom complet : " msgstr "Nom complet : "
#: core/templates/core/group_detail.jinja:4 #: core/templates/core/group_detail.jinja:5
msgid "Group detail" msgid "Group detail"
msgstr "Détail du groupe" msgstr "Détail du groupe"
#: core/templates/core/group_detail.jinja:9 #: core/templates/core/group_detail.jinja:10
#: core/templates/core/group_edit.jinja:4 #: core/templates/core/group_edit.jinja:4
msgid "Back to list" msgid "Back to list"
msgstr "Retour à la liste" msgstr "Retour à la liste"
#: core/templates/core/group_detail.jinja:11 #: core/templates/core/group_detail.jinja:12
msgid "No user in this group" msgid "No user in this group"
msgstr "Aucun utilisateur dans ce groupe" msgstr "Aucun utilisateur dans ce groupe"
@ -2607,11 +2607,11 @@ msgstr "Liste des groupes"
msgid "New group" msgid "New group"
msgstr "Nouveau groupe" msgstr "Nouveau groupe"
#: core/templates/core/group_list.jinja:12 #: core/templates/core/group_list.jinja:13
msgid "ID" msgid "ID"
msgstr "ID" msgstr "ID"
#: core/templates/core/group_list.jinja:13 #: core/templates/core/group_list.jinja:14
msgid "Group" msgid "Group"
msgstr "Groupe" msgstr "Groupe"
@ -2680,6 +2680,14 @@ msgstr "actuel"
msgid "Next" msgid "Next"
msgstr "Suivant" msgstr "Suivant"
#: core/templates/core/macros.jinja:147
msgid "Select All"
msgstr "Tout sélectionner"
#: core/templates/core/macros.jinja:148
msgid "Unselect All"
msgstr "Tout désélectionner"
#: core/templates/core/macros_pages.jinja:4 #: core/templates/core/macros_pages.jinja:4
#, python-format #, python-format
msgid "You're seeing the history of page \"%(page_name)s\"" msgid "You're seeing the history of page \"%(page_name)s\""