refactor: removed contact store from MultiSelectInput
This commit is contained in:
parent
d37db923a3
commit
5d4272a572
@ -93,7 +93,6 @@ import {
|
||||
ComboboxOption,
|
||||
} from '@headlessui/vue'
|
||||
import UserAvatar from '@/components/UserAvatar.vue'
|
||||
import { contactsStore } from '@/stores/contacts'
|
||||
import { Popover, createResource } from 'frappe-ui'
|
||||
import { ref, computed, nextTick } from 'vue'
|
||||
import { watchDebounced } from '@vueuse/core'
|
||||
@ -111,8 +110,6 @@ const props = defineProps({
|
||||
|
||||
const values = defineModel()
|
||||
|
||||
const { getContactByName } = contactsStore()
|
||||
|
||||
const emails = ref([])
|
||||
const search = ref(null)
|
||||
const error = ref(null)
|
||||
@ -153,13 +150,13 @@ const filterOptions = createResource({
|
||||
transform: (data) => {
|
||||
let allData = data
|
||||
.filter((c) => {
|
||||
return getContactByName(c.value).email_id
|
||||
return c.description.split(', ')[1]
|
||||
})
|
||||
.map((option) => {
|
||||
let c = getContactByName(option.value)
|
||||
let email = option.description.split(', ')[1]
|
||||
return {
|
||||
label: c.full_name || c.email_id,
|
||||
value: c.email_id,
|
||||
label: option.label || email,
|
||||
value: email,
|
||||
}
|
||||
})
|
||||
return allData
|
||||
@ -222,19 +219,19 @@ const removeValue = (value) => {
|
||||
const removeLastValue = () => {
|
||||
if (query.value) return
|
||||
|
||||
let emailRef = emails.value[emails.value.length - 1].$el
|
||||
let emailRef = emails.value[emails.value.length - 1]?.$el
|
||||
if (document.activeElement === emailRef) {
|
||||
values.value.pop()
|
||||
nextTick(() => {
|
||||
if (values.value.length) {
|
||||
emailRef = emails.value[emails.value.length - 1].$el
|
||||
emailRef.focus()
|
||||
emailRef?.focus()
|
||||
} else {
|
||||
setFocus()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
emailRef.focus()
|
||||
emailRef?.focus()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user