Browse Source

Merge pull request #4062 from nocodb/fix/view-data-inj

pull/4072/head
Braks 2 years ago committed by GitHub
parent
commit
03fded3e7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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 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 [

8
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"

21
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<PaginatedType>({ 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)

Loading…
Cancel
Save