Allow filtering assignee list (#2708)

Signed-off-by: Sergei Ogorelkov <sergei.ogorelkov@xored.com>
This commit is contained in:
Sergei Ogorelkov 2023-03-03 22:56:57 +06:00 committed by GitHub
parent 126098d2ba
commit 99bef1d311
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -48,6 +48,7 @@
export let prevAssigned: Ref<Employee>[] | undefined = [] export let prevAssigned: Ref<Employee>[] | undefined = []
export let projectLead: Ref<Employee> | undefined = undefined export let projectLead: Ref<Employee> | undefined = undefined
export let projectMembers: Ref<Employee>[] | undefined = [] export let projectMembers: Ref<Employee>[] | undefined = []
export let allowDeselect = true
export let titleDeselect: IntlString | undefined = undefined export let titleDeselect: IntlString | undefined = undefined
export let readonly = false export let readonly = false
export let kind: ButtonKind = 'no-border' export let kind: ButtonKind = 'no-border'
@ -95,6 +96,7 @@
icon, icon,
selected: value, selected: value,
placeholder, placeholder,
allowDeselect,
titleDeselect titleDeselect
}, },
!$$slots.content ? container : getEventPositionElement(ev), !$$slots.content ? container : getEventPositionElement(ev),

View File

@ -44,6 +44,7 @@
export let prevAssigned: Ref<Employee>[] | undefined = [] export let prevAssigned: Ref<Employee>[] | undefined = []
export let projectLead: Ref<Employee> | undefined = undefined export let projectLead: Ref<Employee> | undefined = undefined
export let projectMembers: Ref<Employee>[] | undefined = [] export let projectMembers: Ref<Employee>[] | undefined = []
export let allowDeselect = true
export let titleDeselect: IntlString | undefined export let titleDeselect: IntlString | undefined
export let placeholder: IntlString = presentation.string.Search export let placeholder: IntlString = presentation.string.Search
export let ignoreUsers: Ref<Person>[] = [] export let ignoreUsers: Ref<Person>[] = []
@ -72,7 +73,10 @@
{ {
...(docQuery ?? {}), ...(docQuery ?? {}),
[searchField]: { $like: '%' + search + '%' }, [searchField]: { $like: '%' + search + '%' },
_id: { $nin: ignoreUsers } _id: {
...(typeof docQuery?._id === 'object' ? docQuery._id : {}),
$nin: ignoreUsers
}
}, },
(result) => { (result) => {
objects = result objects = result
@ -117,7 +121,7 @@
async function handleSelection (evt: Event | undefined, selection: number): Promise<void> { async function handleSelection (evt: Event | undefined, selection: number): Promise<void> {
const person = contacts[selection] const person = contacts[selection]
selected = person._id === selected ? undefined : person._id selected = allowDeselect && person._id === selected ? undefined : person._id
dispatch('close', selected !== undefined ? person : undefined) dispatch('close', selected !== undefined ? person : undefined)
} }
@ -232,7 +236,7 @@
handleSelection(undefined, item) handleSelection(undefined, item)
}} }}
> >
{#if selected} {#if allowDeselect && selected}
<div class="icon"> <div class="icon">
{#if obj._id === selected} {#if obj._id === selected}
<div bind:this={selectedDiv}> <div bind:this={selectedDiv}>