Skip to content

Commit

Permalink
optimise filter call number on input update
Browse files Browse the repository at this point in the history
  • Loading branch information
syrk4web committed Jul 12, 2024
1 parent cb334c5 commit 8b17e99
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/client/vite/src/components/Widget/Filter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,21 @@ const filters = reactive({
});
watch(props.data, () => {
filters.base.forEach((filter) => {
filterData(filter, filter.value);
});
filterData();
});
function filterData(filter, value) {
// Case we are changing a filter value
// We only have to check data for this filter
function filterData(filter = {}, value = "") {
// Case we have new filter value, update it
// Loop on filter.base and update the "value" key when matching filterName
filters.base.forEach((f) => {
if (f.filterName === filter.filterName) {
f.value = value;
}
});
if (filter?.filterName && value) {
filters.base.forEach((f) => {
if (f.filterName === filter.filterName) {
f.value = value;
}
});
}
// Start filtering
let template = JSON.parse(JSON.stringify(props.data));
Expand Down Expand Up @@ -130,6 +133,7 @@ function filterData(filter, value) {
// Remove empty row
template = template.filter((row) => row.length > 0);
}
console.log("filter");
emits("filter", template);
}
Expand All @@ -152,6 +156,7 @@ function filterRegularSettings(filterSettings, template) {
}
function filterMultiplesSettings(filterSettings, template) {
// Loop on plugins and get multiples settings like this
template.forEach((plugin, id) => {
// loop on plugin settings dict
const filterMultiple = {};
Expand Down

0 comments on commit 8b17e99

Please sign in to comment.