From 2fee785b73f335eb26dbf1f10b8af67efa2a73d2 Mon Sep 17 00:00:00 2001 From: nichenqin Date: Wed, 21 Aug 2024 22:28:21 +0800 Subject: [PATCH] feat: allow required form field with default value hidden --- .../blocks/forms/form-field-options.svelte | 19 +++++++++++++------ .../blocks/forms/form-fields-editor.svelte | 19 +++++++++++++------ .../src/modules/forms/form/form-field.vo.ts | 11 +++++++++++ 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/apps/frontend/src/lib/components/blocks/forms/form-field-options.svelte b/apps/frontend/src/lib/components/blocks/forms/form-field-options.svelte index 59bf6dcd4..a1fee25e6 100644 --- a/apps/frontend/src/lib/components/blocks/forms/form-field-options.svelte +++ b/apps/frontend/src/lib/components/blocks/forms/form-field-options.svelte @@ -6,6 +6,7 @@ type MaybeConditionGroup, toMaybeConditionGroup, parseValidViewFilter, + formOption, } from "@undb/table" import { Switch } from "$lib/components/ui/switch" import { Label } from "$lib/components/ui/label" @@ -85,18 +86,24 @@
@@ -106,7 +113,7 @@ type="checkbox" class="hidden" bind:checked={formField.hidden} - disabled={formField.required} + disabled={formField.getRequired(field) && !formField.defaultValue} on:click={setForm} /> {#if formField.hidden} diff --git a/apps/frontend/src/lib/components/blocks/forms/form-fields-editor.svelte b/apps/frontend/src/lib/components/blocks/forms/form-fields-editor.svelte index e5622ac97..c2bad2d0f 100644 --- a/apps/frontend/src/lib/components/blocks/forms/form-fields-editor.svelte +++ b/apps/frontend/src/lib/components/blocks/forms/form-fields-editor.svelte @@ -121,7 +121,8 @@ {#each filteredFields as formField (formField.fieldId)} {@const field = schema.get(formField.fieldId)} {#if field} - {@const disabled = formField.getRequired(field)} + {@const required = formField.getRequired(field)} + {@const hiddenDisabled = required && !formField.defaultValue}