Skip to content

Commit a922cf7

Browse files
committed
fix: fix rollup control display
1 parent 093ee26 commit a922cf7

File tree

4 files changed

+17
-38
lines changed

4 files changed

+17
-38
lines changed

apps/frontend/src/lib/components/blocks/field-control/field-control.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
import AttachmentControl from "./attachment-control.svelte"
1313
import JsonControl from "./json-control.svelte"
1414
import CheckboxControl from "./checkbox-control.svelte"
15-
import RollupControl from "./rollup-control.svelte"
1615
import UrlControl from "./url-control.svelte"
16+
import RollupField from "../field-value/rollup-field.svelte"
1717
1818
export let readonly = false
1919
export let field: NoneSystemField
@@ -36,7 +36,7 @@
3636
string: StringControl,
3737
number: NumberControl,
3838
reference: ReferenceControl,
39-
rollup: RollupControl,
39+
rollup: RollupField,
4040
select: SelectControl,
4141
rating: RatingControl,
4242
email: EmailControl,

apps/frontend/src/lib/components/blocks/field-control/rollup-control.svelte

Lines changed: 0 additions & 30 deletions
This file was deleted.

apps/frontend/src/lib/components/blocks/field-value/rollup-field.svelte

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
import type { RollupField } from "@undb/table"
33
import { isNumber } from "radash"
44
5-
export let value: string | Array<string | null> | undefined = undefined
5+
export let value: string | Array<string | null>
66
export let field: RollupField
77
88
$: fn = field.fn
99
</script>
1010

1111
<span class={$$restProps.class}>
12-
{#if value !== null}
12+
{#if !!value}
1313
{#if fn === "lookup" && Array.isArray(value)}
1414
<div class="flex overflow-hidden">
1515
{#each value as item}
16-
{#if item !== null}
16+
{#if !!item}
1717
<span
1818
class="me-2 rounded bg-gray-200 px-1 py-0.5 text-xs font-medium text-gray-800 dark:bg-gray-700 dark:text-gray-300"
1919
>
@@ -33,5 +33,11 @@
3333
{value}
3434
</span>
3535
{/if}
36+
{:else}
37+
<span
38+
class="text-muted-foreground me-2 rounded bg-gray-200 px-1 py-0.5 text-xs font-medium dark:bg-gray-700 dark:text-gray-300"
39+
>
40+
Unamed
41+
</span>
3642
{/if}
3743
</span>

apps/frontend/src/lib/components/blocks/record-detail/record-detail.svelte

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
export let record: RecordDO
2626
2727
beforeNavigate(({ cancel }) => {
28-
if ($tainted) {
28+
if (mutableFieldTainted) {
2929
if (!confirm("Are you sure you want to leave this page? You have unsaved changes that will be lost.")) {
3030
cancel()
3131
}
@@ -93,7 +93,10 @@
9393
9494
const { form: formData, enhance, allErrors, tainted, reset, errors } = form
9595
96-
$: dirty = !!$tainted
96+
$: mutableFields = fields.filter((f) => f.isMutable)
97+
$: taintedKeys = Object.keys($tainted ?? {})
98+
$: mutableFieldTainted = taintedKeys.some((key) => mutableFields.some((f) => f.id.value === key))
99+
$: dirty = mutableFieldTainted
97100
$: disabled = !$tainted || !!$allErrors.length
98101
99102
$: hiddenFields = $table.getOrderedHiddenFields()
@@ -117,7 +120,7 @@
117120
{#if field.required}
118121
<span class="text-red-500">*</span>
119122
{/if}
120-
{#if dirty}
123+
{#if dirty && field.isMutable}
121124
<span
122125
class="me-2 rounded bg-green-100 px-2.5 py-0.5 text-xs font-medium text-green-800 dark:bg-green-900 dark:text-green-300"
123126
>

0 commit comments

Comments
 (0)