Merge pull request #11665 from Budibase/form-block-fix
Fix for datasource reset on formblock. Added 'resetOn' behaviour to the component manifest
This commit is contained in:
commit
40611358c5
|
@ -1246,6 +1246,13 @@ export const getFrontendStore = () => {
|
||||||
const settings = getComponentSettings(component._component)
|
const settings = getComponentSettings(component._component)
|
||||||
const updatedSetting = settings.find(setting => setting.key === name)
|
const updatedSetting = settings.find(setting => setting.key === name)
|
||||||
|
|
||||||
|
const resetFields = settings.filter(
|
||||||
|
setting => name === setting.resetOn
|
||||||
|
)
|
||||||
|
resetFields?.forEach(setting => {
|
||||||
|
component[setting.key] = null
|
||||||
|
})
|
||||||
|
|
||||||
if (
|
if (
|
||||||
updatedSetting?.type === "dataSource" ||
|
updatedSetting?.type === "dataSource" ||
|
||||||
updatedSetting?.type === "table"
|
updatedSetting?.type === "table"
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
let fieldList
|
let fieldList
|
||||||
let schema
|
let schema
|
||||||
let cachedValue
|
let cachedValue
|
||||||
|
let options
|
||||||
|
let sanitisedValue
|
||||||
|
let unconfigured
|
||||||
|
|
||||||
$: bindings = getBindableProperties($selectedScreen, componentInstance._id)
|
$: bindings = getBindableProperties($selectedScreen, componentInstance._id)
|
||||||
$: actionType = componentInstance.actionType
|
$: actionType = componentInstance.actionType
|
||||||
|
@ -34,16 +37,24 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$: datasource = getDatasourceForProvider($currentAsset, componentInstance)
|
$: datasource = getDatasourceForProvider($currentAsset, componentInstance)
|
||||||
|
$: resourceId = datasource.resourceId || datasource.tableId
|
||||||
|
|
||||||
$: if (!isEqual(value, cachedValue)) {
|
$: if (!isEqual(value, cachedValue)) {
|
||||||
cachedValue = value
|
cachedValue = cloneDeep(value)
|
||||||
schema = getSchema($currentAsset, datasource)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$: options = Object.keys(schema || {})
|
const updateState = value => {
|
||||||
$: sanitisedValue = getValidColumns(convertOldFieldFormat(value), options)
|
schema = getSchema($currentAsset, datasource)
|
||||||
$: updateSanitsedFields(sanitisedValue)
|
options = Object.keys(schema || {})
|
||||||
$: unconfigured = buildUnconfiguredOptions(schema, sanitisedFields)
|
sanitisedValue = getValidColumns(convertOldFieldFormat(value), options)
|
||||||
|
updateSanitsedFields(sanitisedValue)
|
||||||
|
unconfigured = buildUnconfiguredOptions(schema, sanitisedFields)
|
||||||
|
fieldList = [...sanitisedFields, ...unconfigured]
|
||||||
|
.map(buildSudoInstance)
|
||||||
|
.filter(x => x != null)
|
||||||
|
}
|
||||||
|
|
||||||
|
$: updateState(cachedValue, resourceId)
|
||||||
|
|
||||||
// Builds unused ones only
|
// Builds unused ones only
|
||||||
const buildUnconfiguredOptions = (schema, selected) => {
|
const buildUnconfiguredOptions = (schema, selected) => {
|
||||||
|
@ -97,7 +108,6 @@
|
||||||
if (instance._component) {
|
if (instance._component) {
|
||||||
return instance
|
return instance
|
||||||
}
|
}
|
||||||
|
|
||||||
const type = getComponentForField(instance.field, schema)
|
const type = getComponentForField(instance.field, schema)
|
||||||
if (!type) {
|
if (!type) {
|
||||||
return null
|
return null
|
||||||
|
@ -118,12 +128,6 @@
|
||||||
return { ...instance, ...pseudoComponentInstance }
|
return { ...instance, ...pseudoComponentInstance }
|
||||||
}
|
}
|
||||||
|
|
||||||
$: if (sanitisedFields) {
|
|
||||||
fieldList = [...sanitisedFields, ...unconfigured]
|
|
||||||
.map(buildSudoInstance)
|
|
||||||
.filter(x => x != null)
|
|
||||||
}
|
|
||||||
|
|
||||||
const processItemUpdate = e => {
|
const processItemUpdate = e => {
|
||||||
const updatedField = e.detail
|
const updatedField = e.detail
|
||||||
const parentFieldsUpdated = fieldList ? cloneDeep(fieldList) : []
|
const parentFieldsUpdated = fieldList ? cloneDeep(fieldList) : []
|
||||||
|
|
|
@ -4745,7 +4745,8 @@
|
||||||
"dependsOn": {
|
"dependsOn": {
|
||||||
"setting": "clickBehaviour",
|
"setting": "clickBehaviour",
|
||||||
"value": "details"
|
"value": "details"
|
||||||
}
|
},
|
||||||
|
"resetOn": "dataSource"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Save button",
|
"label": "Save button",
|
||||||
|
@ -5397,6 +5398,7 @@
|
||||||
"type": "fieldConfiguration",
|
"type": "fieldConfiguration",
|
||||||
"key": "fields",
|
"key": "fields",
|
||||||
"nested": true,
|
"nested": true,
|
||||||
|
"resetOn": "dataSource",
|
||||||
"selectAllFields": true
|
"selectAllFields": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -275,7 +275,7 @@
|
||||||
dataSource,
|
dataSource,
|
||||||
showSaveButton: true,
|
showSaveButton: true,
|
||||||
showDeleteButton: false,
|
showDeleteButton: false,
|
||||||
saveButtonLabel: sidePanelSaveLabel,
|
saveButtonLabel: sidePanelSaveLabel || "Save", //always show
|
||||||
actionType: "Create",
|
actionType: "Create",
|
||||||
fields: sidePanelFields || normalFields,
|
fields: sidePanelFields || normalFields,
|
||||||
title: "Create Row",
|
title: "Create Row",
|
||||||
|
|
|
@ -211,17 +211,19 @@
|
||||||
{/if}
|
{/if}
|
||||||
</BlockComponent>
|
</BlockComponent>
|
||||||
{/if}
|
{/if}
|
||||||
<BlockComponent type="fieldgroup" props={{ labelPosition }} order={1}>
|
{#key fields}
|
||||||
{#each fields as field, idx}
|
<BlockComponent type="fieldgroup" props={{ labelPosition }} order={1}>
|
||||||
{#if getComponentForField(field) && field.active}
|
{#each fields as field, idx}
|
||||||
<BlockComponent
|
{#if getComponentForField(field) && field.active}
|
||||||
type={getComponentForField(field)}
|
<BlockComponent
|
||||||
props={getPropsForField(field)}
|
type={getComponentForField(field)}
|
||||||
order={idx}
|
props={getPropsForField(field)}
|
||||||
/>
|
order={idx}
|
||||||
{/if}
|
/>
|
||||||
{/each}
|
{/if}
|
||||||
</BlockComponent>
|
{/each}
|
||||||
|
</BlockComponent>
|
||||||
|
{/key}
|
||||||
</BlockComponent>
|
</BlockComponent>
|
||||||
</BlockComponent>
|
</BlockComponent>
|
||||||
{:else}
|
{:else}
|
||||||
|
|
Loading…
Reference in New Issue