|
|
|
@ -33,8 +33,6 @@ const { modelValue } = defineProps<Props>()
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits(['update:modelValue']) |
|
|
|
|
|
|
|
|
|
const { isMysql } = useProject() |
|
|
|
|
|
|
|
|
|
const column = inject(ColumnInj)! |
|
|
|
|
|
|
|
|
|
const readOnly = inject(ReadonlyInj)! |
|
|
|
@ -59,6 +57,8 @@ const { $api } = useNuxtApp()
|
|
|
|
|
|
|
|
|
|
const { getMeta } = useMetas() |
|
|
|
|
|
|
|
|
|
const { isPg, isMysql } = useProject() |
|
|
|
|
|
|
|
|
|
// a variable to keep newly created options value |
|
|
|
|
// temporary until it's add the option to column meta |
|
|
|
|
const tempSelectedOptsState = reactive<string[]>([]) |
|
|
|
@ -171,8 +171,19 @@ useSelectedCellKeyupListener(active, (e) => {
|
|
|
|
|
isOpen.value = true |
|
|
|
|
} |
|
|
|
|
break |
|
|
|
|
case 'ArrowUp': |
|
|
|
|
case 'ArrowDown': |
|
|
|
|
case 'ArrowRight': |
|
|
|
|
case 'ArrowLeft': |
|
|
|
|
case 'Delete': |
|
|
|
|
// skip |
|
|
|
|
break |
|
|
|
|
default: |
|
|
|
|
isOpen.value = true |
|
|
|
|
// toggle only if char key pressed |
|
|
|
|
if (e.key?.length === 1) { |
|
|
|
|
e.stopPropagation() |
|
|
|
|
isOpen.value = true |
|
|
|
|
} |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
@ -195,9 +206,28 @@ async function addIfMissingAndSave() {
|
|
|
|
|
}) |
|
|
|
|
column.value.colOptions = { options: newOptions.map(({ value: _, ...rest }) => rest) } |
|
|
|
|
|
|
|
|
|
await $api.dbTableColumn.update((column.value as { fk_column_id?: string })?.fk_column_id || (column.value?.id as string), { |
|
|
|
|
...column.value, |
|
|
|
|
}) |
|
|
|
|
const updatedColMeta = { ...column.value } |
|
|
|
|
|
|
|
|
|
// todo: refactor and avoid repetition |
|
|
|
|
if (updatedColMeta.cdf) { |
|
|
|
|
// 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) { |
|
|
|
|
updatedColMeta.cdf = updatedColMeta.cdf.substring( |
|
|
|
|
updatedColMeta.cdf.indexOf(`'`) + 1, |
|
|
|
|
updatedColMeta.cdf.lastIndexOf(`'`), |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Mysql escapes single quotes with backslash so we keep quotes but others have to unescaped |
|
|
|
|
if (!isMysql.value) { |
|
|
|
|
updatedColMeta.cdf = updatedColMeta.cdf.replace(/''/g, "'") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
await $api.dbTableColumn.update( |
|
|
|
|
(column.value as { fk_column_id?: string })?.fk_column_id || (column.value?.id as string), |
|
|
|
|
updatedColMeta, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
activeOptCreateInProgress.value-- |
|
|
|
|
if (!activeOptCreateInProgress.value) { |
|
|
|
|