From 95f252ba844ea79fc5ebdd545e5c7f26cdf658f8 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Thu, 13 Oct 2022 15:56:29 +0200 Subject: [PATCH] fix(nc-gui): remove `useMetas` from cb fn --- .../nc-gui/components/smartsheet/Cell.vue | 12 +++++++---- .../nc-gui/components/smartsheet/Grid.vue | 8 ++++--- packages/nc-gui/composables/useViewData.ts | 21 +++++++++---------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/Cell.vue b/packages/nc-gui/components/smartsheet/Cell.vue index d37f19e3ce..8101fce96b 100644 --- a/packages/nc-gui/components/smartsheet/Cell.vue +++ b/packages/nc-gui/components/smartsheet/Cell.vue @@ -58,10 +58,14 @@ const isLocked = inject(IsLockedInj, ref(false)) const { currentRow } = useSmartsheetRowStoreOrThrow() -const syncValue = useDebounceFn(function () { - currentRow.value.rowMeta.changed = false - emit('save') -}, 1000) +const syncValue = useDebounceFn( + () => { + currentRow.value.rowMeta.changed = false + emit('save') + }, + 500, + { maxWait: 2000 }, +) const isAutoSaved = $computed(() => { return [ diff --git a/packages/nc-gui/components/smartsheet/Grid.vue b/packages/nc-gui/components/smartsheet/Grid.vue index d7d859d63d..862a916c75 100644 --- a/packages/nc-gui/components/smartsheet/Grid.vue +++ b/packages/nc-gui/components/smartsheet/Grid.vue @@ -506,8 +506,8 @@ watch( class="cell relative cursor-pointer nc-grid-cell" :class="{ 'active': - (isUIAllowed('xcDatatableEditable') && selected.col === colIndex && selected.row === rowIndex) || - (isUIAllowed('xcDatatableEditable') && selectedRange(rowIndex, colIndex)), + (hasEditPermission && selected.col === colIndex && selected.row === rowIndex) || + (hasEditPermission && selectedRange(rowIndex, colIndex)), 'nc-required-cell': isColumnRequiredAndNull(columnObj, row.row), }" :data-key="rowIndex + columnObj.id" @@ -533,7 +533,9 @@ watch( v-else v-model="row.row[columnObj.title]" :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" :active="selected.col === colIndex && selected.row === rowIndex" @update:edit-enabled="editEnabled = false" diff --git a/packages/nc-gui/composables/useViewData.ts b/packages/nc-gui/composables/useViewData.ts index 6eb63e87db..0b21448f7c 100644 --- a/packages/nc-gui/composables/useViewData.ts +++ b/packages/nc-gui/composables/useViewData.ts @@ -44,6 +44,9 @@ export function useViewData( const { api, isLoading, error } = useApi() const { appInfo } = $(useGlobal()) + + const { getMeta } = useMetas() + const appInfoDefaultLimit = appInfo.defaultLimit || 25 const _paginationData = ref({ page: 1, pageSize: appInfoDefaultLimit }) 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 } = {}, ) { try { - const { getMeta } = useMetas() - const { missingRequiredColumns, insertObj } = await populateInsertObject({ meta: metaValue!, ltarState, @@ -258,15 +259,13 @@ export function useViewData( // } ) // audit - $api.utils - .auditRowUpdate(id, { - fk_model_id: meta.value?.id as string, - column_name: property, - row_id: id, - value: getHTMLEncodedText(toUpdate.row[property]), - prev_value: getHTMLEncodedText(toUpdate.oldRow[property]), - }) - .then(() => {}) + $api.utils.auditRowUpdate(id, { + fk_model_id: meta.value?.id as string, + column_name: property, + row_id: id, + value: getHTMLEncodedText(toUpdate.row[property]), + prev_value: getHTMLEncodedText(toUpdate.oldRow[property]), + }) /** update row data(to sync formula and other related columns) */ Object.assign(toUpdate.row, updatedRowData)