Browse Source

fix: update link for new records

pull/6360/head
DarkPhoenix2704 1 year ago
parent
commit
733da2e3a5
  1. 12
      packages/nc-gui/components/virtual-cell/components/ListChildItems.vue
  2. 17
      packages/nc-gui/components/virtual-cell/components/ListItems.vue

12
packages/nc-gui/components/virtual-cell/components/ListChildItems.vue

@ -47,7 +47,7 @@ const {
displayValueProp,
} = useLTARStoreOrThrow()
const { isNew, state, removeLTARRef } = useSmartsheetRowStoreOrThrow()
const { isNew, state, removeLTARRef, addLTARRef } = useSmartsheetRowStoreOrThrow()
watch(
[vModel, isForm],
@ -67,6 +67,14 @@ const unlinkRow = async (row: Record<string, any>, id: number) => {
}
}
const linkRow = async (row: Record<string, any>, id: number) => {
if (isNew.value) {
await addLTARRef(row, injectedColumn?.value as ColumnType)
} else {
await link(row, {}, false, id)
}
}
const attachmentCol = computedInject(FieldsInj, (_fields) => {
return (relatedTableMeta.value.columns ?? []).filter((col) => isAttachment(col))[0]
})
@ -160,7 +168,7 @@ watch(expandedFormDlg, () => {
isChildrenListLinked[Number.parseInt(id)]
? unlinkRow(refRow, Number.parseInt(id))
: link(refRow, {}, false, Number.parseInt(id))
: linkRow(refRow, Number.parseInt(id))
}
"
/>

17
packages/nc-gui/components/virtual-cell/components/ListItems.vue

@ -41,7 +41,7 @@ const {
row,
} = useLTARStoreOrThrow()
const { addLTARRef, isNew } = useSmartsheetRowStoreOrThrow()
const { addLTARRef, isNew, removeLTARRef } = useSmartsheetRowStoreOrThrow()
const isPublic = inject(IsPublicInj, ref(false))
@ -56,12 +56,23 @@ const isFocused = ref(false)
const linkRow = async (row: Record<string, any>, id: number) => {
if (isNew.value) {
addLTARRef(row, injectedColumn?.value as ColumnType)
isChildrenExcludedListLinked.value[id] = true
saveRow!()
} else {
await link(row, {}, false, id)
}
}
const unlinkRow = async (row: Record<string, any>, id: number) => {
if (isNew.value) {
removeLTARRef(row, injectedColumn?.value as ColumnType)
isChildrenExcludedListLinked.value[id] = false
saveRow!()
} else {
await unlink(row, {}, false, id)
}
}
/** reload list on modal open */
watch(vModel, (nextVal, prevVal) => {
if (nextVal && !prevVal) {
@ -212,7 +223,7 @@ watch(expandedFormDlg, () => {
"
@click="
() => {
if (isChildrenExcludedListLinked[Number.parseInt(id)]) unlink(refRow, {}, false, Number.parseInt(id))
if (isChildrenExcludedListLinked[Number.parseInt(id)]) unlinkRow(refRow, Number.parseInt(id))
else linkRow(refRow, Number.parseInt(id))
}
"
@ -244,7 +255,7 @@ watch(expandedFormDlg, () => {
show-less-items
/>
</div>
<NcButton class="nc-close-btn" @click="vModel = false"> Close </NcButton>
<NcButton class="nc-close-btn ml-auto" @click="vModel = false"> Close </NcButton>
</div>
<Suspense>
<LazySmartsheetExpandedForm

Loading…
Cancel
Save