mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
39 lines
1.1 KiB
<script lang="ts" setup> |
|
import type { Row } from '~/composables' |
|
import { useProvideSmartsheetRowStore, useSmartsheetStoreOrThrow } from '#imports' |
|
import { ReloadRowDataHookInj, ReloadViewDataHookInj } from '~/context' |
|
|
|
interface Props { |
|
row: Row |
|
} |
|
|
|
const props = defineProps<Props>() |
|
const currentRow = toRef(props, 'row') |
|
|
|
const { meta } = useSmartsheetStoreOrThrow() |
|
const { isNew, state, syncLTARRefs, loadRow } = useProvideSmartsheetRowStore(meta, currentRow) |
|
|
|
// on changing isNew(new record insert) status sync LTAR cell values |
|
watch(isNew, async (nextVal, prevVal) => { |
|
if (prevVal && !nextVal) { |
|
await syncLTARRefs(currentRow.value.row) |
|
// update row values without invoking api |
|
currentRow.value.row = { ...currentRow.value.row, ...state.value } |
|
currentRow.value.oldRow = { ...currentRow.value.row, ...state.value } |
|
} |
|
}) |
|
|
|
// override reload trigger and use it to reload row |
|
const reloadHook = createEventHook() |
|
|
|
reloadHook.on(() => { |
|
if (isNew.value) return |
|
loadRow() |
|
}) |
|
|
|
provide(ReloadRowDataHookInj, reloadHook) |
|
</script> |
|
|
|
<template> |
|
<slot :state="state" /> |
|
</template>
|
|
|