|
|
@ -180,12 +180,12 @@ export function useViewData( |
|
|
|
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!, { |
|
|
|
...queryParams.value, |
|
|
|
...queryParams.value, |
|
|
|
...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) }), |
|
|
|
where: where?.value, |
|
|
|
where: where?.value, |
|
|
|
}) |
|
|
|
}) |
|
|
|
: await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: nestedFilters.value }) |
|
|
|
: await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: nestedFilters.value }) |
|
|
|
formattedData.value = formatData(response.list) |
|
|
|
formattedData.value = formatData(response.list) |
|
|
|
paginationData.value = response.pageInfo |
|
|
|
paginationData.value = response.pageInfo |
|
|
@ -204,9 +204,12 @@ export function useViewData( |
|
|
|
row: Record<string, any>, |
|
|
|
row: Record<string, any>, |
|
|
|
rowIndex = formattedData.value?.length, |
|
|
|
rowIndex = formattedData.value?.length, |
|
|
|
ltarState: Record<string, any> = {}, |
|
|
|
ltarState: Record<string, any> = {}, |
|
|
|
{ metaValue = meta.value, viewMetaValue = viewMeta.value }: { metaValue?: TableType; viewMetaValue?: ViewType } = {}, |
|
|
|
{ |
|
|
|
|
|
|
|
metaValue = meta.value, |
|
|
|
|
|
|
|
viewMetaValue = viewMeta.value, |
|
|
|
|
|
|
|
}: { metaValue?: TableType; viewMetaValue?: ViewType } = {}, |
|
|
|
) { |
|
|
|
) { |
|
|
|
formattedData.value[rowIndex].rowMeta.saving = true |
|
|
|
if (formattedData.value[rowIndex].rowMeta) formattedData.value[rowIndex].rowMeta.saving = true |
|
|
|
try { |
|
|
|
try { |
|
|
|
const { missingRequiredColumns, insertObj } = await populateInsertObject({ |
|
|
|
const { missingRequiredColumns, insertObj } = await populateInsertObject({ |
|
|
|
meta: metaValue!, |
|
|
|
meta: metaValue!, |
|
|
@ -227,7 +230,7 @@ export function useViewData( |
|
|
|
|
|
|
|
|
|
|
|
Object.assign(formattedData.value[rowIndex], { |
|
|
|
Object.assign(formattedData.value[rowIndex], { |
|
|
|
row: { ...insertedData, ...row }, |
|
|
|
row: { ...insertedData, ...row }, |
|
|
|
rowMeta: { ...row.rowMeta, new: undefined }, |
|
|
|
rowMeta: { ...(row.rowMeta || {}), new: undefined }, |
|
|
|
oldRow: { ...insertedData }, |
|
|
|
oldRow: { ...insertedData }, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
@ -236,16 +239,19 @@ export function useViewData( |
|
|
|
} catch (error: any) { |
|
|
|
} catch (error: any) { |
|
|
|
message.error(await extractSdkResponseErrorMsg(error)) |
|
|
|
message.error(await extractSdkResponseErrorMsg(error)) |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
formattedData.value[rowIndex].rowMeta.saving = false |
|
|
|
if (formattedData.value[rowIndex].rowMeta) formattedData.value[rowIndex].rowMeta.saving = false |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function updateRowProperty( |
|
|
|
async function updateRowProperty( |
|
|
|
toUpdate: Row, |
|
|
|
toUpdate: Row, |
|
|
|
property: string, |
|
|
|
property: string, |
|
|
|
{ metaValue = meta.value, viewMetaValue = viewMeta.value }: { metaValue?: TableType; viewMetaValue?: ViewType } = {}, |
|
|
|
{ |
|
|
|
|
|
|
|
metaValue = meta.value, |
|
|
|
|
|
|
|
viewMetaValue = viewMeta.value, |
|
|
|
|
|
|
|
}: { metaValue?: TableType; viewMetaValue?: ViewType } = {}, |
|
|
|
) { |
|
|
|
) { |
|
|
|
toUpdate.rowMeta.saving = true |
|
|
|
if (toUpdate.rowMeta) toUpdate.rowMeta.saving = true |
|
|
|
try { |
|
|
|
try { |
|
|
|
const id = extractPkFromRow(toUpdate.row, meta.value?.columns as ColumnType[]) |
|
|
|
const id = extractPkFromRow(toUpdate.row, meta.value?.columns as ColumnType[]) |
|
|
|
|
|
|
|
|
|
|
@ -278,7 +284,7 @@ export function useViewData( |
|
|
|
} catch (e: any) { |
|
|
|
} catch (e: any) { |
|
|
|
message.error(`${t('msg.error.rowUpdateFailed')} ${await extractSdkResponseErrorMsg(e)}`) |
|
|
|
message.error(`${t('msg.error.rowUpdateFailed')} ${await extractSdkResponseErrorMsg(e)}`) |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
toUpdate.rowMeta.saving = false |
|
|
|
if (toUpdate.rowMeta) toUpdate.rowMeta.saving = false |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -289,7 +295,7 @@ export function useViewData( |
|
|
|
args: { metaValue?: TableType; viewMetaValue?: ViewType } = {}, |
|
|
|
args: { metaValue?: TableType; viewMetaValue?: ViewType } = {}, |
|
|
|
) { |
|
|
|
) { |
|
|
|
// if new row and save is in progress then wait until the save is complete
|
|
|
|
// if new row and save is in progress then wait until the save is complete
|
|
|
|
await until(() => !(row.rowMeta.new && row.rowMeta.saving)).toMatch((v) => v) |
|
|
|
await until(() => !(row.rowMeta?.new && row.rowMeta?.saving)).toMatch((v) => v) |
|
|
|
|
|
|
|
|
|
|
|
if (row.rowMeta.new) { |
|
|
|
if (row.rowMeta.new) { |
|
|
|
return await insertRow(row.row, formattedData.value.indexOf(row), ltarState, args) |
|
|
|
return await insertRow(row.row, formattedData.value.indexOf(row), ltarState, args) |
|
|
@ -309,7 +315,7 @@ export function useViewData( |
|
|
|
|
|
|
|
|
|
|
|
async function deleteRowById(id: string) { |
|
|
|
async function deleteRowById(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( |
|
|
|