From daea05835ade7dbad3090c2c7845ad3ee69da1aa Mon Sep 17 00:00:00 2001 From: Laetitia Getti Date: Wed, 7 Jun 2023 19:07:16 +0200 Subject: [PATCH] order detail on click in a modal --- .../order/grouped_order_overview.html | 80 ++++++++++++++++++- la_chariotte/static/css/app.css | 14 ++++ la_chariotte/static/sass/base/_global.sass | 12 ++- la_chariotte/static/sass/base/_variables.sass | 1 + 4 files changed, 104 insertions(+), 3 deletions(-) diff --git a/la_chariotte/order/templates/order/grouped_order_overview.html b/la_chariotte/order/templates/order/grouped_order_overview.html index 66569cd..f608fe6 100644 --- a/la_chariotte/order/templates/order/grouped_order_overview.html +++ b/la_chariotte/order/templates/order/grouped_order_overview.html @@ -116,7 +116,7 @@ {% endfor %} - Total pour la commande groupée + Total {{ grouped_order.total_price }} € @@ -136,6 +136,7 @@ Participant·e Montant Contact + Voir @@ -144,13 +145,41 @@ {{ order.author }} {{ order.price }} € {{ order.author.email }} + + + + {% endfor %} + - Total pour la commande groupée + Total {{ grouped_order.total_price }} € + {% else %} @@ -198,5 +227,52 @@ // Open by default the "resume" tab at first openTab("resume"); + + // Modal + document.addEventListener('DOMContentLoaded', () => { + // Functions to open and close a modal + function openModal($el) { + $el.classList.add('is-active'); + } + + function closeModal($el) { + $el.classList.remove('is-active'); + } + + function closeAllModals() { + (document.querySelectorAll('.modal') || []).forEach(($modal) => { + closeModal($modal); + }); + } + + // Add a click event on buttons to open a specific modal + (document.querySelectorAll('.js-modal-trigger') || []).forEach(($trigger) => { + const modal = $trigger.dataset.target; + const $target = document.getElementById(modal); + + $trigger.addEventListener('click', () => { + openModal($target); + }); + }); + + // Add a click event on various child elements to close the parent modal + (document.querySelectorAll('.modal-background, .modal-close, .modal-card-head .delete, .modal-card-foot .button') || []).forEach(($close) => { + const $target = $close.closest('.modal'); + + $close.addEventListener('click', () => { + closeModal($target); + }); + }); + + // Add a keyboard event to close all modals + document.addEventListener('keydown', (event) => { + const e = event || window.event; + + if (e.keyCode === 27) { // Escape key + closeAllModals(); + } + }); + }); + {% endblock %} \ No newline at end of file diff --git a/la_chariotte/static/css/app.css b/la_chariotte/static/css/app.css index 383278f..838b626 100644 --- a/la_chariotte/static/css/app.css +++ b/la_chariotte/static/css/app.css @@ -10303,6 +10303,20 @@ a { padding: 0; } +.modal-card-foot { + display: block; + padding: 1rem; +} + +.modal-card { + max-width: 90vw; +} + +.modal-card-head { + padding: 1rem; + justify-content: space-between; +} + @media screen and (min-width: 1024px) { .navbar.side-nav { right: inherit; diff --git a/la_chariotte/static/sass/base/_global.sass b/la_chariotte/static/sass/base/_global.sass index a10b439..9f4d24e 100644 --- a/la_chariotte/static/sass/base/_global.sass +++ b/la_chariotte/static/sass/base/_global.sass @@ -13,4 +13,14 @@ a padding: 0 font-size: 0.7rem .content - padding: 0 \ No newline at end of file + padding: 0 +.modal-card-foot + display: block + padding: 1rem + +.modal-card + max-width: 90vw + +.modal-card-head + padding: 1rem + justify-content: space-between diff --git a/la_chariotte/static/sass/base/_variables.sass b/la_chariotte/static/sass/base/_variables.sass index 755ff1e..903df73 100644 --- a/la_chariotte/static/sass/base/_variables.sass +++ b/la_chariotte/static/sass/base/_variables.sass @@ -7,6 +7,7 @@ $grey-text: #7a7a7a $primary: $betterave $info: $beige $text: $bright-black +$grey-text: #7a7a7a // Navbar $side-nav-width: 220px