From 1e593d5b64659ce88e3ba1ec48867b6473139fd6 Mon Sep 17 00:00:00 2001 From: Jordan Blasenhauer Date: Fri, 12 Jul 2024 11:46:04 +0200 Subject: [PATCH] update multiple working + fix filter move plugin * update multiple value is now working * fix filter that reset to first plugin to select --- .../vite/src/components/Form/Advanced.vue | 6 +- .../vite/src/components/Widget/Filter.vue | 1 - src/client/vite/src/utils/form.js | 55 ++++++++++--------- 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/src/client/vite/src/components/Form/Advanced.vue b/src/client/vite/src/components/Form/Advanced.vue index d6e22cf32..da22f2428 100644 --- a/src/client/vite/src/components/Form/Advanced.vue +++ b/src/client/vite/src/components/Form/Advanced.vue @@ -203,7 +203,11 @@ function filter(filterData) { setValidity(); data.format = filterData; data.plugins = getPluginNames(filterData); - data.currPlugin = getFirstPlugin(filterData); + // Check after a filter if previous plugin is still in the list and if at least one plugin is available + // Update if not the case + data.currPlugin = data.plugins.includes(data.currPlugin) + ? data.currPlugin + : getFirstPlugin(filterData); } function setValidity() { diff --git a/src/client/vite/src/components/Widget/Filter.vue b/src/client/vite/src/components/Widget/Filter.vue index ea98b5074..97399810e 100644 --- a/src/client/vite/src/components/Widget/Filter.vue +++ b/src/client/vite/src/components/Widget/Filter.vue @@ -130,7 +130,6 @@ function filterData(filter, value) { // Remove empty row template = template.filter((row) => row.length > 0); } - emits("filter", template); } diff --git a/src/client/vite/src/utils/form.js b/src/client/vite/src/utils/form.js index cb594cc4c..39e7d55ae 100644 --- a/src/client/vite/src/utils/form.js +++ b/src/client/vite/src/utils/form.js @@ -358,36 +358,39 @@ function useUnlistenTemp(handler) { */ function useUpdateTemplate(e, template) { // Wait some ms that previous update logic is done like datepicker - let inpId, inpValue; + setTimeout(() => { + let inpId, inpValue; - // Case target is input (a little different for datepicker) - if (e.target.tagName === "INPUT") { - inpId = e.target.id; - inpValue = e.target.hasAttribute("data-timestamp") - ? e.target.getAttribute("data-timestamp") - : e.target.value; - } - - // Case target is select - if ( - e.target.closest("[data-field-container]") && - e.target.hasAttribute("data-setting-id") && - e.target.hasAttribute("data-setting-value") - ) { - inpId = e.target.getAttribute("data-setting-id"); - inpValue = e.target.getAttribute("data-setting-value"); - } + // Case target is input (a little different for datepicker) + if (e.target.tagName === "INPUT") { + inpId = e.target.id; + inpValue = e.target.hasAttribute("data-timestamp") + ? e.target.getAttribute("data-timestamp") + : e.target.value; + } - // Case target is not an input-like - if (!inpId) return; + // Case target is select + if ( + e.target.closest("[data-field-container]") && + e.target.hasAttribute("data-setting-id") && + e.target.hasAttribute("data-setting-value") + ) { + inpId = e.target.getAttribute("data-setting-id"); + inpValue = e.target.getAttribute("data-setting-value"); + } - // Check if setting is part multiple or regular settings - const isMultiple = e.target.closest('[data-group="multiple"]') ? true : false; + // Case target is not an input-like + if (!inpId) return; - if (!isMultiple) useUpdateTempSettings(template, inpId, inpValue); - if (isMultiple) useUpdateTempMultiples(template, inpId, inpValue); + // Check if setting is part multiple or regular settings + const isMultiple = e.target.closest('[data-group="multiple"]') + ? true + : false; - return template; + if (!isMultiple) useUpdateTempSettings(template, inpId, inpValue); + if (isMultiple) useUpdateTempMultiples(template, inpId, inpValue); + return template; + }, 50); } /** @@ -440,7 +443,7 @@ function useUpdateTempMultiples(template, inpId, inpValue) { for (const [groupId, groupSettings] of Object.entries(multGroups)) { // Check if inpid is mathing a groupSettings key for (const [settingName, settings] of Object.entries(groupSettings)) { - if (!settings?.inpId) continue; + if (settings?.id !== inpId) continue; settings.value = inpValue; isSettingUpdated = true; if (isSettingUpdated) break;