2020-08-23 08:06:16 +00:00
|
|
|
{% extends "member/base.html" %}
|
2020-09-01 08:20:16 +00:00
|
|
|
{% comment %}
|
|
|
|
SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
{% endcomment %}
|
2020-07-31 11:17:16 +00:00
|
|
|
{% load i18n %}
|
|
|
|
{% load render_table from django_tables2 %}
|
|
|
|
|
|
|
|
{% block profile_content %}
|
2020-08-25 14:30:02 +00:00
|
|
|
<div class="card bg-light">
|
|
|
|
<h3 class="card-header text-center">
|
|
|
|
{{ title }}
|
|
|
|
</h3>
|
|
|
|
<div class="card-body">
|
|
|
|
<input id="searchbar" type="text" class="form-control" placeholder="Nom/prénom/note…">
|
2020-07-31 15:01:52 +00:00
|
|
|
<div class="form-check">
|
|
|
|
<label class="form-check-label" for="only_active">
|
|
|
|
<input type="checkbox" class="checkboxinput form-check-input" id="only_active"
|
2020-08-25 14:30:02 +00:00
|
|
|
{% if only_active %}checked{% endif %}>
|
2020-07-31 15:01:52 +00:00
|
|
|
{% trans "Display only active memberships" %}
|
|
|
|
</label>
|
|
|
|
</div>
|
2020-08-25 14:30:02 +00:00
|
|
|
<div id="div_id_roles">
|
|
|
|
<label for="roles" class="col-form-label">{% trans "Filter roles:" %}</label>
|
2020-07-31 15:01:52 +00:00
|
|
|
<select name="roles" class="selectmultiple form-control" id="roles" multiple="">
|
|
|
|
{% for role in applicable_roles %}
|
2020-08-25 14:30:02 +00:00
|
|
|
<option value="{{ role.id }}" selected>{{ role.name }}</option>
|
2020-07-31 15:01:52 +00:00
|
|
|
{% endfor %}
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-07-31 11:17:16 +00:00
|
|
|
<div id="memberships_table">
|
|
|
|
{% if table.data %}
|
2020-08-25 14:30:02 +00:00
|
|
|
{% render_table table %}
|
2020-07-31 11:17:16 +00:00
|
|
|
{% else %}
|
2020-08-25 14:30:02 +00:00
|
|
|
<div class="alert alert-warning">
|
|
|
|
{% trans "There is no membership found with this pattern." %}
|
|
|
|
</div>
|
2020-07-31 11:17:16 +00:00
|
|
|
{% endif %}
|
|
|
|
</div>
|
2020-08-25 14:30:02 +00:00
|
|
|
</div>
|
2020-07-31 11:17:16 +00:00
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
{% block extrajavascript %}
|
2020-08-25 14:30:02 +00:00
|
|
|
<script type="text/javascript">
|
|
|
|
$(document).ready(function () {
|
|
|
|
let searchbar_obj = $("#searchbar");
|
|
|
|
let only_active_obj = $("#only_active");
|
|
|
|
let roles_obj = $("#roles");
|
2020-07-31 11:17:16 +00:00
|
|
|
|
2020-08-25 14:30:02 +00:00
|
|
|
function reloadTable() {
|
|
|
|
let pattern = searchbar_obj.val();
|
2020-07-31 11:17:16 +00:00
|
|
|
|
2020-08-25 14:30:02 +00:00
|
|
|
let roles = [];
|
|
|
|
$("#roles option:selected").each(function () {
|
|
|
|
roles.push($(this).val());
|
|
|
|
});
|
|
|
|
let roles_str = roles.join(',');
|
2020-07-31 11:17:16 +00:00
|
|
|
|
2020-08-25 14:30:02 +00:00
|
|
|
$("#memberships_table").load(location.pathname + "?search=" + pattern.replace(" ", "%20") +
|
|
|
|
"&only_active=" + (only_active_obj.is(':checked') ? '1' : '0') +
|
|
|
|
"&roles=" + roles_str + " #memberships_table");
|
|
|
|
}
|
2020-07-31 11:17:16 +00:00
|
|
|
|
2020-08-25 14:30:02 +00:00
|
|
|
searchbar_obj.keyup(reloadTable);
|
|
|
|
only_active_obj.change(reloadTable);
|
|
|
|
roles_obj.change(reloadTable);
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
{% endblock %}
|