Fix for datasource reset on formblock. Added 'resetOn' to the manifest to trigger a clear when the configured field is cleared

This commit is contained in:
Dean 2023-09-05 11:40:52 +01:00
parent cf33680b1e
commit c6bd81ba21
4 changed files with 29 additions and 14 deletions

View File

@ -1246,6 +1246,16 @@ export const getFrontendStore = () => {
const settings = getComponentSettings(component._component)
const updatedSetting = settings.find(setting => setting.key === name)
const resetFields = settings.filter(
setting => name === setting.resetOn
)
resetFields?.forEach(setting => {
console.log(setting.key, component)
if (component[setting.key]) {
component[setting.key] = null
}
})
if (
updatedSetting?.type === "dataSource" ||
updatedSetting?.type === "table"

View File

@ -34,9 +34,10 @@
}
$: datasource = getDatasourceForProvider($currentAsset, componentInstance)
$: resourceId = datasource.resourceId || datasource.tableId
$: if (!isEqual(value, cachedValue)) {
cachedValue = value
$: if (!isEqual(value, cachedValue) || resourceId) {
cachedValue = cloneDeep(value)
schema = getSchema($currentAsset, datasource)
}

View File

@ -4745,7 +4745,8 @@
"dependsOn": {
"setting": "clickBehaviour",
"value": "details"
}
},
"resetOn": "dataSource"
},
{
"label": "Save button",
@ -5397,6 +5398,7 @@
"type": "fieldConfiguration",
"key": "fields",
"nested": true,
"resetOn": "dataSource",
"selectAllFields": true
},
{

View File

@ -211,17 +211,19 @@
{/if}
</BlockComponent>
{/if}
<BlockComponent type="fieldgroup" props={{ labelPosition }} order={1}>
{#each fields as field, idx}
{#if getComponentForField(field) && field.active}
<BlockComponent
type={getComponentForField(field)}
props={getPropsForField(field)}
order={idx}
/>
{/if}
{/each}
</BlockComponent>
{#key fields}
<BlockComponent type="fieldgroup" props={{ labelPosition }} order={1}>
{#each fields as field, idx}
{#if getComponentForField(field) && field.active}
<BlockComponent
type={getComponentForField(field)}
props={getPropsForField(field)}
order={idx}
/>
{/if}
{/each}
</BlockComponent>
{/key}
</BlockComponent>
</BlockComponent>
{:else}