feat: remove props destructuring from FilterInput
This commit is contained in:
parent
ddc8b416c0
commit
fd6692ea1a
@ -23,17 +23,16 @@ import {
|
|||||||
import {useDebounceFn} from '@vueuse/core'
|
import {useDebounceFn} from '@vueuse/core'
|
||||||
import {createRandomID} from '@/helpers/randomId'
|
import {createRandomID} from '@/helpers/randomId'
|
||||||
|
|
||||||
const {
|
const props = defineProps<{
|
||||||
modelValue,
|
|
||||||
projectId,
|
|
||||||
inputLabel = undefined,
|
|
||||||
} = defineProps<{
|
|
||||||
modelValue: string,
|
modelValue: string,
|
||||||
projectId?: number,
|
projectId?: number,
|
||||||
inputLabel?: string,
|
inputLabel?: string,
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue', 'blur'])
|
const emit = defineEmits<{
|
||||||
|
'update:modelValue': [value: string],
|
||||||
|
'blur': [],
|
||||||
|
}>()
|
||||||
|
|
||||||
const userService = new UserService()
|
const userService = new UserService()
|
||||||
const projectUserService = new ProjectUserService()
|
const projectUserService = new ProjectUserService()
|
||||||
@ -49,9 +48,9 @@ const {
|
|||||||
const id = ref(createRandomID())
|
const id = ref(createRandomID())
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => modelValue,
|
() => props.modelValue,
|
||||||
() => {
|
() => {
|
||||||
filterQuery.value = modelValue
|
filterQuery.value = props.modelValue
|
||||||
},
|
},
|
||||||
{immediate: true},
|
{immediate: true},
|
||||||
)
|
)
|
||||||
@ -59,7 +58,7 @@ watch(
|
|||||||
watch(
|
watch(
|
||||||
() => filterQuery.value,
|
() => filterQuery.value,
|
||||||
() => {
|
() => {
|
||||||
if (filterQuery.value !== modelValue) {
|
if (filterQuery.value !== props.modelValue) {
|
||||||
emit('update:modelValue', filterQuery.value)
|
emit('update:modelValue', filterQuery.value)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -204,6 +203,7 @@ const autocompleteResultType = ref<'labels' | 'assignees' | 'projects' | null>(n
|
|||||||
const autocompleteResults = ref<any[]>([])
|
const autocompleteResults = ref<any[]>([])
|
||||||
|
|
||||||
function handleFieldInput() {
|
function handleFieldInput() {
|
||||||
|
if (!filterInput.value) return
|
||||||
const cursorPosition = filterInput.value.selectionStart
|
const cursorPosition = filterInput.value.selectionStart
|
||||||
const textUpToCursor = filterQuery.value.substring(0, cursorPosition)
|
const textUpToCursor = filterQuery.value.substring(0, cursorPosition)
|
||||||
autocompleteResults.value = []
|
autocompleteResults.value = []
|
||||||
@ -230,15 +230,15 @@ function handleFieldInput() {
|
|||||||
}
|
}
|
||||||
if (matched.startsWith('assignee')) {
|
if (matched.startsWith('assignee')) {
|
||||||
autocompleteResultType.value = 'assignees'
|
autocompleteResultType.value = 'assignees'
|
||||||
if (projectId) {
|
if (props.projectId) {
|
||||||
projectUserService.getAll({projectId}, {s: search})
|
projectUserService.getAll({projectId: props.projectId}, {s: search})
|
||||||
.then(users => autocompleteResults.value = users.length > 1 ? users : [])
|
.then(users => autocompleteResults.value = users.length > 1 ? users : [])
|
||||||
} else {
|
} else {
|
||||||
userService.getAll({}, {s: search})
|
userService.getAll({}, {s: search})
|
||||||
.then(users => autocompleteResults.value = users.length > 1 ? users : [])
|
.then(users => autocompleteResults.value = users.length > 1 ? users : [])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!projectId && matched.startsWith('project')) {
|
if (!props.projectId && matched.startsWith('project')) {
|
||||||
autocompleteResultType.value = 'projects'
|
autocompleteResultType.value = 'projects'
|
||||||
autocompleteResults.value = projectStore.searchProject(search)
|
autocompleteResults.value = projectStore.searchProject(search)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user