Add confirmation dialog before resetting form fields manually

This commit is contained in:
Andrew Kingston 2021-02-03 10:05:49 +00:00
parent 9ff40cc288
commit 231eec81ab
1 changed files with 11 additions and 1 deletions

View File

@ -2,6 +2,7 @@
import { get } from "lodash" import { get } from "lodash"
import { isEmpty } from "lodash/fp" import { isEmpty } from "lodash/fp"
import { Button } from "@budibase/bbui" import { Button } from "@budibase/bbui"
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
import { currentAsset } from "builderStore" import { currentAsset } from "builderStore"
import { findClosestMatchingComponent } from "builderStore/storeUtils" import { findClosestMatchingComponent } from "builderStore/storeUtils"
import { makeSchemaFormComponents } from "builderStore/store/screenTemplates/utils/commonComponents" import { makeSchemaFormComponents } from "builderStore/store/screenTemplates/utils/commonComponents"
@ -50,6 +51,7 @@
"layoutId", "layoutId",
"routing.roleId", "routing.roleId",
] ]
let confirmResetFieldsDialog
$: settings = componentDefinition?.settings ?? [] $: settings = componentDefinition?.settings ?? []
$: isLayout = assetInstance && assetInstance.favicon $: isLayout = assetInstance && assetInstance.favicon
@ -154,9 +156,17 @@
{/if} {/if}
{#if componentDefinition?.component?.endsWith('/fieldgroup')} {#if componentDefinition?.component?.endsWith('/fieldgroup')}
<Button secondary wide on:click={resetFormFields}>Reset Fields</Button> <Button secondary wide on:click={() => confirmResetFieldsDialog?.show()}>
Reset Fields
</Button>
{/if} {/if}
</div> </div>
<ConfirmDialog
bind:this={confirmResetFieldsDialog}
body={`All components inside this group will be deleted and replaced with fields to match the schema. Are you sure you want to reset this Field Group?`}
okText="Reset"
onOk={resetFormFields}
title="Confirm Reset Fields" />
<style> <style>
.settings-view-container { .settings-view-container {