Browse Source

chore(gui-v2): group imports and rename arg

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3338/head
Pranav C 2 years ago
parent
commit
174ae68f56
  1. 2
      packages/nc-gui-v2/composables/useExpandedFormStore.ts
  2. 16
      packages/nc-gui-v2/composables/useViewData.ts

2
packages/nc-gui-v2/composables/useExpandedFormStore.ts

@ -7,6 +7,7 @@ import {
NOCO,
extractPkFromRow,
extractSdkResponseErrorMsg,
getHTMLEncodedText,
useApi,
useInjectionState,
useNuxtApp,
@ -14,7 +15,6 @@ import {
useProvideSmartsheetRowStore,
} from '#imports'
import type { Row } from '~/composables'
import { getHTMLEncodedText } from '~/utils'
const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((meta: Ref<TableType>, row: Ref<Row>) => {
const { $e, $state, $api } = useNuxtApp()

16
packages/nc-gui-v2/composables/useViewData.ts

@ -7,10 +7,10 @@ import {
NOCO,
extractPkFromRow,
extractSdkResponseErrorMsg,
getHTMLEncodedText,
useProject,
useUIPermission,
} from '#imports'
import { getHTMLEncodedText } from '~/utils'
const formatData = (list: Record<string, any>[]) =>
list.map((row) => ({
@ -165,11 +165,11 @@ export function useViewData(
}
}
const updateRowProperty = async (row: Row, property: string) => {
const updateRowProperty = async (toUpdate: Row, property: string) => {
try {
const id = meta?.value?.columns
?.filter((c) => c.pk)
.map((c) => row.row[c.title as string])
.map((c) => toUpdate.row[c.title as string])
.join('___') as string
const updatedRowData = await $api.dbViewRow.update(
@ -179,7 +179,7 @@ export function useViewData(
viewMeta?.value?.id as string,
id,
{
[property]: row.row[property],
[property]: toUpdate.row[property],
},
// todo:
// {
@ -192,14 +192,14 @@ export function useViewData(
fk_model_id: meta?.value.id as string,
column_name: property,
row_id: id,
value: getHTMLEncodedText(row.row[property]),
prev_value: getHTMLEncodedText(row.oldRow[property]),
value: getHTMLEncodedText(toUpdate.row[property]),
prev_value: getHTMLEncodedText(toUpdate.oldRow[property]),
})
.catch(() => {})
/** update row data(to sync formula and other related columns) */
Object.assign(row.row, updatedRowData)
Object.assign(row.oldRow, updatedRowData)
Object.assign(toUpdate.row, updatedRowData)
Object.assign(toUpdate.oldRow, updatedRowData)
} catch (e: any) {
message.error(`Row update failed ${await extractSdkResponseErrorMsg(e)}`)
}

Loading…
Cancel
Save