diff --git a/apps/frontend/src/lib/components/blocks/field-control/field-control.svelte b/apps/frontend/src/lib/components/blocks/field-control/field-control.svelte index 519aadb9c..34eedab83 100644 --- a/apps/frontend/src/lib/components/blocks/field-control/field-control.svelte +++ b/apps/frontend/src/lib/components/blocks/field-control/field-control.svelte @@ -12,8 +12,8 @@ import AttachmentControl from "./attachment-control.svelte" import JsonControl from "./json-control.svelte" import CheckboxControl from "./checkbox-control.svelte" - import RollupControl from "./rollup-control.svelte" import UrlControl from "./url-control.svelte" + import RollupField from "../field-value/rollup-field.svelte" export let readonly = false export let field: NoneSystemField @@ -36,7 +36,7 @@ string: StringControl, number: NumberControl, reference: ReferenceControl, - rollup: RollupControl, + rollup: RollupField, select: SelectControl, rating: RatingControl, email: EmailControl, diff --git a/apps/frontend/src/lib/components/blocks/field-control/rollup-control.svelte b/apps/frontend/src/lib/components/blocks/field-control/rollup-control.svelte deleted file mode 100644 index 027d1a858..000000000 --- a/apps/frontend/src/lib/components/blocks/field-control/rollup-control.svelte +++ /dev/null @@ -1,30 +0,0 @@ - - -
-{#if Array.isArray(value)} - {#each value as item} - {#if item !== null} - - {item} - - {:else} - - Unamed - - {/if} - {/each} -{:else} - - {value} - -{/if} diff --git a/apps/frontend/src/lib/components/blocks/field-value/rollup-field.svelte b/apps/frontend/src/lib/components/blocks/field-value/rollup-field.svelte index 7e38e853c..f419d3b70 100644 --- a/apps/frontend/src/lib/components/blocks/field-value/rollup-field.svelte +++ b/apps/frontend/src/lib/components/blocks/field-value/rollup-field.svelte @@ -2,18 +2,18 @@ import type { RollupField } from "@undb/table" import { isNumber } from "radash" - export let value: string | Array | undefined = undefined + export let value: string | Array export let field: RollupField $: fn = field.fn - {#if value !== null} + {#if !!value} {#if fn === "lookup" && Array.isArray(value)}
{#each value as item} - {#if item !== null} + {#if !!item} @@ -33,5 +33,11 @@ {value} {/if} + {:else} + + Unamed + {/if} diff --git a/apps/frontend/src/lib/components/blocks/record-detail/record-detail.svelte b/apps/frontend/src/lib/components/blocks/record-detail/record-detail.svelte index a9effb2c8..444db1c97 100644 --- a/apps/frontend/src/lib/components/blocks/record-detail/record-detail.svelte +++ b/apps/frontend/src/lib/components/blocks/record-detail/record-detail.svelte @@ -25,7 +25,7 @@ export let record: RecordDO beforeNavigate(({ cancel }) => { - if ($tainted) { + if (mutableFieldTainted) { if (!confirm("Are you sure you want to leave this page? You have unsaved changes that will be lost.")) { cancel() } @@ -93,7 +93,10 @@ const { form: formData, enhance, allErrors, tainted, reset, errors } = form - $: dirty = !!$tainted + $: mutableFields = fields.filter((f) => f.isMutable) + $: taintedKeys = Object.keys($tainted ?? {}) + $: mutableFieldTainted = taintedKeys.some((key) => mutableFields.some((f) => f.id.value === key)) + $: dirty = mutableFieldTainted $: disabled = !$tainted || !!$allErrors.length $: hiddenFields = $table.getOrderedHiddenFields() @@ -117,7 +120,7 @@ {#if field.required} * {/if} - {#if dirty} + {#if dirty && field.isMutable}