Skip to content

Commit

Permalink
update multiple working + fix filter move plugin
Browse files Browse the repository at this point in the history
* update multiple value is now working
* fix filter that reset to first plugin to select
  • Loading branch information
syrk4web committed Jul 12, 2024
1 parent 79e6eef commit 1e593d5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 28 deletions.
6 changes: 5 additions & 1 deletion src/client/vite/src/components/Form/Advanced.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 0 additions & 1 deletion src/client/vite/src/components/Widget/Filter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ function filterData(filter, value) {
// Remove empty row
template = template.filter((row) => row.length > 0);
}
emits("filter", template);
}
Expand Down
55 changes: 29 additions & 26 deletions src/client/vite/src/utils/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1e593d5

Please sign in to comment.