From 12fff63715ddb8d0b3143504a8a2ca29239b3b85 Mon Sep 17 00:00:00 2001 From: eclipse Date: Wed, 28 May 2025 22:09:03 +0200 Subject: [PATCH] minor changes --- the_works/static/js/modal.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/the_works/static/js/modal.js b/the_works/static/js/modal.js index 09fad8a..002592a 100644 --- a/the_works/static/js/modal.js +++ b/the_works/static/js/modal.js @@ -9,23 +9,17 @@ function initModal(modal_id, input_ids, headings, form_actions) { document.getElementById("create-button").addEventListener("click", () => showDialog(modal_id, input_ids, headings[0], form_actions[0], new Array(input_ids.length).fill(""), 0)); // add event listeners to "update" elements for (const el of document.querySelectorAll('.action-update')) { - el.addEventListener("click", event => showDialog( - modal_id, - input_ids, - headings[1], - form_actions[1], - input_ids.map(input => event.currentTarget.dataset[input.slice(5).toLowerCase()]), - event.currentTarget.dataset.id - )); + el.addEventListener("click", event => showDialog(modal_id, input_ids, headings[1], form_actions[1], input_ids.map(input => event.currentTarget.dataset[input.slice(5).toLowerCase()]), event.currentTarget.dataset.id)); } // add event listener to close button - document.querySelector("dialog button.modal-close").addEventListener("click", event => event.target.closest("dialog").close()); + document.querySelector("dialog button.modal-close").addEventListener("click", event => { + event.target.closest("dialog").close(); + }); } // raises a modal with the given options function showDialog(modal_id, input_ids, heading, form_action, input_values, url_id) { -console.dir(arguments); // if form action includes the string "update", the id at the end of the URL is a dummy and must be replaced with the correct id if ( form_action.includes("update") && url_id) { form_action = form_action.slice(0, form_action.lastIndexOf("/") + 1) + url_id;