Skip to content

Commit

Permalink
fix: fix on value change
Browse files Browse the repository at this point in the history
  • Loading branch information
nichenqin committed Aug 10, 2024
1 parent 38fb9fa commit 07adf8e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
export let value: number = 0
export let field: RatingField
export let readonly = false
export let onValueChange: (value: number) => void
$: max = field.max
Expand Down Expand Up @@ -84,6 +85,7 @@
}
}}
on:change={() => {
onValueChange(value)
$updateCell.mutate({
tableId,
id: recordId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,15 @@
</div>

{#if (isSelected || isEditing) && hasValueReactive}
<ForeignRecordsPickerDropdown shouldUpdate {field} {tableId} {recordId} bind:selected isSelected={false}>
<ForeignRecordsPickerDropdown
{onValueChange}
shouldUpdate
{field}
{tableId}
{recordId}
bind:selected
isSelected={false}
>
<Button variant="link" class="px-2">+</Button>
</ForeignRecordsPickerDropdown>
{/if}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
onSuccess(data, variables, context) {
el?.blur()
gridViewStore.exitEditing()
onValueChange(value)
},
onError(error: Error) {
toast.error(error.message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
export let field: ReferenceField
$: foreignTableId = field.foreignTableId
export let selected = writable<string[]>()
export let onValueChange = (value: string[]) => {}
export let onOpenChange: (open: boolean) => void = () => {}
const foreignTableStore = new GetForeignTableStore()
Expand Down Expand Up @@ -55,6 +55,7 @@
{recordId}
{foreignTable}
bind:selected
{onValueChange}
/>
{/if}
</Popover.Content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
export let tableId: string
export let recordId: string | undefined = undefined
export let field: ReferenceField
export let onValueChange = (value: string[]) => {}
let linkAfterCreate = true
const perPage = writable(20)
Expand Down Expand Up @@ -104,6 +104,7 @@
} else {
$selected = unique([...($selected ?? []), id])
}
onValueChange($selected)
if (shouldUpdate) {
if (recordId) {
await $updateCell.mutateAsync({
Expand Down

0 comments on commit 07adf8e

Please sign in to comment.