Update how grid blocks handle visible columns to ensure conditions work on hidden columns

This commit is contained in:
Andrew Kingston 2024-07-17 12:45:31 +01:00
parent 7faa6188c4
commit 94fec5b62b
No known key found for this signature in database
4 changed files with 5 additions and 20 deletions

View File

@ -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}

View File

@ -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,

View File

@ -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,

View File

@ -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],