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 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 => {
console.log(setting.key, component)
if (component[setting.key]) {
component[setting.key] = null
}
})
if ( if (
updatedSetting?.type === "dataSource" || updatedSetting?.type === "dataSource" ||
updatedSetting?.type === "table" updatedSetting?.type === "table"

View File

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

View File

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

View File

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