|
|
@ -19,6 +19,7 @@ import { |
|
|
|
useEventListener, |
|
|
|
useEventListener, |
|
|
|
useMetas, |
|
|
|
useMetas, |
|
|
|
useProject, |
|
|
|
useProject, |
|
|
|
|
|
|
|
useRoles, |
|
|
|
useSelectedCellKeyupListener, |
|
|
|
useSelectedCellKeyupListener, |
|
|
|
watch, |
|
|
|
watch, |
|
|
|
} from '#imports' |
|
|
|
} from '#imports' |
|
|
@ -57,6 +58,8 @@ const { $api } = useNuxtApp() |
|
|
|
|
|
|
|
|
|
|
|
const { getMeta } = useMetas() |
|
|
|
const { getMeta } = useMetas() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { hasRole } = useRoles() |
|
|
|
|
|
|
|
|
|
|
|
const { isPg, isMysql } = useProject() |
|
|
|
const { isPg, isMysql } = useProject() |
|
|
|
|
|
|
|
|
|
|
|
// a variable to keep newly created options value |
|
|
|
// a variable to keep newly created options value |
|
|
@ -80,6 +83,10 @@ const isOptionMissing = computed(() => { |
|
|
|
return (options.value ?? []).every((op) => op.title !== searchVal.value) |
|
|
|
return (options.value ?? []).every((op) => op.title !== searchVal.value) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const hasEditRoles = computed(() => hasRole('owner', true) || hasRole('creator', true) || hasRole('editor', true)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const editAllowed = computed(() => hasEditRoles.value && (active.value || editable.value)) |
|
|
|
|
|
|
|
|
|
|
|
const vModel = computed({ |
|
|
|
const vModel = computed({ |
|
|
|
get: () => { |
|
|
|
get: () => { |
|
|
|
const selected = selectedIds.value.reduce((acc, id) => { |
|
|
|
const selected = selectedIds.value.reduce((acc, id) => { |
|
|
@ -154,11 +161,13 @@ watch( |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
watch(isOpen, (n, _o) => { |
|
|
|
watch(isOpen, (n, _o) => { |
|
|
|
|
|
|
|
if (editAllowed.value) { |
|
|
|
if (!n) { |
|
|
|
if (!n) { |
|
|
|
aselect.value?.$el?.querySelector('input')?.blur() |
|
|
|
aselect.value?.$el?.querySelector('input')?.blur() |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
aselect.value?.$el?.querySelector('input')?.focus() |
|
|
|
aselect.value?.$el?.querySelector('input')?.focus() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
useSelectedCellKeyupListener(active, (e) => { |
|
|
|
useSelectedCellKeyupListener(active, (e) => { |
|
|
@ -167,7 +176,7 @@ useSelectedCellKeyupListener(active, (e) => { |
|
|
|
isOpen.value = false |
|
|
|
isOpen.value = false |
|
|
|
break |
|
|
|
break |
|
|
|
case 'Enter': |
|
|
|
case 'Enter': |
|
|
|
if (active.value && !isOpen.value) { |
|
|
|
if (editAllowed.value && active.value && !isOpen.value) { |
|
|
|
isOpen.value = true |
|
|
|
isOpen.value = true |
|
|
|
} |
|
|
|
} |
|
|
|
break |
|
|
|
break |
|
|
@ -179,6 +188,10 @@ useSelectedCellKeyupListener(active, (e) => { |
|
|
|
// skip |
|
|
|
// skip |
|
|
|
break |
|
|
|
break |
|
|
|
default: |
|
|
|
default: |
|
|
|
|
|
|
|
if (!editAllowed.value) { |
|
|
|
|
|
|
|
e.preventDefault() |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
} |
|
|
|
// toggle only if char key pressed |
|
|
|
// toggle only if char key pressed |
|
|
|
if (!(e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) && e.key?.length === 1) { |
|
|
|
if (!(e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) && e.key?.length === 1) { |
|
|
|
e.stopPropagation() |
|
|
|
e.stopPropagation() |
|
|
@ -272,14 +285,14 @@ const onTagClick = (e: Event, onClose: Function) => { |
|
|
|
:bordered="false" |
|
|
|
:bordered="false" |
|
|
|
clear-icon |
|
|
|
clear-icon |
|
|
|
show-search |
|
|
|
show-search |
|
|
|
:show-arrow="!readOnly" |
|
|
|
:show-arrow="hasEditRoles && !readOnly && (editable || (active && vModel.length === 0))" |
|
|
|
:open="isOpen && (active || editable)" |
|
|
|
:open="isOpen && (active || editable)" |
|
|
|
:disabled="readOnly" |
|
|
|
:disabled="readOnly" |
|
|
|
:class="{ '!ml-[-8px]': readOnly }" |
|
|
|
:class="{ '!ml-[-8px]': readOnly, 'caret-transparent': !hasEditRoles }" |
|
|
|
:dropdown-class-name="`nc-dropdown-multi-select-cell ${isOpen ? 'active' : ''}`" |
|
|
|
:dropdown-class-name="`nc-dropdown-multi-select-cell ${isOpen ? 'active' : ''}`" |
|
|
|
@search="search" |
|
|
|
@search="search" |
|
|
|
@keydown.stop |
|
|
|
@keydown.stop |
|
|
|
@click="isOpen = (active || editable) && !isOpen" |
|
|
|
@click="isOpen = editAllowed && !isOpen" |
|
|
|
> |
|
|
|
> |
|
|
|
<a-select-option |
|
|
|
<a-select-option |
|
|
|
v-for="op of options" |
|
|
|
v-for="op of options" |
|
|
@ -303,7 +316,11 @@ const onTagClick = (e: Event, onClose: Function) => { |
|
|
|
</a-tag> |
|
|
|
</a-tag> |
|
|
|
</a-select-option> |
|
|
|
</a-select-option> |
|
|
|
|
|
|
|
|
|
|
|
<a-select-option v-if="searchVal && isOptionMissing && !isPublic" :key="searchVal" :value="searchVal"> |
|
|
|
<a-select-option |
|
|
|
|
|
|
|
v-if="searchVal && isOptionMissing && !isPublic && (hasRole('owner', true) || hasRole('creator', true))" |
|
|
|
|
|
|
|
:key="searchVal" |
|
|
|
|
|
|
|
:value="searchVal" |
|
|
|
|
|
|
|
> |
|
|
|
<div class="flex gap-2 text-gray-500 items-center h-full"> |
|
|
|
<div class="flex gap-2 text-gray-500 items-center h-full"> |
|
|
|
<MdiPlusThick class="min-w-4" /> |
|
|
|
<MdiPlusThick class="min-w-4" /> |
|
|
|
<div class="text-xs whitespace-normal"> |
|
|
|
<div class="text-xs whitespace-normal"> |
|
|
@ -318,7 +335,7 @@ const onTagClick = (e: Event, onClose: Function) => { |
|
|
|
class="rounded-tag nc-selected-option" |
|
|
|
class="rounded-tag nc-selected-option" |
|
|
|
:style="{ display: 'flex', alignItems: 'center' }" |
|
|
|
:style="{ display: 'flex', alignItems: 'center' }" |
|
|
|
:color="options.find((el) => el.title === val)?.color" |
|
|
|
:color="options.find((el) => el.title === val)?.color" |
|
|
|
:closable="(active || editable) && (vModel.length > 1 || !column?.rqd)" |
|
|
|
:closable="editAllowed && (active || editable) && (vModel.length > 1 || !column?.rqd)" |
|
|
|
:close-icon="h(MdiCloseCircle, { class: ['ms-close-icon'] })" |
|
|
|
:close-icon="h(MdiCloseCircle, { class: ['ms-close-icon'] })" |
|
|
|
@click="onTagClick($event, onClose)" |
|
|
|
@click="onTagClick($event, onClose)" |
|
|
|
@close="onClose" |
|
|
|
@close="onClose" |
|
|
|