From 823f9fb6a71060043362dded17a4833bde15f319 Mon Sep 17 00:00:00 2001 From: heswell Date: Fri, 15 Dec 2023 14:05:41 +0000 Subject: [PATCH] save renamed filter --- .../src/TickingArrayDataSource.ts | 1 - .../vuu-filters/src/filter-bar/useFilters.ts | 20 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/vuu-ui/packages/vuu-data-test/src/TickingArrayDataSource.ts b/vuu-ui/packages/vuu-data-test/src/TickingArrayDataSource.ts index aec7a8019..9432b3ed1 100644 --- a/vuu-ui/packages/vuu-data-test/src/TickingArrayDataSource.ts +++ b/vuu-ui/packages/vuu-data-test/src/TickingArrayDataSource.ts @@ -110,7 +110,6 @@ export class TickingArrayDataSource extends ArrayDataSource { columnName: string, value: VuuRowDataItemType ): Promise { - console.log(`applyEdit ${columnName} ${value}`); const key = row[metadataKeys.KEY]; this.#table?.update(key, columnName, value); return Promise.resolve(true); diff --git a/vuu-ui/packages/vuu-filters/src/filter-bar/useFilters.ts b/vuu-ui/packages/vuu-filters/src/filter-bar/useFilters.ts index 66ec7fed9..41c887c23 100644 --- a/vuu-ui/packages/vuu-filters/src/filter-bar/useFilters.ts +++ b/vuu-ui/packages/vuu-filters/src/filter-bar/useFilters.ts @@ -39,11 +39,14 @@ export const useFilters = ({ const { module, table } = tableSchema.table; const key = `${module}:${table}`; if (savedFilters) { - console.log("TODO add filter to exisitng store", { + console.log("add filter to existing store ... ", { savedFilters, }); if (savedFilters[key]) { + console.log("add filter to existing filters for this table ... "); if (savedFilters[key].findIndex((f) => f.name === name) !== -1) { + console.log("We already have a filter by that name, replace it "); + saveApplicationSettings( { ...savedFilters, @@ -53,6 +56,21 @@ export const useFilters = ({ }, "filters" ); + } else if ( + name !== undefined && + filter?.name !== undefined && + filter?.name !== name && + savedFilters[key].findIndex((f) => f.name === filter.name) !== -1 + ) { + saveApplicationSettings( + { + ...savedFilters, + [key]: savedFilters[key].map((f) => + f.name === filter.name ? { ...filter, name } : f + ), + }, + "filters" + ); } else { saveApplicationSettings( {