Browse Source

Merge pull request #2984 from nocodb/fix/gui-v2-empty-meta

fix(gui-v2): fix empty meta & feed default values
pull/2991/head
Raju Udava 2 years ago committed by GitHub
parent
commit
5a2fa56cde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      packages/nc-gui-v2/components/smartsheet-column/CurrencyOptions.vue
  2. 6
      packages/nc-gui-v2/components/smartsheet-column/DurationOptions.vue
  3. 11
      packages/nc-gui-v2/components/smartsheet-column/RatingOptions.vue
  4. 22
      packages/nc-gui-v2/composables/useColumnCreateStore.ts

7
packages/nc-gui-v2/components/smartsheet-column/CurrencyOptions.vue

@ -57,6 +57,13 @@ const message = computed(() => {
function filterOption(input: string, option: Option) {
return option.value.toUpperCase().includes(input.toUpperCase())
}
// set default value
formState.value.meta = {
currency_locale: 'en-US',
currency_code: 'USD',
...formState.value.meta,
}
</script>
<template>

6
packages/nc-gui-v2/components/smartsheet-column/DurationOptions.vue

@ -10,6 +10,12 @@ const durationOptionList =
// h:mm:ss (e.g. 3:45, 1:23:40)
title: `${o.title} ${o.example}`,
})) || []
// set default value
formState.value.meta = {
duration: 0,
...formState.value.meta,
}
</script>
<template>

11
packages/nc-gui-v2/components/smartsheet-column/RatingOptions.vue

@ -32,6 +32,17 @@ const iconList = [
const advanced = ref(true)
const picked = ref(formState.value.meta.color || enumColor.light[0])
// set default value
formState.value.meta = {
icons: {
full: 'mdi-star',
empty: 'mdi-star-outline',
},
color: '#fcb401',
max: 5,
...formState.value.meta,
}
</script>
<template>

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

@ -34,6 +34,8 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState
title: 'title',
uidt: UITypes.SingleLineText,
...(column || {}),
// todo: swagger json update - include meta
meta: (column as any)?.meta || {},
})
const additionalValidations = ref<Record<string, any>>({})
@ -77,14 +79,16 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState
const { resetFields, validate, validateInfos } = useForm(formState, validators)
const setAdditionalValidations = (validations: Record<string, any>) => {
additionalValidations.value = validations
}
// actions
const generateNewColumnMeta = () => {
formState.value = sqlUi.value.getNewColumn((meta.value.columns?.length || 0) + 1)
setAdditionalValidations({})
formState.value = { meta: {}, ...sqlUi.value.getNewColumn((meta.value.columns?.length || 0) + 1) }
}
const setAdditionalValidations = (validations: Record<string, any>) => {
additionalValidations.value = validations
}
const onUidtOrIdTypeChange = () => {
const { isCurrency } = useColumn(formState.value as ColumnType)
@ -92,7 +96,7 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState
const colProp = sqlUi?.value.getDataTypeForUiType(formState?.value as any, idType as any)
formState.value = {
...formState.value,
meta: null,
meta: {},
rqd: false,
pk: false,
ai: false,
@ -170,11 +174,13 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState
}
const addOrUpdate = async (onSuccess: () => {}) => {
if (!(await validate())) return
formState.value.table_name = meta.value.table_name
formState.value.title = formState.value.column_name
try {
console.log(formState, validators)
if (!(await validate())) return
formState.value.table_name = meta.value.table_name
formState.value.title = formState.value.column_name
if (column) {
await $api.dbTableColumn.update(column.id as string, formState.value)
toast.success('Column updated')

Loading…
Cancel
Save