Browse Source

fix(nc-gui): add condition to check default value

pull/7786/head
Ramesh Mane 4 months ago
parent
commit
62220705de
  1. 4
      packages/nc-gui/components/monaco/Editor.vue
  2. 2
      packages/nc-gui/components/smartsheet/Form.vue
  3. 20
      packages/nc-gui/composables/useSharedFormViewStore.ts
  4. 4
      packages/nc-gui/utils/dataUtils.ts

4
packages/nc-gui/components/monaco/Editor.vue

@ -22,10 +22,10 @@ const props = withDefaults(defineProps<Props>(), {
autoFocus: true,
})
const { hideMinimap, lang, validate, disableDeepCompare, modelValue, readOnly, autoFocus } = props
const emits = defineEmits(['update:modelValue'])
const { hideMinimap, lang, validate, disableDeepCompare, modelValue, readOnly, autoFocus } = props
const vModel = computed<string>({
get: () => {
if (typeof modelValue === 'object') {

2
packages/nc-gui/components/smartsheet/Form.vue

@ -1466,7 +1466,7 @@ useEventListener(
<SmartsheetHeaderCellIcon v-else :column-meta="field" />
<div class="flex-1 flex items-center justify-start max-w-[calc(100%_-_68px)] mr-4">
<div class="w-full flex items-center">
<div class="ml-1 inline-block max-w-1/2">
<div class="ml-1 inline-flex" :class="field.label?.trim() ? 'max-w-1/2' : 'max-w-[95%]'">
<NcTooltip class="truncate text-sm" :disabled="drag" show-on-truncate-only>
<template #title>
<div class="text-center">

20
packages/nc-gui/composables/useSharedFormViewStore.ts

@ -97,7 +97,11 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
helpers.withMessage(t('msg.error.fieldRequired', { value: fieldName }), required)
const formColumns = computed(() =>
columns.value?.filter((c) => c.show).filter((col) => !isSystemColumn(col) && (!isVirtualCol(col) || isLinksOrLTAR(col.uidt))),
columns.value
?.filter((c) => c.show)
.filter(
(col) => !isSystemColumn(col) && col.uidt !== UITypes.SpecificDBType && (!isVirtualCol(col) || isLinksOrLTAR(col.uidt)),
),
)
const loadSharedView = async () => {
@ -125,7 +129,15 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
)
columns.value = viewMeta.model?.columns?.map((c) => {
if (!isSystemColumn(c) && !isVirtualCol(c) && c?.title && c?.cdf) {
if (
!isSystemColumn(c) &&
!isVirtualCol(c) &&
!isAttachment(c) &&
c.uidt !== UITypes.SpecificDBType &&
c?.title &&
c?.cdf &&
!/^\w+\(\)|CURRENT_TIMESTAMP$/.test(c.cdf)
) {
formState.value[c.title] = c.cdf
}
@ -275,8 +287,8 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
!queryParam ||
isSystemColumn(c) ||
isVirtualCol(c) ||
// (isVirtualCol(c) && !isLinksOrLTAR(c)) || // Todo: Enable this after linksOrLTAR prefill supported
isAttachment(c)
isAttachment(c) ||
c.uidt === UITypes.SpecificDBType
) {
return c
}

4
packages/nc-gui/utils/dataUtils.ts

@ -102,9 +102,9 @@ export const rowDefaultData = (columns: ColumnType[] = []) => {
if (
!isSystemColumn(col) &&
!isVirtualCol(col) &&
!isLinksOrLTAR({ uidt: col.uidt! }) &&
![UITypes.Rollup, UITypes.Lookup, UITypes.Formula, UITypes.Barcode, UITypes.QrCode].includes(col.uidt) &&
col?.cdf
col?.cdf &&
!/^\w+\(\)|CURRENT_TIMESTAMP$/.test(col.cdf)
) {
const defaultValue = col.cdf
acc[col.title!] = typeof defaultValue === 'string' ? defaultValue.replace(/^'/, '').replace(/'$/, '') : defaultValue

Loading…
Cancel
Save