From 20f72c99a2b7aaa268fb8f3706bdee32f3aa17f4 Mon Sep 17 00:00:00 2001 From: Muhammed Mustafa Date: Thu, 23 Nov 2023 07:02:55 +0000 Subject: [PATCH 01/12] fix: Dblclick and right click to column header will not do anything for locked mode --- packages/nc-gui/components/smartsheet/header/Cell.vue | 6 ++++++ .../nc-gui/components/smartsheet/header/VirtualCell.vue | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/packages/nc-gui/components/smartsheet/header/Cell.vue b/packages/nc-gui/components/smartsheet/header/Cell.vue index be95ede623..2c48516fe8 100644 --- a/packages/nc-gui/components/smartsheet/header/Cell.vue +++ b/packages/nc-gui/components/smartsheet/header/Cell.vue @@ -17,6 +17,8 @@ const hideMenu = toRef(props, 'hideMenu') const isForm = inject(IsFormInj, ref(false)) +const isLocked = inject(IsLockedInj, ref(false)) + const isSurveyForm = inject(IsSurveyFormInj, ref(false)) const isExpandedForm = inject(IsExpandedFormOpenInj, ref(false)) @@ -46,12 +48,16 @@ const closeAddColumnDropdown = () => { } const openHeaderMenu = () => { + if (isLocked.value) return + if (!isForm.value && !isExpandedForm.value && isUIAllowed('fieldEdit') && !isMobileMode.value) { editColumnDropdown.value = true } } const openDropDown = (e: Event) => { + if (isLocked.value) return + if (isForm.value || isExpandedForm.value || (!isUIAllowed('fieldEdit') && !isMobileMode.value)) return e.preventDefault() diff --git a/packages/nc-gui/components/smartsheet/header/VirtualCell.vue b/packages/nc-gui/components/smartsheet/header/VirtualCell.vue index 62d595a52c..9b0c4d390e 100644 --- a/packages/nc-gui/components/smartsheet/header/VirtualCell.vue +++ b/packages/nc-gui/components/smartsheet/header/VirtualCell.vue @@ -36,6 +36,8 @@ const editColumnDropdown = ref(false) const isDropDownOpen = ref(false) +const isLocked = inject(IsLockedInj, ref(false)) + provide(ColumnInj, column) const { metas } = useMetas() @@ -124,12 +126,16 @@ const closeAddColumnDropdown = () => { } const openHeaderMenu = () => { + if (isLocked.value) return + if (!isForm.value && !isExpandedForm.value && isUIAllowed('fieldEdit') && !isMobileMode.value) { editColumnDropdown.value = true } } const openDropDown = (e: Event) => { + if (isLocked.value) return + if (isForm.value || isExpandedForm.value || (!isUIAllowed('fieldEdit') && !isMobileMode.value)) return e.preventDefault() From 721825a0c694d29cc6b6ad3614f639aa70f41685 Mon Sep 17 00:00:00 2001 From: Muhammed Mustafa Date: Thu, 23 Nov 2023 07:02:55 +0000 Subject: [PATCH 02/12] fix: Locked mode doesnt affect data operations for grid table --- .../components/smartsheet/grid/Table.vue | 79 ++++++++----------- 1 file changed, 33 insertions(+), 46 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/grid/Table.vue b/packages/nc-gui/components/smartsheet/grid/Table.vue index 5fdd247608..cbd90dbeeb 100644 --- a/packages/nc-gui/components/smartsheet/grid/Table.vue +++ b/packages/nc-gui/components/smartsheet/grid/Table.vue @@ -188,7 +188,7 @@ const isViewColumnsLoading = computed(() => _isViewColumnsLoading.value || !meta // #Permissions 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 { 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) { - if (!hasEditPermission.value || editEnabled.value || isView || isLocked.value || readOnly.value || isSystemColumn(col)) { + if (!hasEditPermission.value || editEnabled.value || isView || readOnly.value || isSystemColumn(col)) { return } @@ -382,9 +382,7 @@ function makeEditable(row: Row, col: ColumnType) { // #Computed -const isAddingEmptyRowAllowed = computed( - () => !isView && !isLocked.value && hasEditPermission.value && !isSqlView.value && !isPublicView.value, -) +const isAddingEmptyRowAllowed = computed(() => !isView && hasEditPermission.value && !isSqlView.value && !isPublicView.value) const visibleColLength = computed(() => fields.value?.length) @@ -452,9 +450,7 @@ async function openNewRecordHandler() { } const onDraftRecordClick = () => { - if (!isLocked?.value) { - openNewRecordFormHook.trigger() - } + openNewRecordFormHook.trigger() } const onNewRecordToGridClick = () => { @@ -987,7 +983,6 @@ const refreshFillHandle = () => { const showFillHandle = computed( () => !readOnly.value && - !isLocked.value && !editEnabled.value && (!selectedRange.isEmpty() || (activeCell.row !== null && activeCell.col !== null)) && !dataRef.value[(isNaN(selectedRange.end.row) ? activeCell.row : selectedRange.end.row) ?? -1]?.rowMeta?.new, @@ -1477,7 +1472,7 @@ onKeyStroke('ArrowDown', onDown) >
@@ -1503,29 +1498,28 @@ onKeyStroke('ArrowDown', onDown) class="!flex items-center" :data-testid="`row-save-spinner-${rowIndex}`" /> - + /> +
@@ -1717,19 +1711,14 @@ onKeyStroke('ArrowDown', onDown) {{ $t('general.clear') }} - - - -
+
- + - +
New Field @@ -730,19 +746,22 @@ const onFieldOptionUpdate = () => { Reset - + Save changes @@ -752,7 +771,7 @@ const onFieldOptionUpdate = () => {
- + - - Duplicate - - - Insert above - - - Insert below - - - - - -
- - Delete -
-
+ @@ -927,7 +955,13 @@ const onFieldOptionUpdate = () => { @click="changeField(displayColumn, $event)" >
- + { :preload="fieldState(activeField)" :table-explorer-columns="fields" embed-mode + :readonly="isLocked" from-table-explorer @update="onFieldUpdate" @add="onFieldAdd" From 0eaec112542b0e6c15378e908173c8089e6d2e45 Mon Sep 17 00:00:00 2001 From: Muhammed Mustafa Date: Thu, 23 Nov 2023 07:02:55 +0000 Subject: [PATCH 04/12] fix: Made share view toggle locked in locked mode --- .../components/dlg/share-and-collaborate/SharePage.vue | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue b/packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue index 386c7b9d38..0c609b1742 100644 --- a/packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue +++ b/packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue @@ -16,6 +16,8 @@ const { metas } = useMetas() const workspaceStore = useWorkspace() +const isLocked = inject(IsLockedInj, ref(false)) + const isUpdating = ref({ public: false, password: false, @@ -269,10 +271,6 @@ function onChangeTheme(color: string) { const isPublicShared = computed(() => { return !!activeView.value?.uuid }) - -const isPublicShareDisabled = computed(() => { - return false -})