|
|
@ -32,11 +32,16 @@ const formatData = (list: Record<string, any>[]) => |
|
|
|
})) |
|
|
|
})) |
|
|
|
|
|
|
|
|
|
|
|
export function useViewData( |
|
|
|
export function useViewData( |
|
|
|
meta: Ref<TableType | undefined> | ComputedRef<TableType | undefined>, |
|
|
|
_meta: Ref<TableType | undefined> | ComputedRef<TableType | undefined>, |
|
|
|
viewMeta: Ref<ViewType | undefined> | ComputedRef<(ViewType & { id: string }) | undefined>, |
|
|
|
viewMeta: Ref<ViewType | undefined> | ComputedRef<(ViewType & { id: string }) | undefined>, |
|
|
|
where?: ComputedRef<string | undefined>, |
|
|
|
where?: ComputedRef<string | undefined>, |
|
|
|
) { |
|
|
|
) { |
|
|
|
if (!meta) { |
|
|
|
const { activeTableId, activeTable } = storeToRefs(useTablesStore()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const meta = computed(() => _meta.value || activeTable.value) |
|
|
|
|
|
|
|
const metaId = computed(() => _meta.value?.id || activeTableId.value) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!meta.value) { |
|
|
|
throw new Error('Table meta is not available') |
|
|
|
throw new Error('Table meta is not available') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -101,7 +106,7 @@ export function useViewData( |
|
|
|
const { count } = await $api.dbViewRow.count( |
|
|
|
const { count } = await $api.dbViewRow.count( |
|
|
|
NOCO, |
|
|
|
NOCO, |
|
|
|
project?.value?.id as string, |
|
|
|
project?.value?.id as string, |
|
|
|
meta?.value?.id as string, |
|
|
|
metaId.value as string, |
|
|
|
viewMeta?.value?.id as string, |
|
|
|
viewMeta?.value?.id as string, |
|
|
|
) |
|
|
|
) |
|
|
|
paginationData.value.totalRows = count |
|
|
|
paginationData.value.totalRows = count |
|
|
@ -150,7 +155,7 @@ export function useViewData( |
|
|
|
|
|
|
|
|
|
|
|
aggCommentCount.value = await $api.utils.commentCount({ |
|
|
|
aggCommentCount.value = await $api.utils.commentCount({ |
|
|
|
ids, |
|
|
|
ids, |
|
|
|
fk_model_id: meta.value?.id as string, |
|
|
|
fk_model_id: metaId.value as string, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
for (const row of formattedData.value) { |
|
|
|
for (const row of formattedData.value) { |
|
|
@ -160,9 +165,9 @@ export function useViewData( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function loadData(params: Parameters<Api<any>['dbViewRow']['list']>[4] = {}) { |
|
|
|
async function loadData(params: Parameters<Api<any>['dbViewRow']['list']>[4] = {}) { |
|
|
|
if ((!project?.value?.id || !meta.value?.id || !viewMeta.value?.id) && !isPublic.value) return |
|
|
|
if ((!project?.value?.id || !metaId.value || !viewMeta.value?.id) && !isPublic.value) return |
|
|
|
const response = !isPublic.value |
|
|
|
const response = !isPublic.value |
|
|
|
? await api.dbViewRow.list('noco', project.value.id!, meta.value!.id!, viewMeta.value!.id!, { |
|
|
|
? await api.dbViewRow.list('noco', project.value.id!, metaId.value!, viewMeta.value!.id!, { |
|
|
|
...queryParams.value, |
|
|
|
...queryParams.value, |
|
|
|
...params, |
|
|
|
...params, |
|
|
|
...(isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(sorts.value) }), |
|
|
|
...(isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(sorts.value) }), |
|
|
|