Amélioration de l'UX lors de l'import d'un événement
This commit is contained in:
parent
d71f49e297
commit
df0ae03076
@ -1,8 +1,16 @@
|
|||||||
let visibleModal = null;
|
let visibleModal = null;
|
||||||
|
var escapeOk = true;
|
||||||
|
|
||||||
|
const toggleModalNoEscape = (event) => {
|
||||||
|
toggleModal(event, true);
|
||||||
|
escapeOk = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Toggle modal
|
// Toggle modal
|
||||||
const toggleModal = (event) => {
|
const toggleModal = (event, avoidPrevent=false) => {
|
||||||
event.preventDefault();
|
escapeOk = true;
|
||||||
|
if (!avoidPrevent)
|
||||||
|
event.preventDefault();
|
||||||
const modal = document.getElementById(event.currentTarget.getAttribute("data-target"));
|
const modal = document.getElementById(event.currentTarget.getAttribute("data-target"));
|
||||||
typeof modal != "undefined" && modal != null && isModalOpen(modal)
|
typeof modal != "undefined" && modal != null && isModalOpen(modal)
|
||||||
? closeModal(modal)
|
? closeModal(modal)
|
||||||
@ -28,15 +36,16 @@ const openModal = (modal) => {
|
|||||||
|
|
||||||
// Close modal
|
// Close modal
|
||||||
const closeModal = (modal) => {
|
const closeModal = (modal) => {
|
||||||
visibleModal = null;
|
if (escapeOk) {
|
||||||
document.documentElement.style.removeProperty("--scrollbar-width");
|
visibleModal = null;
|
||||||
modal.removeAttribute("open");
|
document.documentElement.style.removeProperty("--scrollbar-width");
|
||||||
|
modal.removeAttribute("open");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Close with a click outside
|
// Close with a click outside
|
||||||
document.addEventListener("click", (event) => {
|
document.addEventListener("click", (event) => {
|
||||||
if (visibleModal != null) {
|
if (visibleModal != null) {
|
||||||
console.log("bordel");
|
|
||||||
const modalContent = visibleModal.querySelector("article");
|
const modalContent = visibleModal.querySelector("article");
|
||||||
const isClickInside = modalContent.contains(event.target);
|
const isClickInside = modalContent.contains(event.target);
|
||||||
!isClickInside && closeModal(visibleModal);
|
!isClickInside && closeModal(visibleModal);
|
||||||
|
@ -18,7 +18,11 @@
|
|||||||
|
|
||||||
{% load static_content_extra %}
|
{% load static_content_extra %}
|
||||||
|
|
||||||
|
{% if object %}
|
||||||
<h1>Édition de l'événement {{ object.title }} ({{ object.start_day }})</h1>
|
<h1>Édition de l'événement {{ object.title }} ({{ object.start_day }})</h1>
|
||||||
|
{% else %}
|
||||||
|
<h1>Édition de l'événement importé</h1>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<form method="post">{% csrf_token %}
|
<form method="post">{% csrf_token %}
|
||||||
{{ form.media }}
|
{{ form.media }}
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
<script src="/static/admin/js/admin/RelatedObjectLookups.js"></script>
|
<script src="/static/admin/js/admin/RelatedObjectLookups.js"></script>
|
||||||
<script src="{% static 'recurrence/js/recurrence-widget.js' %}"></script>
|
<script src="{% static 'recurrence/js/recurrence-widget.js' %}"></script>
|
||||||
<script src="{% static 'recurrence/js/recurrence-widget.init.js' %}"></script>
|
<script src="{% static 'recurrence/js/recurrence-widget.init.js' %}"></script>
|
||||||
|
|
||||||
|
<script src="{% static 'js/modal.js' %}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
@ -36,10 +38,14 @@
|
|||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form.media }}
|
{{ form.media }}
|
||||||
{{ form.as_p }}
|
{{ form.as_p }}
|
||||||
<input type="submit" value="Lancer l'import">
|
<input type="submit" value="Lancer l'import" id="import-button" data-target="modal-import" onClick="toggleModalNoEscape(event)">
|
||||||
</form>
|
</form>
|
||||||
</article>
|
</article>
|
||||||
|
<dialog id="modal-import">
|
||||||
|
<article aria-busy="true">
|
||||||
|
Veuillez patienter, lien en cours d'importation...
|
||||||
|
</article>
|
||||||
|
</dialog>
|
||||||
<article>
|
<article>
|
||||||
<header>
|
<header>
|
||||||
<h2>Ajout manuel</h2>
|
<h2>Ajout manuel</h2>
|
||||||
|
Loading…
Reference in New Issue
Block a user