Browse Source

fix(nc-gui): remove `useMetas` from cb fn

pull/4062/head
braks 2 years ago
parent
commit
95f252ba84
  1. 12
      packages/nc-gui/components/smartsheet/Cell.vue
  2. 8
      packages/nc-gui/components/smartsheet/Grid.vue
  3. 21
      packages/nc-gui/composables/useViewData.ts

12
packages/nc-gui/components/smartsheet/Cell.vue

@ -58,10 +58,14 @@ const isLocked = inject(IsLockedInj, ref(false))
const { currentRow } = useSmartsheetRowStoreOrThrow() const { currentRow } = useSmartsheetRowStoreOrThrow()
const syncValue = useDebounceFn(function () { const syncValue = useDebounceFn(
currentRow.value.rowMeta.changed = false () => {
emit('save') currentRow.value.rowMeta.changed = false
}, 1000) emit('save')
},
500,
{ maxWait: 2000 },
)
const isAutoSaved = $computed(() => { const isAutoSaved = $computed(() => {
return [ return [

8
packages/nc-gui/components/smartsheet/Grid.vue

@ -506,8 +506,8 @@ watch(
class="cell relative cursor-pointer nc-grid-cell" class="cell relative cursor-pointer nc-grid-cell"
:class="{ :class="{
'active': 'active':
(isUIAllowed('xcDatatableEditable') && selected.col === colIndex && selected.row === rowIndex) || (hasEditPermission && selected.col === colIndex && selected.row === rowIndex) ||
(isUIAllowed('xcDatatableEditable') && selectedRange(rowIndex, colIndex)), (hasEditPermission && selectedRange(rowIndex, colIndex)),
'nc-required-cell': isColumnRequiredAndNull(columnObj, row.row), 'nc-required-cell': isColumnRequiredAndNull(columnObj, row.row),
}" }"
:data-key="rowIndex + columnObj.id" :data-key="rowIndex + columnObj.id"
@ -533,7 +533,9 @@ watch(
v-else v-else
v-model="row.row[columnObj.title]" v-model="row.row[columnObj.title]"
:column="columnObj" :column="columnObj"
:edit-enabled="hasEditPermission && editEnabled && selected.col === colIndex && selected.row === rowIndex" :edit-enabled="
!!hasEditPermission && !!editEnabled && selected.col === colIndex && selected.row === rowIndex
"
:row-index="rowIndex" :row-index="rowIndex"
:active="selected.col === colIndex && selected.row === rowIndex" :active="selected.col === colIndex && selected.row === rowIndex"
@update:edit-enabled="editEnabled = false" @update:edit-enabled="editEnabled = false"

21
packages/nc-gui/composables/useViewData.ts

@ -44,6 +44,9 @@ export function useViewData(
const { api, isLoading, error } = useApi() const { api, isLoading, error } = useApi()
const { appInfo } = $(useGlobal()) const { appInfo } = $(useGlobal())
const { getMeta } = useMetas()
const appInfoDefaultLimit = appInfo.defaultLimit || 25 const appInfoDefaultLimit = appInfo.defaultLimit || 25
const _paginationData = ref<PaginatedType>({ page: 1, pageSize: appInfoDefaultLimit }) const _paginationData = ref<PaginatedType>({ page: 1, pageSize: appInfoDefaultLimit })
const aggCommentCount = ref<{ row_id: string; count: number }[]>([]) const aggCommentCount = ref<{ row_id: string; count: number }[]>([])
@ -203,8 +206,6 @@ export function useViewData(
{ metaValue = meta.value, viewMetaValue = viewMeta.value }: { metaValue?: TableType; viewMetaValue?: ViewType } = {}, { metaValue = meta.value, viewMetaValue = viewMeta.value }: { metaValue?: TableType; viewMetaValue?: ViewType } = {},
) { ) {
try { try {
const { getMeta } = useMetas()
const { missingRequiredColumns, insertObj } = await populateInsertObject({ const { missingRequiredColumns, insertObj } = await populateInsertObject({
meta: metaValue!, meta: metaValue!,
ltarState, ltarState,
@ -258,15 +259,13 @@ export function useViewData(
// } // }
) )
// audit // audit
$api.utils $api.utils.auditRowUpdate(id, {
.auditRowUpdate(id, { fk_model_id: meta.value?.id as string,
fk_model_id: meta.value?.id as string, column_name: property,
column_name: property, row_id: id,
row_id: id, value: getHTMLEncodedText(toUpdate.row[property]),
value: getHTMLEncodedText(toUpdate.row[property]), prev_value: getHTMLEncodedText(toUpdate.oldRow[property]),
prev_value: getHTMLEncodedText(toUpdate.oldRow[property]), })
})
.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)

Loading…
Cancel
Save