|
|
@ -1,7 +1,7 @@ |
|
|
|
<script lang="ts" setup> |
|
|
|
<script lang="ts" setup> |
|
|
|
import type { SelectOptionType } from '~~/../nocodb-sdk/build/main/index.js' |
|
|
|
import type { SelectOptionType } from '~~/../nocodb-sdk/build/main/index.js' |
|
|
|
import { computed, inject } from '#imports' |
|
|
|
import { computed, inject } from '#imports' |
|
|
|
import { ColumnInj } from '~/context' |
|
|
|
import { ActiveCellInj, ColumnInj, EditModeInj } from '~/context' |
|
|
|
|
|
|
|
|
|
|
|
interface Props { |
|
|
|
interface Props { |
|
|
|
modelValue: string | string[] | undefined |
|
|
|
modelValue: string | string[] | undefined |
|
|
@ -16,6 +16,8 @@ const { isMysql } = useProject() |
|
|
|
const column = inject(ColumnInj) |
|
|
|
const column = inject(ColumnInj) |
|
|
|
const isForm = inject<boolean>('isForm', false) |
|
|
|
const isForm = inject<boolean>('isForm', false) |
|
|
|
const editEnabled = inject(EditModeInj, ref(false)) |
|
|
|
const editEnabled = inject(EditModeInj, ref(false)) |
|
|
|
|
|
|
|
const active = inject(ActiveCellInj, ref(false)) |
|
|
|
|
|
|
|
|
|
|
|
const selectedIds = ref<string[]>([]) |
|
|
|
const selectedIds = ref<string[]>([]) |
|
|
|
|
|
|
|
|
|
|
|
const options = computed(() => { |
|
|
|
const options = computed(() => { |
|
|
@ -31,7 +33,7 @@ const options = computed(() => { |
|
|
|
|
|
|
|
|
|
|
|
const vModel = computed({ |
|
|
|
const vModel = computed({ |
|
|
|
get: () => selectedIds.value.map((el) => options.value.find((op: SelectOptionType) => op.id === el).title), |
|
|
|
get: () => selectedIds.value.map((el) => options.value.find((op: SelectOptionType) => op.id === el).title), |
|
|
|
set: (val) => emit('update:modelValue', val.join(',')), |
|
|
|
set: (val) => emit('update:modelValue', val.length === 0 ? null : val.join(',')), |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const selectedTitles = computed(() => |
|
|
|
const selectedTitles = computed(() => |
|
|
@ -59,7 +61,7 @@ onMounted(() => { |
|
|
|
|
|
|
|
|
|
|
|
watch( |
|
|
|
watch( |
|
|
|
() => modelValue, |
|
|
|
() => modelValue, |
|
|
|
(n, _o) => { |
|
|
|
(_n, _o) => { |
|
|
|
selectedIds.value = selectedTitles.value.map((el) => { |
|
|
|
selectedIds.value = selectedTitles.value.map((el) => { |
|
|
|
return options.value.find((op: SelectOptionType) => op.title === el).id |
|
|
|
return options.value.find((op: SelectOptionType) => op.title === el).id |
|
|
|
}) |
|
|
|
}) |
|
|
@ -87,7 +89,7 @@ watch( |
|
|
|
v-if="options.find((el: SelectOptionType) => el.title === val)" |
|
|
|
v-if="options.find((el: SelectOptionType) => el.title === val)" |
|
|
|
class="rounded-tag" |
|
|
|
class="rounded-tag" |
|
|
|
:color="options.find((el: SelectOptionType) => el.title === val).color" |
|
|
|
:color="options.find((el: SelectOptionType) => el.title === val).color" |
|
|
|
:closable="editEnabled" |
|
|
|
:closable="active && (vModel.length > 1 || !column?.rqd)" |
|
|
|
@close="onClose" |
|
|
|
@close="onClose" |
|
|
|
> |
|
|
|
> |
|
|
|
<span class="text-slate-500">{{ val }}</span> |
|
|
|
<span class="text-slate-500">{{ val }}</span> |
|
|
|