|
|
@ -33,8 +33,9 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState |
|
|
|
const formState = ref<Partial<Record<string, any>>>({ |
|
|
|
const formState = ref<Partial<Record<string, any>>>({ |
|
|
|
title: 'title', |
|
|
|
title: 'title', |
|
|
|
uidt: UITypes.SingleLineText, |
|
|
|
uidt: UITypes.SingleLineText, |
|
|
|
meta: {}, |
|
|
|
|
|
|
|
...(column || {}), |
|
|
|
...(column || {}), |
|
|
|
|
|
|
|
// todo: swagger json update - include meta
|
|
|
|
|
|
|
|
meta: (column as any)?.meta || {}, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const additionalValidations = ref<Record<string, any>>({}) |
|
|
|
const additionalValidations = ref<Record<string, any>>({}) |
|
|
@ -78,14 +79,16 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState |
|
|
|
|
|
|
|
|
|
|
|
const { resetFields, validate, validateInfos } = useForm(formState, validators) |
|
|
|
const { resetFields, validate, validateInfos } = useForm(formState, validators) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const setAdditionalValidations = (validations: Record<string, any>) => { |
|
|
|
|
|
|
|
additionalValidations.value = validations |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// actions
|
|
|
|
// actions
|
|
|
|
const generateNewColumnMeta = () => { |
|
|
|
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 onUidtOrIdTypeChange = () => { |
|
|
|
const { isCurrency } = useColumn(formState.value as ColumnType) |
|
|
|
const { isCurrency } = useColumn(formState.value as ColumnType) |
|
|
@ -171,11 +174,13 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const addOrUpdate = async (onSuccess: () => {}) => { |
|
|
|
const addOrUpdate = async (onSuccess: () => {}) => { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
console.log(formState, validators) |
|
|
|
if (!(await validate())) return |
|
|
|
if (!(await validate())) return |
|
|
|
|
|
|
|
|
|
|
|
formState.value.table_name = meta.value.table_name |
|
|
|
formState.value.table_name = meta.value.table_name |
|
|
|
formState.value.title = formState.value.column_name |
|
|
|
formState.value.title = formState.value.column_name |
|
|
|
try { |
|
|
|
|
|
|
|
if (column) { |
|
|
|
if (column) { |
|
|
|
await $api.dbTableColumn.update(column.id as string, formState.value) |
|
|
|
await $api.dbTableColumn.update(column.id as string, formState.value) |
|
|
|
toast.success('Column updated') |
|
|
|
toast.success('Column updated') |
|
|
|