mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
core: add macro that selects/unselect all checkbox
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
{% extends "core/base.jinja" %}
|
||||
{% from "core/macros.jinja" import select_all_checkbox %}
|
||||
|
||||
{% block title %}
|
||||
{% trans %}Group detail{% endtrans %}
|
||||
@ -11,6 +12,8 @@
|
||||
<p>{% trans %}No user in this group{% endtrans %}</p>
|
||||
{% else %}
|
||||
<form action="{{ url('core:group_detail', object.id) }}" method="post" id="add_users">
|
||||
{{ select_all_checkbox("add_users") }}
|
||||
<hr>
|
||||
{% csrf_token %}
|
||||
<label for="{{ form.users_removed.id_for_label }}">{{ form.users_removed.label }} :</label>
|
||||
{{ form.users_removed.errors }}
|
||||
|
@ -132,3 +132,18 @@
|
||||
<span class="disabled">{% trans %}Next{% endtrans %}</span>
|
||||
{% endif %}
|
||||
{% 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 %}
|
Reference in New Issue
Block a user