|
|
@ -10,6 +10,7 @@ import { |
|
|
|
getHTMLEncodedText, |
|
|
|
getHTMLEncodedText, |
|
|
|
useProject, |
|
|
|
useProject, |
|
|
|
useUIPermission, |
|
|
|
useUIPermission, |
|
|
|
|
|
|
|
useApi |
|
|
|
} from '#imports' |
|
|
|
} from '#imports' |
|
|
|
|
|
|
|
|
|
|
|
const formatData = (list: Record<string, any>[]) => |
|
|
|
const formatData = (list: Record<string, any>[]) => |
|
|
@ -38,6 +39,7 @@ export function useViewData( |
|
|
|
throw new Error('Table meta is not available') |
|
|
|
throw new Error('Table meta is not available') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { api, isLoading, error } = useApi() |
|
|
|
const _paginationData = ref<PaginatedType>({ page: 1, pageSize: 25 }) |
|
|
|
const _paginationData = ref<PaginatedType>({ page: 1, pageSize: 25 }) |
|
|
|
const aggCommentCount = ref<{ row_id: string; count: number }[]>([]) |
|
|
|
const aggCommentCount = ref<{ row_id: string; count: number }[]>([]) |
|
|
|
const galleryData = ref<GalleryType>() |
|
|
|
const galleryData = ref<GalleryType>() |
|
|
@ -114,9 +116,8 @@ export function useViewData( |
|
|
|
|
|
|
|
|
|
|
|
const loadData = async (params: Parameters<Api<any>['dbViewRow']['list']>[4] = {}) => { |
|
|
|
const loadData = async (params: Parameters<Api<any>['dbViewRow']['list']>[4] = {}) => { |
|
|
|
if ((!project?.value?.id || !meta?.value?.id || !viewMeta?.value?.id) && !isPublic.value) return |
|
|
|
if ((!project?.value?.id || !meta?.value?.id || !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!, meta.value.id!, viewMeta!.value.id, { |
|
|
|
...params, |
|
|
|
...params, |
|
|
|
...(isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(sorts.value) }), |
|
|
|
...(isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(sorts.value) }), |
|
|
|
...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(nestedFilters.value) }), |
|
|
|
...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(nestedFilters.value) }), |
|
|
@ -192,7 +193,8 @@ export function useViewData( |
|
|
|
value: getHTMLEncodedText(toUpdate.row[property]), |
|
|
|
value: getHTMLEncodedText(toUpdate.row[property]), |
|
|
|
prev_value: getHTMLEncodedText(toUpdate.oldRow[property]), |
|
|
|
prev_value: getHTMLEncodedText(toUpdate.oldRow[property]), |
|
|
|
}) |
|
|
|
}) |
|
|
|
.then(() => {}) |
|
|
|
.then(() => { |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
/** update row data(to sync formula and other related columns) */ |
|
|
|
/** update row data(to sync formula and other related columns) */ |
|
|
|
Object.assign(toUpdate.row, updatedRowData) |
|
|
|
Object.assign(toUpdate.row, updatedRowData) |
|
|
@ -234,7 +236,7 @@ export function useViewData( |
|
|
|
|
|
|
|
|
|
|
|
const deleteRowById = async (id: string) => { |
|
|
|
const deleteRowById = async (id: string) => { |
|
|
|
if (!id) { |
|
|
|
if (!id) { |
|
|
|
throw new Error("Delete not allowed for table which doesn't have primary Key") |
|
|
|
throw new Error('Delete not allowed for table which doesn\'t have primary Key') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const res: any = await $api.dbViewRow.delete( |
|
|
|
const res: any = await $api.dbViewRow.delete( |
|
|
@ -351,6 +353,8 @@ export function useViewData( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
|
|
|
|
error, |
|
|
|
|
|
|
|
isLoading, |
|
|
|
loadData, |
|
|
|
loadData, |
|
|
|
paginationData, |
|
|
|
paginationData, |
|
|
|
queryParams, |
|
|
|
queryParams, |
|
|
|