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