fix(filter): make other filters are not available for project selection
This commit is contained in:
parent
8b8da40265
commit
3f42ce2b34
@ -20,11 +20,20 @@ import type {IProject} from '@/modelTypes/IProject'
|
|||||||
import ProjectService from '@/services/project'
|
import ProjectService from '@/services/project'
|
||||||
import {includesById} from '@/helpers/utils'
|
import {includesById} from '@/helpers/utils'
|
||||||
|
|
||||||
|
type ProjectFilterFunc = (p: IProject) => boolean
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: Array as PropType<IProject[]>,
|
type: Array as PropType<IProject[]>,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
|
projectFilter: {
|
||||||
|
type: Function as PropType<ProjectFilterFunc>,
|
||||||
|
default: () => {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
return (_: IProject) => true
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'update:modelValue', value: IProject[]): void
|
(e: 'update:modelValue', value: IProject[]): void
|
||||||
@ -58,6 +67,8 @@ async function findProjects(query: string) {
|
|||||||
const response = await projectService.getAll({}, {s: query}) as IProject[]
|
const response = await projectService.getAll({}, {s: query}) as IProject[]
|
||||||
|
|
||||||
// Filter selected items from the results
|
// Filter selected items from the results
|
||||||
foundProjects.value = response.filter(({id}) => !includesById(projects.value, id))
|
foundProjects.value = response
|
||||||
|
.filter(({id}) => !includesById(projects.value, id))
|
||||||
|
.filter(props.projectFilter)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
@ -164,6 +164,7 @@
|
|||||||
v-model="entities.projects"
|
v-model="entities.projects"
|
||||||
@select="changeMultiselectFilter('projects', 'project_id')"
|
@select="changeMultiselectFilter('projects', 'project_id')"
|
||||||
@remove="changeMultiselectFilter('projects', 'project_id')"
|
@remove="changeMultiselectFilter('projects', 'project_id')"
|
||||||
|
:project-filter="p => p.id > 0"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user