Browse Source

fix: Locked mode doesnt affect data operations for grid table

pull/7067/head
Muhammed Mustafa 1 year ago
parent
commit
721825a0c6
  1. 33
      packages/nc-gui/components/smartsheet/grid/Table.vue

33
packages/nc-gui/components/smartsheet/grid/Table.vue

@ -188,7 +188,7 @@ const isViewColumnsLoading = computed(() => _isViewColumnsLoading.value || !meta
// #Permissions // #Permissions
const { isUIAllowed } = useRoles() const { isUIAllowed } = useRoles()
const hasEditPermission = computed(() => isUIAllowed('dataEdit') && !isLocked.value) const hasEditPermission = computed(() => isUIAllowed('dataEdit'))
const isAddingColumnAllowed = computed(() => !readOnly.value && !isLocked.value && isUIAllowed('fieldAdd') && !isSqlView.value) const isAddingColumnAllowed = computed(() => !readOnly.value && !isLocked.value && isUIAllowed('fieldAdd') && !isSqlView.value)
const { onDrag, onDragStart, draggedCol, dragColPlaceholderDomRef, toBeDroppedColId } = useColumnDrag({ const { onDrag, onDragStart, draggedCol, dragColPlaceholderDomRef, toBeDroppedColId } = useColumnDrag({
@ -351,7 +351,7 @@ async function clearCell(ctx: { row: number; col: number } | null, skipUpdate =
} }
function makeEditable(row: Row, col: ColumnType) { function makeEditable(row: Row, col: ColumnType) {
if (!hasEditPermission.value || editEnabled.value || isView || isLocked.value || readOnly.value || isSystemColumn(col)) { if (!hasEditPermission.value || editEnabled.value || isView || readOnly.value || isSystemColumn(col)) {
return return
} }
@ -382,9 +382,7 @@ function makeEditable(row: Row, col: ColumnType) {
// #Computed // #Computed
const isAddingEmptyRowAllowed = computed( const isAddingEmptyRowAllowed = computed(() => !isView && hasEditPermission.value && !isSqlView.value && !isPublicView.value)
() => !isView && !isLocked.value && hasEditPermission.value && !isSqlView.value && !isPublicView.value,
)
const visibleColLength = computed(() => fields.value?.length) const visibleColLength = computed(() => fields.value?.length)
@ -452,10 +450,8 @@ async function openNewRecordHandler() {
} }
const onDraftRecordClick = () => { const onDraftRecordClick = () => {
if (!isLocked?.value) {
openNewRecordFormHook.trigger() openNewRecordFormHook.trigger()
} }
}
const onNewRecordToGridClick = () => { const onNewRecordToGridClick = () => {
isAddNewRecordGridMode.value = true isAddNewRecordGridMode.value = true
@ -987,7 +983,6 @@ const refreshFillHandle = () => {
const showFillHandle = computed( const showFillHandle = computed(
() => () =>
!readOnly.value && !readOnly.value &&
!isLocked.value &&
!editEnabled.value && !editEnabled.value &&
(!selectedRange.isEmpty() || (activeCell.row !== null && activeCell.col !== null)) && (!selectedRange.isEmpty() || (activeCell.row !== null && activeCell.col !== null)) &&
!dataRef.value[(isNaN(selectedRange.end.row) ? activeCell.row : selectedRange.end.row) ?? -1]?.rowMeta?.new, !dataRef.value[(isNaN(selectedRange.end.row) ? activeCell.row : selectedRange.end.row) ?? -1]?.rowMeta?.new,
@ -1477,7 +1472,7 @@ onKeyStroke('ArrowDown', onDown)
> >
<div class="items-center flex gap-1 min-w-[60px]"> <div class="items-center flex gap-1 min-w-[60px]">
<div <div
v-if="!readOnly || !isLocked || isMobileMode" v-if="!readOnly || isMobileMode"
class="nc-row-no sm:min-w-4 text-xs text-gray-500" class="nc-row-no sm:min-w-4 text-xs text-gray-500"
:class="{ toggle: !readOnly, hidden: row.rowMeta.selected }" :class="{ toggle: !readOnly, hidden: row.rowMeta.selected }"
> >
@ -1503,7 +1498,7 @@ onKeyStroke('ArrowDown', onDown)
class="!flex items-center" class="!flex items-center"
:data-testid="`row-save-spinner-${rowIndex}`" :data-testid="`row-save-spinner-${rowIndex}`"
/> />
<template v-else-if="!isLocked">
<span <span
v-if="row.rowMeta?.commentCount && expandForm" v-if="row.rowMeta?.commentCount && expandForm"
v-e="['c:expanded-form:open']" v-e="['c:expanded-form:open']"
@ -1525,7 +1520,6 @@ onKeyStroke('ArrowDown', onDown)
@click="expandAndLooseFocus(row, state)" @click="expandAndLooseFocus(row, state)"
/> />
</div> </div>
</template>
</div> </div>
</div> </div>
</td> </td>
@ -1717,19 +1711,14 @@ onKeyStroke('ArrowDown', onDown)
{{ $t('general.clear') }} {{ $t('general.clear') }}
</div> </div>
</NcMenuItem> </NcMenuItem>
<template v-if="contextMenuTarget && selectedRange.isSingleCell() && isUIAllowed('commentEdit') && !isMobileMode">
<NcDivider /> <NcDivider />
<NcMenuItem <NcMenuItem v-e="['a:row:comment']" class="nc-base-menu-item" @click="commentRow(contextMenuTarget.row)">
v-if="contextMenuTarget && !isLocked && selectedRange.isSingleCell() && isUIAllowed('commentEdit') && !isMobileMode"
class="nc-base-menu-item"
@click="commentRow(contextMenuTarget.row)"
>
<div v-e="['a:row:comment']" class="flex gap-2 items-center">
<MdiMessageOutline class="h-4 w-4" /> <MdiMessageOutline class="h-4 w-4" />
{{ $t('general.comment') }} {{ $t('general.comment') }}
</div>
</NcMenuItem> </NcMenuItem>
</template>
<template v-if="hasEditPermission"> <template v-if="hasEditPermission">
<NcDivider v-if="!(!contextMenuClosing && !contextMenuTarget && data.some((r) => r.rowMeta.selected))" /> <NcDivider v-if="!(!contextMenuClosing && !contextMenuTarget && data.some((r) => r.rowMeta.selected))" />
@ -1810,8 +1799,7 @@ onKeyStroke('ArrowDown', onDown)
> >
<div <div
v-e="['c:row:add:grid']" v-e="['c:row:add:grid']"
:class="{ 'group': !isLocked, 'disabled-ring': isLocked }" class="px-4 py-3 flex flex-col select-none gap-y-2 cursor-pointer hover:bg-gray-100 text-gray-600 nc-new-record-with-grid group"
class="px-4 py-3 flex flex-col select-none gap-y-2 cursor-pointer hover:bg-gray-100 text-gray-600 nc-new-record-with-grid"
@click="onNewRecordToGridClick" @click="onNewRecordToGridClick"
> >
<div class="flex flex-row items-center justify-between w-full"> <div class="flex flex-row items-center justify-between w-full">
@ -1827,8 +1815,7 @@ onKeyStroke('ArrowDown', onDown)
</div> </div>
<div <div
v-e="['c:row:add:form']" v-e="['c:row:add:form']"
:class="{ 'group': !isLocked, 'disabled-ring': isLocked }" class="px-4 py-3 flex flex-col select-none gap-y-2 cursor-pointer hover:bg-gray-100 text-gray-600 nc-new-record-with-form group"
class="px-4 py-3 flex flex-col select-none gap-y-2 cursor-pointer hover:bg-gray-100 text-gray-600 nc-new-record-with-form"
@click="onNewRecordToFormClick" @click="onNewRecordToFormClick"
> >
<div class="flex flex-row items-center justify-between w-full"> <div class="flex flex-row items-center justify-between w-full">

Loading…
Cancel
Save