Browse Source

fix: exclude state links from excluded list

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/6360/head
mertmit 1 year ago committed by DarkPhoenix2704
parent
commit
a996934807
  1. 6
      packages/nc-gui/components/virtual-cell/components/ListItems.vue
  2. 22
      packages/nc-gui/composables/useLTARStore.ts

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

@ -41,7 +41,7 @@ const {
row, row,
} = useLTARStoreOrThrow() } = useLTARStoreOrThrow()
const { addLTARRef, isNew, removeLTARRef } = useSmartsheetRowStoreOrThrow() const { addLTARRef, isNew, removeLTARRef, state: rowState } = useSmartsheetRowStoreOrThrow()
const isPublic = inject(IsPublicInj, ref(false)) const isPublic = inject(IsPublicInj, ref(false))
@ -82,7 +82,7 @@ watch(vModel, (nextVal, prevVal) => {
if (!isForm.value) { if (!isForm.value) {
loadChildrenList() loadChildrenList()
} }
loadChildrenExcludedList() loadChildrenExcludedList(rowState.value)
selectedRowIndex.value = 0 selectedRowIndex.value = 0
} }
}) })
@ -140,7 +140,7 @@ const relation = computed(() => {
}) })
watch(expandedFormDlg, () => { watch(expandedFormDlg, () => {
loadChildrenExcludedList() loadChildrenExcludedList(rowState.value)
}) })
</script> </script>

22
packages/nc-gui/composables/useLTARStore.ts

@ -120,7 +120,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
return (meta.value?.columns?.find((c: Required<ColumnType>) => c.pv) || relatedTableMeta?.value?.columns?.[0])?.title return (meta.value?.columns?.find((c: Required<ColumnType>) => c.pv) || relatedTableMeta?.value?.columns?.[0])?.title
}) })
const loadChildrenExcludedList = async () => { const loadChildrenExcludedList = async (activeState?: any) => {
try { try {
if (isPublic.value) { if (isPublic.value) {
const router = useRouter() const router = useRouter()
@ -146,6 +146,26 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
}, },
) )
if (childrenExcludedList.value?.list && activeState && activeState[column.value.title]) {
childrenExcludedList.value.list = childrenExcludedList.value?.list.filter((c: any) => {
// filter out exact same objects in activeState[column.value.title]
// compare all keys and values
const found = activeState[column.value.title].find((a: any) => {
let isSame = true
for (const key in a) {
if (a[key] !== c[key]) {
isSame = false
}
}
return isSame
})
return !found
})
}
/** if new row load all records */ /** if new row load all records */
} else if (isNewRow?.value) { } else if (isNewRow?.value) {
childrenExcludedList.value = await $api.dbTableRow.list( childrenExcludedList.value = await $api.dbTableRow.list(

Loading…
Cancel
Save