Browse Source

fix(gui-v2): reset validators on new column meta generation and include meta prop

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/2984/head
Pranav C 2 years ago
parent
commit
88a553efe0
  1. 21
      packages/nc-gui-v2/composables/useColumnCreateStore.ts

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

@ -33,8 +33,9 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState
const formState = ref<Partial<Record<string, any>>>({
title: 'title',
uidt: UITypes.SingleLineText,
meta: {},
...(column || {}),
// todo: swagger json update - include meta
meta: (column as any)?.meta || {},
})
const additionalValidations = ref<Record<string, any>>({})
@ -78,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)
@ -171,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