Commit 0a15d81 1 parent 8a3b349 commit 0a15d81 Copy full SHA for 0a15d81
File tree 1 file changed +25
-2
lines changed
apps/frontend/src/lib/components/blocks/field-value
1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change 2
2
import type { ReferenceField } from " @undb/table"
3
3
import ForeignRecordsPickerDropdown from " ../reference/foreign-records-picker-dropdown.svelte"
4
4
import { Button } from " $lib/components/ui/button"
5
+ import { writable } from " svelte/store"
5
6
6
7
export let value: string [] | null
7
8
export let field: ReferenceField
8
9
export let tableId: string
9
10
export let recordId: string | undefined
10
11
11
- $ : hasValue = Array .isArray (value ) && value ?.length > 0
12
+ $ : selected = writable <string []>(value )
13
+
14
+ let hasValue = Array .isArray (value ) && value .length > 0
15
+
16
+ $ : selected , (hasValue = Array .isArray (value ) && value .length > 0 )
17
+
18
+ $ : hasValueReactive = Array .isArray ($selected ) && $selected .length > 0
19
+ $ : if (hasValue && ! hasValueReactive ) {
20
+ hasValue = hasValueReactive
21
+ }
12
22
</script >
13
23
14
24
<div class =" flex gap-1 overflow-hidden" >
15
- <ForeignRecordsPickerDropdown shouldUpdate {field } {tableId } {recordId } bind:isSelected ={hasValue } let:builder >
25
+ <ForeignRecordsPickerDropdown
26
+ shouldUpdate
27
+ onOpenChange ={(open ) => {
28
+ if (! open ) {
29
+ hasValue = hasValueReactive
30
+ }
31
+ }}
32
+ {field }
33
+ {tableId }
34
+ {recordId }
35
+ bind:isSelected ={hasValue }
36
+ bind:selected
37
+ let:builder
38
+ >
16
39
{#if hasValue }
17
40
<Button size ="xs" variant ="link" class ="px-0" builders ={[builder ]} on:click ={(e ) => e .stopPropagation ()}>
18
41
{value ?.length } Linked Records
You can’t perform that action at this time.
0 commit comments