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, ), }; };