diff --git a/packages/nc-gui/.eslintrc.js b/packages/nc-gui/.eslintrc.js index 8780df770e..084e429adc 100644 --- a/packages/nc-gui/.eslintrc.js +++ b/packages/nc-gui/.eslintrc.js @@ -3,6 +3,7 @@ const baseRules = { 'no-console': 0, 'antfu/if-newline': 0, 'no-unused-vars': 0, + '@typescript-eslint/no-this-alias': 0, '@typescript-eslint/no-unused-vars': [ 'error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }, diff --git a/packages/nc-gui/components/cell/DatePicker.vue b/packages/nc-gui/components/cell/DatePicker.vue index 644dab08c0..9fae66cc85 100644 --- a/packages/nc-gui/components/cell/DatePicker.vue +++ b/packages/nc-gui/components/cell/DatePicker.vue @@ -12,11 +12,11 @@ const emit = defineEmits(['update:modelValue']) const columnMeta = inject(ColumnInj, null)! -const readOnly = inject(ReadonlyInj, false) +const readOnly = inject(ReadonlyInj, ref(false)) let isDateInvalid = $ref(false) -const dateFormat = columnMeta?.value?.meta?.date_format ?? 'YYYY-MM-DD' +const dateFormat = $computed(() => columnMeta?.value?.meta?.date_format ?? 'YYYY-MM-DD') const localState = $computed({ get() { diff --git a/packages/nc-gui/components/cell/DateTimePicker.vue b/packages/nc-gui/components/cell/DateTimePicker.vue index fb192cfc8c..d444494c8c 100644 --- a/packages/nc-gui/components/cell/DateTimePicker.vue +++ b/packages/nc-gui/components/cell/DateTimePicker.vue @@ -12,7 +12,7 @@ const emit = defineEmits(['update:modelValue']) const { isMysql } = useProject() -const readOnly = inject(ReadonlyInj, false) +const readOnly = inject(ReadonlyInj, ref(false)) let isDateInvalid = $ref(false) diff --git a/packages/nc-gui/components/cell/Text.vue b/packages/nc-gui/components/cell/Text.vue index 832ddb7ff4..53e7aa02b1 100644 --- a/packages/nc-gui/components/cell/Text.vue +++ b/packages/nc-gui/components/cell/Text.vue @@ -1,6 +1,6 @@ - + diff --git a/packages/nc-gui/components/smartsheet/toolbar/ViewActions.vue b/packages/nc-gui/components/smartsheet/toolbar/ViewActions.vue index c926a5c3d7..daa2c857f3 100644 --- a/packages/nc-gui/components/smartsheet/toolbar/ViewActions.vue +++ b/packages/nc-gui/components/smartsheet/toolbar/ViewActions.vue @@ -228,7 +228,7 @@ const { isSqlView } = useSmartsheetStoreOrThrow() - + diff --git a/packages/nc-gui/components/tabs/Smartsheet.vue b/packages/nc-gui/components/tabs/Smartsheet.vue index db6aad701d..392fa50c43 100644 --- a/packages/nc-gui/components/tabs/Smartsheet.vue +++ b/packages/nc-gui/components/tabs/Smartsheet.vue @@ -7,6 +7,7 @@ import { IsLockedInj, MetaInj, OpenNewRecordFormHookInj, + ReadonlyInj, ReloadViewDataHookInj, ReloadViewMetaHookInj, TabMetaInj, @@ -18,6 +19,7 @@ import { useMetas, useProvideKanbanViewStore, useProvideSmartsheetStore, + useUIPermission, } from '#imports' import type { TabItem } from '~/lib' @@ -25,6 +27,8 @@ const props = defineProps<{ activeTab: TabItem }>() +const { isUIAllowed } = useUIPermission() + const { metas } = useMetas() const activeTab = toRef(props, 'activeTab') @@ -55,6 +59,10 @@ provide(OpenNewRecordFormHookInj, openNewRecordFormHook) provide(FieldsInj, fields) provide(IsFormInj, isForm) provide(TabMetaInj, activeTab) +provide( + ReadonlyInj, + computed(() => !isUIAllowed('xcDatatableEditable')), +) - +
@@ -833,7 +865,7 @@ function isSelectDisabled(uidt: string, disableSelect = false) { Add Other Column - +
diff --git a/packages/nc-gui/components/virtual-cell/BelongsTo.vue b/packages/nc-gui/components/virtual-cell/BelongsTo.vue index e7f14fd3d4..8a2eaed14f 100644 --- a/packages/nc-gui/components/virtual-cell/BelongsTo.vue +++ b/packages/nc-gui/components/virtual-cell/BelongsTo.vue @@ -31,7 +31,7 @@ const row = inject(RowInj)! const active = inject(ActiveCellInj)! -const readOnly = inject(ReadonlyInj, false) +const readOnly = inject(ReadonlyInj, ref(false)) const isForm = inject(IsFormInj, ref(false)) diff --git a/packages/nc-gui/components/virtual-cell/Formula.vue b/packages/nc-gui/components/virtual-cell/Formula.vue index e6192c2ec3..f91a8a8cab 100644 --- a/packages/nc-gui/components/virtual-cell/Formula.vue +++ b/packages/nc-gui/components/virtual-cell/Formula.vue @@ -6,7 +6,7 @@ import { CellValueInj, ColumnInj, computed, handleTZ, inject, ref, replaceUrlsWi // todo: column type doesn't have required property `error` - throws in typecheck const column = inject(ColumnInj) as Ref -const value = inject(CellValueInj) +const cellValue = inject(CellValueInj) const { isPg } = useProject() @@ -20,7 +20,7 @@ const showEditFormulaWarningMessage = () => { }, 3000) } -const result = computed(() => (isPg.value ? handleTZ(value) : value)) +const result = computed(() => (isPg.value ? handleTZ(cellValue?.value) : cellValue?.value)) const urls = computed(() => replaceUrlsWithLink(result.value)) diff --git a/packages/nc-gui/components/virtual-cell/HasMany.vue b/packages/nc-gui/components/virtual-cell/HasMany.vue index c4f063ea03..82d7cbbb06 100644 --- a/packages/nc-gui/components/virtual-cell/HasMany.vue +++ b/packages/nc-gui/components/virtual-cell/HasMany.vue @@ -27,7 +27,7 @@ const reloadRowTrigger = inject(ReloadRowDataHookInj, createEventHook()) const isForm = inject(IsFormInj) -const readOnly = inject(ReadonlyInj, false) +const readOnly = inject(ReadonlyInj, ref(false)) const isLocked = inject(IsLockedInj) diff --git a/packages/nc-gui/components/virtual-cell/Lookup.vue b/packages/nc-gui/components/virtual-cell/Lookup.vue index 5f2530d9f2..789ff99187 100644 --- a/packages/nc-gui/components/virtual-cell/Lookup.vue +++ b/packages/nc-gui/components/virtual-cell/Lookup.vue @@ -17,7 +17,7 @@ import { const { metas, getMeta } = useMetas() -provide(ReadonlyInj, true) +provide(ReadonlyInj, ref(true)) const column = inject(ColumnInj)! as Ref diff --git a/packages/nc-gui/components/virtual-cell/ManyToMany.vue b/packages/nc-gui/components/virtual-cell/ManyToMany.vue index 30fdbe9f7f..3464471789 100644 --- a/packages/nc-gui/components/virtual-cell/ManyToMany.vue +++ b/packages/nc-gui/components/virtual-cell/ManyToMany.vue @@ -28,7 +28,7 @@ const reloadRowTrigger = inject(ReloadRowDataHookInj, createEventHook()) const isForm = inject(IsFormInj) -const readOnly = inject(ReadonlyInj, false) +const readOnly = inject(ReadonlyInj, ref(false)) const isLocked = inject(IsLockedInj) diff --git a/packages/nc-gui/components/virtual-cell/components/ItemChip.vue b/packages/nc-gui/components/virtual-cell/components/ItemChip.vue index fe11b08950..6665dd9187 100644 --- a/packages/nc-gui/components/virtual-cell/components/ItemChip.vue +++ b/packages/nc-gui/components/virtual-cell/components/ItemChip.vue @@ -1,5 +1,15 @@