|
|
@ -11,6 +11,7 @@ import { |
|
|
|
useProject, |
|
|
|
useProject, |
|
|
|
useUIPermission, |
|
|
|
useUIPermission, |
|
|
|
} from '#imports' |
|
|
|
} from '#imports' |
|
|
|
|
|
|
|
import { getHTMLEncodedText } from '~/utils' |
|
|
|
|
|
|
|
|
|
|
|
const formatData = (list: Record<string, any>[]) => |
|
|
|
const formatData = (list: Record<string, any>[]) => |
|
|
|
list.map((row) => ({ |
|
|
|
list.map((row) => ({ |
|
|
@ -166,43 +167,41 @@ export function useViewData( |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const updateRowProperty = async (row: Record<string, any>, property: string) => { |
|
|
|
const updateRowProperty = async (row: Row, property: string) => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const id = meta?.value?.columns |
|
|
|
const id = meta?.value?.columns |
|
|
|
?.filter((c) => c.pk) |
|
|
|
?.filter((c) => c.pk) |
|
|
|
.map((c) => row[c.title as string]) |
|
|
|
.map((c) => row.row[c.title as string]) |
|
|
|
.join('___') as string |
|
|
|
.join('___') as string |
|
|
|
|
|
|
|
|
|
|
|
return await $api.dbViewRow.update( |
|
|
|
const updatedRowData = await $api.dbViewRow.update( |
|
|
|
NOCO, |
|
|
|
NOCO, |
|
|
|
project?.value.id as string, |
|
|
|
project?.value.id as string, |
|
|
|
meta?.value.id as string, |
|
|
|
meta?.value.id as string, |
|
|
|
viewMeta?.value?.id as string, |
|
|
|
viewMeta?.value?.id as string, |
|
|
|
id, |
|
|
|
id, |
|
|
|
{ |
|
|
|
{ |
|
|
|
[property]: row[property], |
|
|
|
[property]: row.row[property], |
|
|
|
}, |
|
|
|
}, |
|
|
|
// todo:
|
|
|
|
// todo:
|
|
|
|
// {
|
|
|
|
// {
|
|
|
|
// query: { ignoreWebhook: !saved }
|
|
|
|
// query: { ignoreWebhook: !saved }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
todo: audit |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// audit
|
|
|
|
// audit
|
|
|
|
this.$api.utils |
|
|
|
$api.utils |
|
|
|
.auditRowUpdate(id, { |
|
|
|
.auditRowUpdate(id, { |
|
|
|
fk_model_id: this.meta.id, |
|
|
|
fk_model_id: meta?.value.id as string, |
|
|
|
column_name: column.title, |
|
|
|
column_name: property, |
|
|
|
row_id: id, |
|
|
|
row_id: id, |
|
|
|
value: getPlainText(rowObj[column.title]), |
|
|
|
value: getHTMLEncodedText(row.row[property]), |
|
|
|
prev_value: getPlainText(oldRow[column.title]) |
|
|
|
prev_value: getHTMLEncodedText(row.oldRow[property]), |
|
|
|
}) |
|
|
|
}) |
|
|
|
.then(() => {}) |
|
|
|
.catch(() => {}) |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
/** update row data(to sync formula and other related columns) */ |
|
|
|
|
|
|
|
Object.assign(row.row, updatedRowData) |
|
|
|
|
|
|
|
Object.assign(row.oldRow, updatedRowData) |
|
|
|
} catch (e: any) { |
|
|
|
} catch (e: any) { |
|
|
|
message.error(`Row update failed ${await extractSdkResponseErrorMsg(e)}`) |
|
|
|
message.error(`Row update failed ${await extractSdkResponseErrorMsg(e)}`) |
|
|
|
} |
|
|
|
} |
|
|
@ -212,9 +211,8 @@ export function useViewData( |
|
|
|
if (row.rowMeta.new) { |
|
|
|
if (row.rowMeta.new) { |
|
|
|
await insertRow(row.row, formattedData.value.indexOf(row)) |
|
|
|
await insertRow(row.row, formattedData.value.indexOf(row)) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
await updateRowProperty(row.row, property) |
|
|
|
await updateRowProperty(row, property) |
|
|
|
} |
|
|
|
} |
|
|
|
reloadHook.trigger() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
const changePage = async (page: number) => { |
|
|
|
const changePage = async (page: number) => { |
|
|
|
paginationData.value.page = page |
|
|
|
paginationData.value.page = page |
|
|
|