diff --git a/apps/frontend/src/lib/components/blocks/field-options/button-field-option.svelte b/apps/frontend/src/lib/components/blocks/field-options/button-field-option.svelte index bcbdee28f..1e372718b 100644 --- a/apps/frontend/src/lib/components/blocks/field-options/button-field-option.svelte +++ b/apps/frontend/src/lib/components/blocks/field-options/button-field-option.svelte @@ -17,7 +17,7 @@ import { Button } from "$lib/components/ui/button" import Separator from "$lib/components/ui/separator/separator.svelte" import { writable } from "svelte/store" - import type { ZodUndefined } from "@undb/zod" + import { Switch } from "$lib/components/ui/switch" import FiltersEditor from "../filters-editor/filters-editor.svelte" import { onMount, tick } from "svelte" @@ -40,15 +40,18 @@ confirm: true, }, } - const value = writable | undefined>() + const value = writable | undefined>() $: validValue = $table && $value ? parseValidViewFilter($table.schema, $value) : undefined $: if (validValue) { option.disabled = validValue } + let disabledWhen = false + onMount(() => { if (option.disabled) { value.set(toMaybeConditionGroup(option.disabled)) + disabledWhen = true } }) @@ -63,14 +66,19 @@ -
- - visibleFields.some((f) => f.id.value === field.id) && getIsFilterableFieldType(field.type)} - > -
+ + {#if disabledWhen} +
+ visibleFields.some((f) => f.id.value === field.id) && getIsFilterableFieldType(field.type)} + > +
+ {/if}

Update Value when Click Button

diff --git a/apps/frontend/src/lib/components/blocks/field-options/field-options.svelte b/apps/frontend/src/lib/components/blocks/field-options/field-options.svelte index c9dc08376..f11882c66 100644 --- a/apps/frontend/src/lib/components/blocks/field-options/field-options.svelte +++ b/apps/frontend/src/lib/components/blocks/field-options/field-options.svelte @@ -31,7 +31,6 @@ export let disabled = false export let type: NoneSystemFieldType - const map: Record = { string: StringFieldOption, longText: LongTextFieldOption, @@ -67,4 +66,5 @@ bind:option {isNew} {field} + {...$$restProps} /> diff --git a/apps/frontend/src/lib/components/blocks/update-field/update-field.svelte b/apps/frontend/src/lib/components/blocks/update-field/update-field.svelte index b4ece9396..c7f407735 100644 --- a/apps/frontend/src/lib/components/blocks/update-field/update-field.svelte +++ b/apps/frontend/src/lib/components/blocks/update-field/update-field.svelte @@ -113,6 +113,7 @@ bind:constraint={$formData.constraint} bind:display={$formData.display} bind:defaultValue={$formData.defaultValue} + {...attrs} /> diff --git a/packages/table/src/modules/schema/fields/variants/button-field/button-field.vo.ts b/packages/table/src/modules/schema/fields/variants/button-field/button-field.vo.ts index 8e9c5d4cf..ff7fa49e6 100644 --- a/packages/table/src/modules/schema/fields/variants/button-field/button-field.vo.ts +++ b/packages/table/src/modules/schema/fields/variants/button-field/button-field.vo.ts @@ -24,7 +24,7 @@ export const buttonFieldUpdateAction = z.object({ confirm: z.boolean().optional(), }) -const buttonCondition = z.undefined() +const buttonCondition = z.any() export const buttonDisabled = createConditionGroup(buttonCondition, buttonCondition) export type IButtonDisabled = z.infer