Browse Source

fix(gui-v2): handle share view project id case

pull/3353/head
Wing-Kam Wong 2 years ago
parent
commit
3348bba4f9
  1. 4
      packages/nc-gui-v2/components/smartsheet/expanded-form/index.vue
  2. 14
      packages/nc-gui-v2/composables/useLTARStore.ts

4
packages/nc-gui-v2/components/smartsheet/expanded-form/index.vue

@ -60,9 +60,11 @@ const { $api } = useNuxtApp()
if (props.loadRow) { if (props.loadRow) {
const { project } = useProject() const { project } = useProject()
const { sharedView } = useSharedView() as Record<string, any>
row.value.row = await $api.dbTableRow.read( row.value.row = await $api.dbTableRow.read(
NOCO, NOCO,
project.value.id as string, (project?.value?.id || sharedView.value.view.project_id) as string,
meta.value.title, meta.value.title,
extractPkFromRow(row.value.row, meta.value.columns as ColumnType[]), extractPkFromRow(row.value.row, meta.value.columns as ColumnType[]),
) )

14
packages/nc-gui-v2/composables/useLTARStore.ts

@ -46,6 +46,10 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
const colOptions = $computed(() => column?.value.colOptions as LinkToAnotherRecordType) const colOptions = $computed(() => column?.value.colOptions as LinkToAnotherRecordType)
const { sharedView } = useSharedView() as Record<string, any>
const projectId = project?.value?.id || sharedView.value.view.project_id
// getters // getters
const meta = computed(() => metas?.value?.[column?.value?.fk_model_id as string]) const meta = computed(() => metas?.value?.[column?.value?.fk_model_id as string])
const relatedTableMeta = computed<TableType>(() => { const relatedTableMeta = computed<TableType>(() => {
@ -109,7 +113,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
} else if (isNewRow?.value) { } else if (isNewRow?.value) {
childrenExcludedList.value = await $api.dbTableRow.list( childrenExcludedList.value = await $api.dbTableRow.list(
NOCO, NOCO,
project.value.id as string, projectId,
relatedTableMeta?.value?.id as string, relatedTableMeta?.value?.id as string,
{ {
limit: childrenExcludedListPagination.size, limit: childrenExcludedListPagination.size,
@ -123,7 +127,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
} else { } else {
childrenExcludedList.value = await $api.dbTableRow.nestedChildrenExcludedList( childrenExcludedList.value = await $api.dbTableRow.nestedChildrenExcludedList(
NOCO, NOCO,
project.value.id as string, projectId,
meta.value.id, meta.value.id,
rowId.value, rowId.value,
colOptions.type as 'mm' | 'hm', colOptions.type as 'mm' | 'hm',
@ -146,10 +150,10 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
const loadChildrenList = async () => { const loadChildrenList = async () => {
try { try {
if (colOptions.type === 'bt') return if (colOptions.type === 'bt') return
// console.log(sharedView.value.view.project_id)
childrenList.value = await $api.dbTableRow.nestedList( childrenList.value = await $api.dbTableRow.nestedList(
NOCO, NOCO,
project.value.id as string, (project?.value?.id || sharedView?.value?.view?.project_id) as string,
meta.value.id, meta.value.id,
rowId.value, rowId.value,
colOptions.type as 'mm' | 'hm', colOptions.type as 'mm' | 'hm',
@ -172,7 +176,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
onOk: async () => { onOk: async () => {
const id = getRelatedTableRowId(row) const id = getRelatedTableRowId(row)
try { try {
$api.dbTableRow.delete(NOCO, project.value.id as string, relatedTableMeta.value.id as string, id as string) $api.dbTableRow.delete(NOCO, projectId, relatedTableMeta.value.id as string, id as string)
reloadData?.() reloadData?.()
/** reload child list if not a new row */ /** reload child list if not a new row */

Loading…
Cancel
Save