Browse Source

fix: move default value handling for select column to SelectOptions

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/3894/head
mertmit 2 years ago
parent
commit
e3b82b5ec0
  1. 11
      packages/nc-gui/components/smartsheet/column/AdvancedOptions.vue
  2. 7
      packages/nc-gui/components/smartsheet/column/SelectOptions.vue

11
packages/nc-gui/components/smartsheet/column/AdvancedOptions.vue

@ -1,6 +1,6 @@
<script setup lang="ts">
import { UITypes } from 'nocodb-sdk'
import { computed, onBeforeMount, useColumnCreateStoreOrThrow, useProject, useVModel } from '#imports'
import { computed, useColumnCreateStoreOrThrow, useProject, useVModel } from '#imports'
const props = defineProps<{
value: any
@ -10,7 +10,7 @@ const emit = defineEmits(['update:value'])
const vModel = useVModel(props, 'value', emit)
const { sqlUi, isPg } = useProject()
const { sqlUi } = useProject()
const { onAlter, onDataTypeChange, validateInfos } = useColumnCreateStoreOrThrow()
@ -38,13 +38,6 @@ vModel.value.pk = !!vModel.value.pk
vModel.value.un = !!vModel.value.un
vModel.value.ai = !!vModel.value.ai
vModel.value.au = !!vModel.value.au
onBeforeMount(() => {
// Postgres returns default value wrapped with single quotes & casted with type so we have to get value between single quotes to keep it unified for all databases
if (isPg.value && vModel.value.cdf) {
vModel.value.cdf = vModel.value.cdf.substring(vModel.value.cdf.indexOf(`'`) + 1, vModel.value.cdf.lastIndexOf(`'`))
}
})
</script>
<template>

7
packages/nc-gui/components/smartsheet/column/SelectOptions.vue

@ -11,6 +11,8 @@ const emit = defineEmits(['update:value'])
const vModel = useVModel(props, 'value', emit)
const { isPg } = useProject()
const { setAdditionalValidations, validateInfos } = useColumnCreateStoreOrThrow()
let options = $ref<any[]>([])
@ -77,6 +79,11 @@ onMounted(() => {
for (const op of options.filter((el) => el.order === null)) {
op.title = op.title.replace(/^'/, '').replace(/'$/, '')
}
// Postgres returns default value wrapped with single quotes & casted with type so we have to get value between single quotes to keep it unified for all databases
if (isPg.value && vModel.value.cdf) {
vModel.value.cdf = vModel.value.cdf.substring(vModel.value.cdf.indexOf(`'`) + 1, vModel.value.cdf.lastIndexOf(`'`))
}
})
// focus last created input

Loading…
Cancel
Save