Browse Source

Merge branch 'develop' into feat/gui-v2-formula-options

pull/2998/head
Wing-Kam Wong 2 years ago
parent
commit
2fb4f2c7bd
  1. 2
      packages/nc-gui-v2/components/cell/Decimal.vue
  2. 2
      packages/nc-gui-v2/components/cell/Integer.vue
  3. 2
      packages/nc-gui-v2/components/cell/Text.vue
  4. 2
      packages/nc-gui-v2/components/cell/TextArea.vue
  5. 7
      packages/nc-gui-v2/components/smartsheet-column/CurrencyOptions.vue
  6. 6
      packages/nc-gui-v2/components/smartsheet-column/DurationOptions.vue
  7. 11
      packages/nc-gui-v2/components/smartsheet-column/RatingOptions.vue
  8. 22
      packages/nc-gui-v2/composables/useColumnCreateStore.ts
  9. 2
      packages/nc-gui-v2/composables/useViewColumns.ts

2
packages/nc-gui-v2/components/cell/Decimal.vue

@ -2,7 +2,7 @@
import { computed, inject, onMounted, ref } from '#imports'
interface Props {
modelValue: number
modelValue: number | null
}
interface Emits {

2
packages/nc-gui-v2/components/cell/Integer.vue

@ -3,7 +3,7 @@ import { inject, ref, useVModel } from '#imports'
import { EditModeInj } from '~/context'
interface Props {
modelValue: number
modelValue: number | null
}
interface Emits {

2
packages/nc-gui-v2/components/cell/Text.vue

@ -3,7 +3,7 @@ import { inject, ref, useVModel } from '#imports'
import { EditModeInj } from '~/context'
interface Props {
modelValue: string
modelValue: string | null
}
const props = defineProps<Props>()

2
packages/nc-gui-v2/components/cell/TextArea.vue

@ -3,7 +3,7 @@ import { inject, ref, useVModel } from '#imports'
import { EditModeInj } from '~/context'
interface Props {
modelValue?: string
modelValue: string | null
}
const props = defineProps<Props>()

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')

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

@ -83,7 +83,7 @@ export function useViewColumns(
const metaColumnById = computed(() => {
return (
meta.value.columns?.reduce<Record<string, ColumnType>>((acc, curr) => {
meta.value?.columns?.reduce<Record<string, ColumnType>>((acc, curr) => {
return {
...acc,
[curr.id!]: curr,

Loading…
Cancel
Save