Browse Source

Merge pull request #2991 from nocodb/fix/edit-enabled

fix: Provide edit-enabled in cell level
pull/3002/head
Pranav C 2 years ago committed by GitHub
parent
commit
b03eac43ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      packages/nc-gui-v2/components/smartsheet-header/CellIcon.vue
  2. 15
      packages/nc-gui-v2/components/smartsheet/Cell.vue
  3. 4
      packages/nc-gui-v2/components/smartsheet/Grid.vue
  4. 2
      packages/nc-gui-v2/composables/useColumnCreateStore.ts

7
packages/nc-gui-v2/components/smartsheet-header/CellIcon.vue

@ -11,11 +11,10 @@ import WebIcon from '~icons/mdi/web'
import TextAreaIcon from '~icons/mdi/card-text-outline'
import StringIcon from '~icons/mdi/alpha-a-box-outline'
import BooleanIcon from '~icons/mdi/check-box-outline'
import YearIcon from '~icons/mdi/calendar'
import CalendarIcon from '~icons/mdi/calendar'
import SingleSelectIcon from '~icons/mdi/radiobox-marked'
import MultiSelectIcon from '~icons/mdi/checkbox-multiple-marked'
import DatetimeIcon from '~icons/mdi/calendar-clock'
import DateIcon from '~icons/mdi/calendar'
import RatingIcon from '~icons/mdi/star'
import GenericIcon from '~icons/mdi/square-rounded'
import NumericIcon from '~icons/mdi/numeric'
@ -37,7 +36,7 @@ const icon = computed(() => {
} else if (additionalColMeta.isJSON) {
return JSONIcon
} else if (additionalColMeta.isDate) {
return DateIcon
return CalendarIcon
} else if (additionalColMeta.isDateTime) {
return DatetimeIcon
} else if (additionalColMeta.isSet) {
@ -51,7 +50,7 @@ const icon = computed(() => {
} else if (additionalColMeta.isEmail) {
return EmailIcon
} else if (additionalColMeta.isYear) {
return YearIcon
return CalendarIcon
} else if (additionalColMeta.isTime) {
return ClockIcon
} else if (additionalColMeta.isRating) {

15
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,16 +15,13 @@ 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 () {
@ -53,9 +50,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)

2
packages/nc-gui-v2/composables/useColumnCreateStore.ts

@ -89,7 +89,6 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState
formState.value = { meta: {}, ...sqlUi.value.getNewColumn((meta.value.columns?.length || 0) + 1) }
}
const onUidtOrIdTypeChange = () => {
const { isCurrency } = useColumn(formState.value as ColumnType)
@ -174,7 +173,6 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState
}
const addOrUpdate = async (onSuccess: () => {}) => {
try {
console.log(formState, validators)
if (!(await validate())) return

Loading…
Cancel
Save