From 35f69b9a9bb751621abe67b746e206d587c99886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Poincelet?= Date: Tue, 3 Dec 2024 12:04:23 +0100 Subject: [PATCH] fix layers error if don't exist when drag n drop --- js/mviewerstudio.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/js/mviewerstudio.js b/js/mviewerstudio.js index ff36575a..7e1e00cd 100644 --- a/js/mviewerstudio.js +++ b/js/mviewerstudio.js @@ -554,12 +554,6 @@ function initializeNestedSortables() { item.setAttribute("data-groupid", toGroupId); item.setAttribute("data-themeid", toThemeId); - config.themes[toThemeId].layers.forEach((layer) => { - if (layer.id === item.getAttribute("data-layerid")) { - layer["data-groupid"] = toGroupId; - layer["data-themeid"] = toThemeId; - } - }); // Cherche l'index de départ en fonction de si le layer bougé vient d'un groupe ou un thème const index = fromGroupId ? config.themes[fromThemeId].groups @@ -593,6 +587,13 @@ function initializeNestedSortables() { .layers.splice(newIndex, 0, itemToMove) : config.themes[toThemeId].layers.splice(newIndex, 0, itemToMove); } + + config.themes[toThemeId].layers.forEach((layer) => { + if (layer.id === item.getAttribute("data-layerid")) { + layer["data-groupid"] = toGroupId; + layer["data-themeid"] = toThemeId; + } + }); }, }); // Marquer cet élément comme "initialisé" pour éviter les doublons