|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
import type { ExportTypes, FilterType, PaginatedType, SortType, TableType, ViewType } from 'nocodb-sdk' |
|
|
|
|
import type { ExportTypes, FilterType, PaginatedType, RequestParams, SortType, TableType, ViewType } from 'nocodb-sdk' |
|
|
|
|
import { UITypes } from 'nocodb-sdk' |
|
|
|
|
import { useNuxtApp } from '#app' |
|
|
|
|
|
|
|
|
@ -8,15 +8,15 @@ export function useSharedView() {
|
|
|
|
|
() => [], |
|
|
|
|
) |
|
|
|
|
const paginationData = useState<PaginatedType>('paginationData', () => ({ page: 1, pageSize: 25 })) |
|
|
|
|
const sharedView = useState<ViewType>('sharedView') |
|
|
|
|
const sharedView = useState<ViewType | undefined>('sharedView', () => undefined) |
|
|
|
|
const sorts = useState<SortType[]>('sorts', () => []) |
|
|
|
|
const password = useState<string | undefined>('password') |
|
|
|
|
const password = useState<string | undefined>('password', () => undefined) |
|
|
|
|
const allowCSVDownload = useState<boolean>('allowCSVDownload', () => false) |
|
|
|
|
const meta = useState<TableType | undefined>('meta', () => undefined) |
|
|
|
|
|
|
|
|
|
const meta = useState<TableType>('meta') |
|
|
|
|
const formColumns = computed( |
|
|
|
|
() => |
|
|
|
|
meta.value.columns |
|
|
|
|
meta.value?.columns |
|
|
|
|
?.filter( |
|
|
|
|
(f: Record<string, any>) => |
|
|
|
|
f.show && f.uidt !== UITypes.Rollup && f.uidt !== UITypes.Lookup && f.uidt !== UITypes.Formula, |
|
|
|
@ -29,7 +29,9 @@ export function useSharedView() {
|
|
|
|
|
const { setMeta } = useMetas() |
|
|
|
|
|
|
|
|
|
const loadSharedView = async (viewId: string, localPassword: string | undefined = undefined) => { |
|
|
|
|
const viewMeta = await $api.public.sharedViewMetaGet(viewId, { |
|
|
|
|
if (!meta.value) return |
|
|
|
|
|
|
|
|
|
const viewMeta: Record<string, any> = await $api.public.sharedViewMetaGet(viewId, { |
|
|
|
|
headers: { |
|
|
|
|
'xc-password': localPassword ?? password.value, |
|
|
|
|
}, |
|
|
|
@ -42,7 +44,7 @@ export function useSharedView() {
|
|
|
|
|
meta.value = { ...viewMeta.model } |
|
|
|
|
|
|
|
|
|
let order = 1 |
|
|
|
|
meta.value.columns = [...viewMeta.model.columns] |
|
|
|
|
meta.value!.columns = [...viewMeta.model.columns] |
|
|
|
|
.filter((c) => c.show) |
|
|
|
|
.map((c) => ({ ...c, order: order++ })) |
|
|
|
|
.sort((a, b) => a.order - b.order) |
|
|
|
@ -58,7 +60,7 @@ export function useSharedView() {
|
|
|
|
|
const pageSize = paginationData.value.pageSize || 25 |
|
|
|
|
|
|
|
|
|
const { data } = await $api.public.dataList( |
|
|
|
|
sharedView?.value?.uuid, |
|
|
|
|
(sharedView.value as any)?.uuid, |
|
|
|
|
{ |
|
|
|
|
offset: (page - 1) * pageSize, |
|
|
|
|
filterArrJson: JSON.stringify(nestedFilters.value), |
|
|
|
@ -80,7 +82,7 @@ export function useSharedView() {
|
|
|
|
|
type: ExportTypes.EXCEL | ExportTypes.CSV, |
|
|
|
|
responseType: 'base64' | 'blob', |
|
|
|
|
) => { |
|
|
|
|
return await $api.public.csvExport(sharedView.value?.uuid, type, { |
|
|
|
|
return await $api.public.csvExport((sharedView.value as any)?.uuid, type, { |
|
|
|
|
format: responseType as any, |
|
|
|
|
query: { |
|
|
|
|
fields: fields.map((field) => field.title), |
|
|
|
@ -92,7 +94,7 @@ export function useSharedView() {
|
|
|
|
|
headers: { |
|
|
|
|
'xc-password': password.value, |
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|
} as RequestParams) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|