From ac77bc2cf26795888eba7dc3a34145dbf1ef9724 Mon Sep 17 00:00:00 2001 From: Hassan Albaaj Date: Wed, 28 Aug 2024 14:39:23 +0200 Subject: [PATCH] fix: remove saved setting of disabled column --- demo/helpers/x-page.js | 11 +++++++++++ lib/settings/normalize.js | 19 +++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/demo/helpers/x-page.js b/demo/helpers/x-page.js index 1df27efb..6f13041a 100644 --- a/demo/helpers/x-page.js +++ b/demo/helpers/x-page.js @@ -78,6 +78,12 @@ class XPage extends translatable(PolymerElement) { Loading + + Hide Sub-property column + (item) => item.name === name; export const normalizeColumns = ( columns = [], settings = [], - savedSettings = [] + savedSettings = [], ) => { - const cols = columns.filter( + const _settings = settings.filter((setting) => + columns.some(byName(setting.name)), + ), + cols = columns.filter( (column) => !settings.some(byName(column.name)) && - !savedSettings.some(byName(column.name)) + !savedSettings.some(byName(column.name)), ), _savedSettings = savedSettings.filter( - (column) => !settings.some(byName(column.name)) + (column) => !settings.some(byName(column.name)), ); return [ - ...settings, + ..._settings, ..._savedSettings.flatMap((setting) => { const column = columns.find((c) => c.name === setting.name); @@ -52,13 +55,13 @@ export const normalizeStore = (settings, current) => ({ ...current, ...props(sgProps)(settings), columns: settings.columns?.map( - props(['name', 'priority', 'width', 'flex', 'disabled']) + props(['name', 'priority', 'width', 'flex', 'disabled']), ), }); export default ({ columns, settings, savedSettings, initial }) => { const init = Object.fromEntries( - sgProps.flatMap((k) => (initial[k] != null ? [[k, initial[k]]] : [])) + sgProps.flatMap((k) => (initial[k] != null ? [[k, initial[k]]] : [])), ); return { @@ -68,7 +71,7 @@ export default ({ columns, settings, savedSettings, initial }) => { columns: normalizeColumns( columns, settings?.columns, - savedSettings?.columns + savedSettings?.columns, ), }; };