1
0
Fork 0
mirror of synced 2024-07-03 13:30:46 +12:00

Add button to fieldgroups to automatically update from schema

This commit is contained in:
Andrew Kingston 2021-02-02 17:26:14 +00:00
parent 3d5876f8bd
commit ed2ada720e

View file

@ -1,7 +1,10 @@
<script>
import { get } from "lodash"
import { isEmpty } from "lodash/fp"
import { Button } from "@budibase/bbui"
import { currentAsset } from "builderStore"
import { findClosestMatchingComponent } from "builderStore/storeUtils"
import { makeSchemaFormComponents } from "builderStore/store/screenTemplates/utils/commonComponents"
import PropertyControl from "./PropertyControls/PropertyControl.svelte"
import Input from "./PropertyControls/Input.svelte"
import LayoutSelect from "./PropertyControls/LayoutSelect.svelte"
@ -94,6 +97,17 @@
const onInstanceNameChange = name => {
onChange("_instanceName", name)
}
const resetFormFields = () => {
const form = findClosestMatchingComponent(
$currentAsset.props,
componentInstance._id,
component => component._component.endsWith("/form")
)
const tableId = form?.datasource?.tableId
const fields = makeSchemaFormComponents(tableId).map(field => field.json())
onChange("_children", fields)
}
</script>
<div class="settings-view-container">
@ -138,6 +152,10 @@
This component doesn't have any additional settings.
</div>
{/if}
{#if componentDefinition?.component?.endsWith('/fieldgroup')}
<Button secondary wide on:click={resetFormFields}>Reset Fields</Button>
{/if}
</div>
<style>