diff --git a/modules/holidays/holidays.js b/modules/holidays/holidays.js index 7d948f8..749f5d4 100644 --- a/modules/holidays/holidays.js +++ b/modules/holidays/holidays.js @@ -115,87 +115,80 @@ function closeHolidayModal() { function editHoliday(data) { const h = data.main; const modal = document.getElementById("holidayModal"); + if (!modal) return; - if (!modal) { - alert(tr("err_modal_missing")); - return; - } + openHolidayModal("edit"); - document.body.appendChild(modal); + document.getElementById("inp_id").value = h.id; + document.getElementById("inp_title").value = h.title; + document.getElementById("inp_status").value = h.status; + document.getElementById("inp_period").value = h.period_hint || ""; + document.getElementById("inp_start").value = h.start_date || ""; + document.getElementById("inp_end").value = h.end_date || ""; + document.getElementById("inp_food").value = + h.budget_food > 0 ? h.budget_food : ""; + document.getElementById("inp_extra").value = + h.budget_extra > 0 ? h.budget_extra : ""; + document.getElementById("inp_notes").value = h.notes || ""; - if (typeof openHolidayModal === "function") { - openHolidayModal("edit"); - } + document.getElementById("list_transport").innerHTML = ""; + document.getElementById("list_accommodation").innerHTML = ""; + document.getElementById("list_activity").innerHTML = ""; - modal.classList.add("open"); - modal.style.setProperty("display", "flex", "important"); - modal.style.setProperty("z-index", "999999", "important"); - document.body.classList.add("no-scroll"); - - try { - document.getElementById("inp_id").value = h.id; - document.getElementById("inp_title").value = h.title; - document.getElementById("inp_status").value = h.status; - document.getElementById("inp_period").value = h.period_hint || ""; - document.getElementById("inp_start").value = h.start_date || ""; - document.getElementById("inp_end").value = h.end_date || ""; - - document.getElementById("inp_food").value = - h.budget_food > 0 ? h.budget_food : ""; - document.getElementById("inp_extra").value = - h.budget_extra > 0 ? h.budget_extra : ""; - document.getElementById("inp_notes").value = h.notes || ""; - } catch (err) { - console.error("Erreur champs textes :", err); - } - - try { - document.getElementById("list_transport").innerHTML = ""; - document.getElementById("list_accommodation").innerHTML = ""; - document.getElementById("list_activity").innerHTML = ""; - - if (data.items && data.items.length > 0) { - data.items.forEach((item) => { - if ( - typeof addItem === "function" && - item.name !== "PF_TECHNICAL_POINT" - ) { - addItem(item.category, item.name, item.amount, item.is_paid); - } - }); - } - } catch (err) { - console.error("Erreur listes :", err); + if (data.items) { + data.items.forEach((item) => { + if (item.name !== "PF_TECHNICAL_POINT") { + // On passe maintenant l'ID et le lieu à addItem + addItem( + item.category, + item.name, + item.amount, + item.is_paid, + item.id, + item.location_name || "", + ); + } + }); } } // --- 2. GESTION DES LISTES DYNAMIQUES DANS LA MODALE --- -function addItem(category, name = "", amount = "", isPaid = 0) { +function addItem( + category, + name = "", + amount = "", + isPaid = 0, + id = "", + location = "", +) { const container = document.getElementById("list_" + category); const div = document.createElement("div"); - - div.style.display = "flex"; - div.style.gap = "8px"; - div.style.alignItems = "center"; + div.className = "savings-line-item"; // Utilisation de ta classe existante div.style.marginBottom = "10px"; const checkedAttr = isPaid == 1 ? "checked" : ""; + // Optimisation : Affichage du badge d'étape si existant + const locationBadge = location + ? `📍 ${location}` + : ""; div.innerHTML = ` + - - + +