Skip to content

Commit

Permalink
UBER-182: Fix status object filter (#3250)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
  • Loading branch information
haiodo committed May 24, 2023
1 parent 635cc44 commit 4d8412b
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions plugins/view-resources/src/components/filter/ObjectFilter.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@
<script lang="ts">
import core, { Doc, FindResult, getObjectValue, Ref, RefTo, SortingOrder, Space, Status } from '@hcengineering/core'
import { translate } from '@hcengineering/platform'
import presentation, { getClient } from '@hcengineering/presentation'
import presentation, { getClient, statusStore } from '@hcengineering/presentation'
import ui, {
addNotification,
deviceOptionsStore,
EditWithIcon,
Icon,
IconCheck,
IconSearch,
deviceOptionsStore,
Label,
Loading,
resizeObserver,
EditWithIcon
resizeObserver
} from '@hcengineering/ui'
import { Filter } from '@hcengineering/view'
import { createEventDispatcher } from 'svelte'
import view from '../../plugin'
import { FILTER_DEBOUNCE_MS, sortFilterValues } from '../../filter'
import view from '../../plugin'
import { buildConfigLookup, getPresenter } from '../../utils'
import FilterRemovedNotification from './FilterRemovedNotification.svelte'
Expand Down Expand Up @@ -116,8 +116,7 @@
}
if (values.length !== targets.size) {
const oldSize = filter.value.length
const set = new Set(values.map((p) => p?._id))
filter.value = filter.value.filter((p) => set.has(p))
filter.value = filter.value.filter((p) => targets.has(p))
const removed = oldSize - (filter.value.length ?? 0)
if (removed > 0) {
onChange(filter)
Expand All @@ -130,6 +129,14 @@
}
function isSelected (value: Doc | undefined | null, values: any[]): boolean {
if (isStatus) {
const statusSet = new Set(
$statusStore
.filter((it) => it.name.trim().toLocaleLowerCase() === (value as Status)?.name?.trim()?.toLocaleLowerCase())
.map((it) => it._id)
)
return values.some((it) => statusSet.has(it))
}
return values.includes(value?._id ?? value)
}
Expand Down

0 comments on commit 4d8412b

Please sign in to comment.