From be63b29fc40a7bb216ad2c9fedeaf9b497427273 Mon Sep 17 00:00:00 2001 From: nichenqin Date: Sat, 28 Sep 2024 10:36:18 +0800 Subject: [PATCH] fix: fix record store --- .../bulk-update-records-button.svelte | 4 +++- .../bulk-update-records-preview.svelte | 2 -- .../bulk-update-records/bulk-update-records.svelte | 4 +++- .../blocks/field-control/field-control.svelte | 4 +++- .../blocks/field-control/reference-control.svelte | 6 ++++-- .../blocks/field-value/field-value.svelte | 14 +++++++++++++- .../blocks/field-value/reference-field.svelte | 4 +++- .../blocks/gallery-view/gallery-view-card.svelte | 1 + .../blocks/gallery-view/gallery-view.svelte | 2 +- .../grid-view/editable-cell/reference-cell.svelte | 5 ++++- .../blocks/grid-view/grid-view-data-table.svelte | 3 ++- .../grid-view/selected-records-button.svelte | 2 ++ .../blocks/kanban-view/kanban-card.svelte | 6 ++++-- .../blocks/kanban-view/kanban-view.svelte | 2 +- .../record-detail/record-detail-sheet.svelte | 3 ++- .../blocks/record-detail/record-detail.svelte | 10 ++++++---- .../reference/foreign-record-detail-button.svelte | 4 +++- .../foreign-records-picker-dropdown.svelte | 3 +++ .../blocks/reference/foreign-records-picker.svelte | 12 ++++++++---- .../blocks/table-tools/table-tools.svelte | 4 +++- 20 files changed, 69 insertions(+), 26 deletions(-) diff --git a/apps/frontend/src/lib/components/blocks/bulk-update-records/bulk-update-records-button.svelte b/apps/frontend/src/lib/components/blocks/bulk-update-records/bulk-update-records-button.svelte index e7db0fb84..21635fdf5 100644 --- a/apps/frontend/src/lib/components/blocks/bulk-update-records/bulk-update-records-button.svelte +++ b/apps/frontend/src/lib/components/blocks/bulk-update-records/bulk-update-records-button.svelte @@ -4,7 +4,9 @@ import { PencilIcon } from "lucide-svelte" import BulkUpdateRecords from "./bulk-update-records.svelte" import { hasPermission } from "$lib/store/space-member.store" + import { type Writable } from "svelte/store" + export let r: Writable let open = false @@ -21,7 +23,7 @@ Bulk Update Records - (open = false)} /> + (open = false)} /> {/if} diff --git a/apps/frontend/src/lib/components/blocks/bulk-update-records/bulk-update-records-preview.svelte b/apps/frontend/src/lib/components/blocks/bulk-update-records/bulk-update-records-preview.svelte index 885e08f2c..abf62f620 100644 --- a/apps/frontend/src/lib/components/blocks/bulk-update-records/bulk-update-records-preview.svelte +++ b/apps/frontend/src/lib/components/blocks/bulk-update-records/bulk-update-records-preview.svelte @@ -5,8 +5,6 @@ import * as Dialog from "$lib/components/ui/dialog" import { Button } from "$lib/components/ui/button" import { FullscreenIcon } from "lucide-svelte" - import { createQuery } from "@tanstack/svelte-query" - import { trpc } from "$lib/trpc/client" import { r } from "$lib/store/records.store" const table = getTable() diff --git a/apps/frontend/src/lib/components/blocks/bulk-update-records/bulk-update-records.svelte b/apps/frontend/src/lib/components/blocks/bulk-update-records/bulk-update-records.svelte index 87b8deeaf..5d08fa3bf 100644 --- a/apps/frontend/src/lib/components/blocks/bulk-update-records/bulk-update-records.svelte +++ b/apps/frontend/src/lib/components/blocks/bulk-update-records/bulk-update-records.svelte @@ -24,12 +24,13 @@ import type { IBulkUpdateRecordsCommandOutput } from "@undb/commands" import * as AlertDialog from "$lib/components/ui/alert-dialog" import FiltersEditor from "../filters-editor/filters-editor.svelte" - import { writable } from "svelte/store" + import { writable, type Writable } from "svelte/store" import autoAnimate from "@formkit/auto-animate" const table = getTable() const mutableFields = $table.schema.mutableFields const schema = $table.schema.getMutableSchema() + export let r: Writable let open = false @@ -163,6 +164,7 @@ {...attrs} bind:value={$formData[field.id.value]} {field} + {r} tableId={$table.id.value} class={cn($errors[field.id.value] && "border-red-500 focus-visible:ring-0")} /> 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 5dead65ac..94b34cb07 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 @@ -19,13 +19,14 @@ import ButtonControl from "./button-control.svelte" import DurationControl from "./duration-control.svelte" import PercentageControl from "./percentage-control.svelte" + import { type Writable } from "svelte/store" export let readonly = false export let field: NoneSystemField export let tableId: string export let recordId: string | undefined export let record: RecordDO | undefined - + export let r: Writable export let value: any export let displayValue: any @@ -71,4 +72,5 @@ {tableId} {recordId} {record} + {r} /> diff --git a/apps/frontend/src/lib/components/blocks/field-control/reference-control.svelte b/apps/frontend/src/lib/components/blocks/field-control/reference-control.svelte index 298d3efb7..1580d745a 100644 --- a/apps/frontend/src/lib/components/blocks/field-control/reference-control.svelte +++ b/apps/frontend/src/lib/components/blocks/field-control/reference-control.svelte @@ -1,7 +1,7 @@ - + diff --git a/apps/frontend/src/lib/components/blocks/field-value/reference-field.svelte b/apps/frontend/src/lib/components/blocks/field-value/reference-field.svelte index 2f241a0c9..62ed1a315 100644 --- a/apps/frontend/src/lib/components/blocks/field-value/reference-field.svelte +++ b/apps/frontend/src/lib/components/blocks/field-value/reference-field.svelte @@ -2,11 +2,12 @@ import type { ReferenceField } from "@undb/table" import ForeignRecordsPickerDropdown from "../reference/foreign-records-picker-dropdown.svelte" import { Button } from "$lib/components/ui/button" - import { writable } from "svelte/store" + import { writable, type Writable } from "svelte/store" import { onMount } from "svelte" export let value: string[] | null export let field: ReferenceField + export let r: Writable export let tableId: string export let recordId: string | undefined @@ -37,6 +38,7 @@ {recordId} bind:isSelected={hasValue} bind:selected + {r} let:builder > {#if hasValueReactive} diff --git a/apps/frontend/src/lib/components/blocks/gallery-view/gallery-view-card.svelte b/apps/frontend/src/lib/components/blocks/gallery-view/gallery-view-card.svelte index 4a1ab6ef6..d263badc2 100644 --- a/apps/frontend/src/lib/components/blocks/gallery-view/gallery-view-card.svelte +++ b/apps/frontend/src/lib/components/blocks/gallery-view/gallery-view-card.svelte @@ -66,6 +66,7 @@ {#each fields.filter((f) => f.id.value !== fieldId) as field}
- +
{#if !field} diff --git a/apps/frontend/src/lib/components/blocks/grid-view/editable-cell/reference-cell.svelte b/apps/frontend/src/lib/components/blocks/grid-view/editable-cell/reference-cell.svelte index 9920d55da..1dd2aa1d6 100644 --- a/apps/frontend/src/lib/components/blocks/grid-view/editable-cell/reference-cell.svelte +++ b/apps/frontend/src/lib/components/blocks/grid-view/editable-cell/reference-cell.svelte @@ -2,7 +2,7 @@ import type { ReferenceField } from "@undb/table" import ForeignRecordsPickerDropdown from "../../reference/foreign-records-picker-dropdown.svelte" import { Button } from "$lib/components/ui/button" - import { writable } from "svelte/store" + import { writable, type Writable } from "svelte/store" export let tableId: string export let field: ReferenceField @@ -12,6 +12,7 @@ export let isSelected: boolean export let recordId: string export let onValueChange = (value: string[]) => {} + export let r: Writable $: selected = writable(value) @@ -38,6 +39,7 @@ {field} {tableId} {recordId} + {r} bind:isSelected={hasValue} bind:selected let:builder @@ -59,6 +61,7 @@ {field} {tableId} {recordId} + {r} bind:selected isSelected={false} let:builder diff --git a/apps/frontend/src/lib/components/blocks/grid-view/grid-view-data-table.svelte b/apps/frontend/src/lib/components/blocks/grid-view/grid-view-data-table.svelte index ad85e159c..48ff22ee7 100644 --- a/apps/frontend/src/lib/components/blocks/grid-view/grid-view-data-table.svelte +++ b/apps/frontend/src/lib/components/blocks/grid-view/grid-view-data-table.svelte @@ -122,6 +122,7 @@ const record = $store.records.get(item.row.original.id) const displayValue = record?.displayValues?.toJSON()?.[field.id.value] return createRender(GridViewCell, { + r, index, value: item.value, field, @@ -178,7 +179,7 @@
{#if !readonly} - + {#if selectedRecordIds.length} {/if} diff --git a/apps/frontend/src/lib/components/blocks/grid-view/selected-records-button.svelte b/apps/frontend/src/lib/components/blocks/grid-view/selected-records-button.svelte index ff1289132..5e178bc09 100644 --- a/apps/frontend/src/lib/components/blocks/grid-view/selected-records-button.svelte +++ b/apps/frontend/src/lib/components/blocks/grid-view/selected-records-button.svelte @@ -11,6 +11,7 @@ import BulkUpdateRecords from "../bulk-update-records/bulk-update-records.svelte" import { ID_TYPE } from "@undb/table" import { cn } from "$lib/utils" + import { r } from "$lib/store/records.store" const table = getTable() @@ -115,6 +116,7 @@ conjunction: "and", children: [{ field: ID_TYPE, op: "in", value: ids }], }} + {r} /> diff --git a/apps/frontend/src/lib/components/blocks/kanban-view/kanban-card.svelte b/apps/frontend/src/lib/components/blocks/kanban-view/kanban-card.svelte index 4c9b5b52d..3c7a22d3c 100644 --- a/apps/frontend/src/lib/components/blocks/kanban-view/kanban-card.svelte +++ b/apps/frontend/src/lib/components/blocks/kanban-view/kanban-card.svelte @@ -24,8 +24,9 @@