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">
import { UITypes } 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 { ColumnInj } from '~/context'
import { ColumnInj, EditModeInj } from '~/context'
interface Props {
column: ColumnType
@ -15,19 +15,18 @@ interface Emits {
(event: 'update:modelValue', value: any): void
}
const { column, editEnabled, ...rest } = defineProps<Props>()
const { column, ...props } = defineProps<Props>()
const emit = defineEmits(['update:modelValue', 'save'])
provide(ColumnInj, column)
provide(
'editEnabled',
computed(() => editEnabled),
)
provide(EditModeInj, toRef(props, 'editEnabled'))
let changed = $ref(false)
const syncValue = useDebounceFn(function () {
const syncValue = useDebounceFn(function() {
emit('save')
}, 1000)
@ -53,9 +52,9 @@ const isManualSaved = $computed(() => {
})
const vModel = computed({
get: () => rest.modelValue,
get: () => props.modelValue,
set: (val) => {
if (val !== rest.modelValue) {
if (val !== props.modelValue) {
changed = true
emit('update:modelValue', val)
if (isAutoSaved) {

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

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

Loading…
Cancel
Save