Reactivity fix for the editableColumn and an update to the onChange behaviour for the formula value to ensure updates are detected

This commit is contained in:
Dean 2023-02-09 16:36:02 +00:00
parent 8eeb766976
commit 4c013df676
1 changed files with 18 additions and 9 deletions

View File

@ -75,7 +75,8 @@
editableColumn.constraints.presence = { allowEmpty: false } editableColumn.constraints.presence = { allowEmpty: false }
} }
$: if (field && !savingColumn) { const initialiseField = (field, savingColumn) => {
if (field && !savingColumn) {
editableColumn = cloneDeep(field) editableColumn = cloneDeep(field)
originalName = editableColumn.name ? editableColumn.name + "" : null originalName = editableColumn.name ? editableColumn.name + "" : null
linkEditDisabled = originalName != null linkEditDisabled = originalName != null
@ -84,6 +85,9 @@
$tables.selected.primaryDisplay == null || $tables.selected.primaryDisplay == null ||
$tables.selected.primaryDisplay === editableColumn.name $tables.selected.primaryDisplay === editableColumn.name
} }
}
$: initialiseField(field, savingColumn)
$: checkConstraints(editableColumn) $: checkConstraints(editableColumn)
$: required = !!editableColumn?.constraints?.presence || primaryDisplay $: required = !!editableColumn?.constraints?.presence || primaryDisplay
@ -583,7 +587,12 @@
title="Formula" title="Formula"
label="Formula" label="Formula"
value={editableColumn.formula} value={editableColumn.formula}
on:change={e => (editableColumn.formula = e.detail)} on:change={e => {
editableColumn = {
...editableColumn,
formula: e.detail,
}
}}
bindings={getBindings({ table })} bindings={getBindings({ table })}
allowJS allowJS
/> />