|
|
@ -57,7 +57,9 @@ const { $api } = useNuxtApp() |
|
|
|
|
|
|
|
|
|
|
|
const { getMeta } = useMetas() |
|
|
|
const { getMeta } = useMetas() |
|
|
|
|
|
|
|
|
|
|
|
const tempVal = reactive<string[]>([]) |
|
|
|
// a variable to keep newly created options value |
|
|
|
|
|
|
|
// temporary until it's add the option to column meta |
|
|
|
|
|
|
|
const tempSelectedOptsState = reactive<string[]>([]) |
|
|
|
|
|
|
|
|
|
|
|
const options = computed<(SelectOptionType & { value?: string })[]>(() => { |
|
|
|
const options = computed<(SelectOptionType & { value?: string })[]>(() => { |
|
|
|
if (column?.value.colOptions) { |
|
|
|
if (column?.value.colOptions) { |
|
|
@ -86,7 +88,7 @@ const vModel = computed({ |
|
|
|
return acc |
|
|
|
return acc |
|
|
|
}, [] as string[]) |
|
|
|
}, [] as string[]) |
|
|
|
|
|
|
|
|
|
|
|
if (tempVal.length) selected.push(...tempVal) |
|
|
|
if (tempSelectedOptsState.length) selected.push(...tempSelectedOptsState) |
|
|
|
|
|
|
|
|
|
|
|
return selected |
|
|
|
return selected |
|
|
|
}, |
|
|
|
}, |
|
|
@ -103,31 +105,18 @@ const selectedTitles = computed(() => |
|
|
|
? typeof modelValue === 'string' |
|
|
|
? typeof modelValue === 'string' |
|
|
|
? isMysql |
|
|
|
? isMysql |
|
|
|
? modelValue.split(',').sort((a, b) => { |
|
|
|
? modelValue.split(',').sort((a, b) => { |
|
|
|
const opa = options.value.find((el) => el.title === a) |
|
|
|
const opa = options.value.find((el) => el.title === a) |
|
|
|
const opb = options.value.find((el) => el.title === b) |
|
|
|
const opb = options.value.find((el) => el.title === b) |
|
|
|
if (opa && opb) { |
|
|
|
if (opa && opb) { |
|
|
|
return opa.order! - opb.order! |
|
|
|
return opa.order! - opb.order! |
|
|
|
} |
|
|
|
} |
|
|
|
return 0 |
|
|
|
return 0 |
|
|
|
}) |
|
|
|
}) |
|
|
|
: modelValue.split(',') |
|
|
|
: modelValue.split(',') |
|
|
|
: modelValue |
|
|
|
: modelValue |
|
|
|
: [], |
|
|
|
: [], |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// const handleKeys = async (e: KeyboardEvent) => { |
|
|
|
|
|
|
|
// switch (e.key) { |
|
|
|
|
|
|
|
// case 'Escape': |
|
|
|
|
|
|
|
// e.preventDefault() |
|
|
|
|
|
|
|
// isOpen.value = false |
|
|
|
|
|
|
|
// break |
|
|
|
|
|
|
|
// case 'Enter': |
|
|
|
|
|
|
|
// e.stopPropagation() |
|
|
|
|
|
|
|
// await addIfMissingAndSave() |
|
|
|
|
|
|
|
// break |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleClose = (e: MouseEvent) => { |
|
|
|
const handleClose = (e: MouseEvent) => { |
|
|
|
if (aselect.value && !aselect.value.$el.contains(e.target)) { |
|
|
|
if (aselect.value && !aselect.value.$el.contains(e.target)) { |
|
|
|
isOpen.value = false |
|
|
|
isOpen.value = false |
|
|
@ -191,7 +180,7 @@ const activeOptCreateInProgress = ref(0) |
|
|
|
async function addIfMissingAndSave() { |
|
|
|
async function addIfMissingAndSave() { |
|
|
|
if (!searchVal.value || isPublic.value) return false |
|
|
|
if (!searchVal.value || isPublic.value) return false |
|
|
|
try { |
|
|
|
try { |
|
|
|
tempVal.push(searchVal.value) |
|
|
|
tempSelectedOptsState.push(searchVal.value) |
|
|
|
const newOptValue = searchVal?.value |
|
|
|
const newOptValue = searchVal?.value |
|
|
|
searchVal.value = '' |
|
|
|
searchVal.value = '' |
|
|
|
activeOptCreateInProgress.value++ |
|
|
|
activeOptCreateInProgress.value++ |
|
|
@ -212,17 +201,15 @@ async function addIfMissingAndSave() { |
|
|
|
if (!activeOptCreateInProgress.value) { |
|
|
|
if (!activeOptCreateInProgress.value) { |
|
|
|
await getMeta(column.value.fk_model_id!, true) |
|
|
|
await getMeta(column.value.fk_model_id!, true) |
|
|
|
vModel.value = [...vModel.value] |
|
|
|
vModel.value = [...vModel.value] |
|
|
|
tempVal.splice(0, tempVal.length) |
|
|
|
tempSelectedOptsState.splice(0, tempSelectedOptsState.length) |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
activeOptCreateInProgress.value-- |
|
|
|
activeOptCreateInProgress.value-- |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
// todo: handle error message |
|
|
|
// todo: handle error |
|
|
|
console.log(e) |
|
|
|
console.log(e) |
|
|
|
activeOptCreateInProgress.value-- |
|
|
|
activeOptCreateInProgress.value-- |
|
|
|
} finally { |
|
|
|
|
|
|
|
// tempVal.value = '' |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|