Display pools only when necessary

This commit is contained in:
Yohann D'ANELLO 2021-01-18 16:49:23 +01:00
parent 364025b195
commit 70d2ade6a3
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 19 additions and 13 deletions

View File

@ -63,10 +63,12 @@
<hr>
<h3>{% trans "Pools" %}</h3>
<div id="pools_table">
{% render_table pools %}
</div>
{% if pools.data %}
<h3>{% trans "Pools" %}</h3>
<div id="pools_table">
{% render_table pools %}
</div>
{% endif %}
{% if user.registration.is_admin %}
<button class="btn btn-block btn-success" data-toggle="modal" data-target="#addPoolModal">{% trans "Add new pool" %}</button>
@ -87,20 +89,24 @@
</div>
</div>
{% trans "Add pool" as modal_title %}
{% trans "Add" as modal_button %}
{% url "participation:pool_create" as modal_action %}
{% include "base_modal.html" with modal_id="addPool" %}
{% if user.registration.is_admin %}
{% trans "Add pool" as modal_title %}
{% trans "Add" as modal_button %}
{% url "participation:pool_create" as modal_action %}
{% include "base_modal.html" with modal_id="addPool" %}
{% endif %}
{% endblock %}
{% block extrajavascript %}
<script>
$(document).ready(function () {
$('button[data-target="#addPoolModal"]').click(function() {
let modalBody = $("#addPoolModal div.modal-body");
if (!modalBody.html().trim())
modalBody.load("{% url "participation:pool_create" %} #form-content")
});
{% if user.registration.is_admin %}
$('button[data-target="#addPoolModal"]').click(function() {
let modalBody = $("#addPoolModal div.modal-body");
if (!modalBody.html().trim())
modalBody.load("{% url "participation:pool_create" %} #form-content")
});
{% endif %}
});
</script>
{% endblock %}