Browse Source

fix(gui-v2): provide editEnabled from cell component

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/2991/head
Pranav C 2 years ago
parent
commit
bec5a095a7
  1. 19
      packages/nc-gui-v2/components/smartsheet/Cell.vue
  2. 4
      packages/nc-gui-v2/components/smartsheet/Grid.vue

19
packages/nc-gui-v2/components/smartsheet/Cell.vue

@ -1,9 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
import { UITypes } from 'nocodb-sdk' import { UITypes } from 'nocodb-sdk'
import type { ColumnType } from 'nocodb-sdk' import type { ColumnType } from 'nocodb-sdk'
import { provide } from 'vue' import { provide, toRef } from 'vue'
import { computed, useColumn, useDebounceFn, useVModel } from '#imports' import { computed, useColumn, useDebounceFn, useVModel } from '#imports'
import { ColumnInj } from '~/context' import { ColumnInj, EditModeInj } from '~/context'
interface Props { interface Props {
column: ColumnType column: ColumnType
@ -15,19 +15,18 @@ interface Emits {
(event: 'update:modelValue', value: any): void (event: 'update:modelValue', value: any): void
} }
const { column, editEnabled, ...rest } = defineProps<Props>() const { column, ...props } = defineProps<Props>()
const emit = defineEmits(['update:modelValue', 'save']) const emit = defineEmits(['update:modelValue', 'save'])
provide(ColumnInj, column) provide(ColumnInj, column)
provide(
'editEnabled', provide(EditModeInj, toRef(props, 'editEnabled'))
computed(() => editEnabled),
)
let changed = $ref(false) let changed = $ref(false)
const syncValue = useDebounceFn(function () { const syncValue = useDebounceFn(function() {
emit('save') emit('save')
}, 1000) }, 1000)
@ -53,9 +52,9 @@ const isManualSaved = $computed(() => {
}) })
const vModel = computed({ const vModel = computed({
get: () => rest.modelValue, get: () => props.modelValue,
set: (val) => { set: (val) => {
if (val !== rest.modelValue) { if (val !== props.modelValue) {
changed = true changed = true
emit('update:modelValue', val) emit('update:modelValue', val)
if (isAutoSaved) { if (isAutoSaved) {

4
packages/nc-gui-v2/components/smartsheet/Grid.vue

@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ColumnType, isVirtualCol } from 'nocodb-sdk' import { isVirtualCol } from 'nocodb-sdk'
import { import {
Row, Row,
inject, inject,
@ -14,7 +14,6 @@ import {
import { import {
ActiveViewInj, ActiveViewInj,
ChangePageInj, ChangePageInj,
EditModeInj,
FieldsInj, FieldsInj,
IsFormInj, IsFormInj,
IsGridInj, IsGridInj,
@ -65,7 +64,6 @@ onMounted(loadGridViewColumns)
provide(IsFormInj, false) provide(IsFormInj, false)
provide(IsGridInj, true) provide(IsGridInj, true)
provide(PaginationDataInj, paginationData) provide(PaginationDataInj, paginationData)
provide(EditModeInj, editEnabled)
provide(ChangePageInj, changePage) provide(ChangePageInj, changePage)
const reloadViewDataHook = inject(ReloadViewDataHookInj) const reloadViewDataHook = inject(ReloadViewDataHookInj)

Loading…
Cancel
Save