From 94fec5b62be7557a0eaab4446e62e0f1ac44a2d5 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 17 Jul 2024 12:45:31 +0100 Subject: [PATCH] Update how grid blocks handle visible columns to ensure conditions work on hidden columns --- .../client/src/components/app/GridBlock.svelte | 3 +-- .../src/components/grid/layout/Grid.svelte | 2 -- .../src/components/grid/stores/config.js | 2 -- .../src/components/grid/stores/datasource.js | 18 ++++-------------- 4 files changed, 5 insertions(+), 20 deletions(-) diff --git a/packages/client/src/components/app/GridBlock.svelte b/packages/client/src/components/app/GridBlock.svelte index bd210e5998..cfc42692ea 100644 --- a/packages/client/src/components/app/GridBlock.svelte +++ b/packages/client/src/components/app/GridBlock.svelte @@ -42,7 +42,6 @@ $: currentTheme = $context?.device?.theme $: darkMode = !currentTheme?.includes("light") $: parsedColumns = getParsedColumns(columns) - $: columnWhitelist = parsedColumns.filter(x => x.active).map(x => x.field) $: schemaOverrides = getSchemaOverrides(parsedColumns) $: enrichedButtons = enrichButtons(buttons) $: selectedRows = deriveSelectedRows(gridContext) @@ -98,6 +97,7 @@ displayName: column.label, order: idx, conditions: column.conditions, + visible: !!column.active, } if (column.width) { overrides[column.field].width = column.width @@ -170,7 +170,6 @@ {initialSortColumn} {initialSortOrder} {fixedRowHeight} - {columnWhitelist} {schemaOverrides} canAddRows={allowAddRows} canEditRows={allowEditRows} diff --git a/packages/frontend-core/src/components/grid/layout/Grid.svelte b/packages/frontend-core/src/components/grid/layout/Grid.svelte index ba72900ef1..007ad0f8fb 100644 --- a/packages/frontend-core/src/components/grid/layout/Grid.svelte +++ b/packages/frontend-core/src/components/grid/layout/Grid.svelte @@ -37,7 +37,6 @@ export let API = null export let datasource = null export let schemaOverrides = null - export let columnWhitelist = null export let canAddRows = true export let canExpandRows = true export let canEditRows = true @@ -94,7 +93,6 @@ $: props.set({ datasource, schemaOverrides, - columnWhitelist, canAddRows, canExpandRows, canEditRows, diff --git a/packages/frontend-core/src/components/grid/stores/config.js b/packages/frontend-core/src/components/grid/stores/config.js index d2d07c630e..fc0435f92d 100644 --- a/packages/frontend-core/src/components/grid/stores/config.js +++ b/packages/frontend-core/src/components/grid/stores/config.js @@ -12,7 +12,6 @@ export const createStores = context => { const initialFilter = getProp("initialFilter") const fixedRowHeight = getProp("fixedRowHeight") const schemaOverrides = getProp("schemaOverrides") - const columnWhitelist = getProp("columnWhitelist") const notifySuccess = getProp("notifySuccess") const notifyError = getProp("notifyError") const rowConditions = getProp("rowConditions") @@ -24,7 +23,6 @@ export const createStores = context => { initialFilter, fixedRowHeight, schemaOverrides, - columnWhitelist, notifySuccess, notifyError, rowConditions, diff --git a/packages/frontend-core/src/components/grid/stores/datasource.js b/packages/frontend-core/src/components/grid/stores/datasource.js index 8b8ffdf2cf..12a3bd5afe 100644 --- a/packages/frontend-core/src/components/grid/stores/datasource.js +++ b/packages/frontend-core/src/components/grid/stores/datasource.js @@ -13,14 +13,8 @@ export const createStores = () => { } export const deriveStores = context => { - const { - API, - definition, - schemaOverrides, - columnWhitelist, - datasource, - schemaMutations, - } = context + const { API, definition, schemaOverrides, datasource, schemaMutations } = + context const schema = derived(definition, $definition => { let schema = getDatasourceSchema({ @@ -46,17 +40,13 @@ export const deriveStores = context => { // Derives the total enriched schema, made up of the saved schema and any // prop and user overrides const enrichedSchema = derived( - [schema, schemaOverrides, schemaMutations, columnWhitelist], - ([$schema, $schemaOverrides, $schemaMutations, $columnWhitelist]) => { + [schema, schemaOverrides, schemaMutations], + ([$schema, $schemaOverrides, $schemaMutations]) => { if (!$schema) { return null } let enrichedSchema = {} Object.keys($schema).forEach(field => { - // Apply whitelist if provided - if ($columnWhitelist?.length && !$columnWhitelist.includes(field)) { - return - } enrichedSchema[field] = { ...$schema[field], ...$schemaOverrides?.[field],