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

15
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,16 +15,13 @@ 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( provide(EditModeInj, toRef(props, 'editEnabled'))
'editEnabled',
computed(() => editEnabled),
)
let changed = $ref(false) let changed = $ref(false)
const syncValue = useDebounceFn(function () { const syncValue = useDebounceFn(function () {
@ -53,9 +50,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)

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

Loading…
Cancel
Save