minor changes
This commit is contained in:
parent
bcf8fa5d66
commit
12fff63715
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user