EQMS-1569: fixed ui crash when editing product members (#9229)

Signed-off-by: Victor Ilyushchenko <alt13ri@gmail.com>
This commit is contained in:
Victor Ilyushchenko
2025-06-13 18:11:14 +03:00
committed by GitHub
parent c65d2d957f
commit 89e4bfc6d9
@@ -24,7 +24,7 @@
import UserBoxList from './UserBoxList.svelte'
export let label: IntlString
export let value: AccountUuid[] | undefined
export let value: AccountUuid | AccountUuid[] | undefined
export let onChange: ((refs: AccountUuid[]) => void | Promise<void>) | undefined
export let readonly = false
export let kind: ButtonKind = 'link'
@@ -34,13 +34,16 @@
export let excludeItems: Ref<Person>[] = []
export let emptyLabel: IntlString | undefined = undefined
export let allowGuests: boolean = false
export let attributeKey: string | undefined = undefined
$: accounts = typeof value === 'string' ? [value] : value ?? []
let timer: any = null
const client = getClient()
let update: (() => Promise<void>) | undefined
$: valueByPersonRef = new Map(
(value ?? []).map((p) => {
$: accountsByPersonRef = new Map(
accounts.map((p) => {
const person = $employeeRefByAccountUuidStore.get(p)
if (person === undefined) {
@@ -60,7 +63,7 @@
const newAccounts: AccountUuid[] = []
for (const person of newPersons) {
const acc = valueByPersonRef.get(person)
const acc = accountsByPersonRef.get(person)
if (acc !== undefined) {
newAccounts.push(acc)
} else {
@@ -86,7 +89,7 @@
void update?.()
})
$: employees = (value ?? []).map((p) => $employeeRefByAccountUuidStore.get(p)).filter(notEmpty)
$: employees = accounts.map((p) => $employeeRefByAccountUuidStore.get(p)).filter(notEmpty)
$: docQuery =
excludeItems.length === 0 && includeItems.length === 0
? {}