update multiple working + fix filter move plugin

* update multiple value is now working
* fix filter that reset to first plugin to select
This commit is contained in:
Jordan Blasenhauer 2024-07-12 11:46:04 +02:00
parent 79e6eefa2b
commit 1e593d5b64
3 changed files with 34 additions and 28 deletions

View file

@ -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() {

View file

@ -130,7 +130,6 @@ function filterData(filter, value) {
// Remove empty row
template = template.filter((row) => row.length > 0);
}
emits("filter", template);
}

View file

@ -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 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 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 not an input-like
if (!inpId) return;
// Case target is not an input-like
if (!inpId) return;
// Check if setting is part multiple or regular settings
const isMultiple = e.target.closest('[data-group="multiple"]') ? true : false;
// Check if setting is part multiple or regular settings
const isMultiple = e.target.closest('[data-group="multiple"]')
? true
: false;
if (!isMultiple) useUpdateTempSettings(template, inpId, inpValue);
if (isMultiple) useUpdateTempMultiples(template, inpId, inpValue);
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;