Minor Filter fixes (#1825)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2022-05-22 20:15:44 +07:00 committed by GitHub
parent c746d73a85
commit 9fb00d4db2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 4 deletions

View File

@ -120,7 +120,7 @@
</script>
{#if visible}
<div class="flex pl-4 pr-4">
<div class="flex-row-center pl-4 pr-4">
{#each filters as filter, i}
<FilterSection
{_class}

View File

@ -81,7 +81,7 @@
: {
_id: { $in: Array.from(targets.keys()) }
}
values = await client.findAll(targetClass, resultQuery, { projection: { _id: 1 } })
values = await client.findAll(targetClass, resultQuery)
if (targets.has(undefined)) {
values.unshift(undefined)
}

View File

@ -72,7 +72,15 @@
...query
}
: query
const res = await client.findAll(_class, resultQuery, { projection: { [filter.key.key]: 1 } })
let prefix = ''
const attr = client.getHierarchy().getAttribute(_class, filter.key.key)
if (client.getHierarchy().isMixin(attr.attributeOf)) {
prefix = attr.attributeOf + '.'
console.log('prefix', prefix)
}
const res = await client.findAll(_class, resultQuery, { projection: { [prefix + filter.key.key]: 1 } })
for (const object of res) {
const realValue = getObjectValue(filter.key.key, object)
const value = typeof realValue === 'string' ? realValue.trim().toUpperCase() : realValue ?? undefined
@ -123,6 +131,7 @@
<div class="box">
{#await promise then attribute}
{#each Array.from(values.keys()) as value}
{@const realValue = [...(realValues.get(value) ?? [])][0]}
<button
class="menu-item"
on:click={() => {
@ -135,7 +144,11 @@
<CheckBox checked={isSelected(value, selectedValues)} primary />
</div>
{#if value}
<svelte:component this={attribute.presenter} {value} {...attribute.props} />
<svelte:component
this={attribute.presenter}
value={typeof value === 'string' ? realValue : value}
{...attribute.props}
/>
{:else}
<Label label={ui.string.NotSelected} />
{/if}