mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-23 05:53:09 +03:00
Allow to show filter items only for current space
Signed-off-by: Denis Bunakalya <denis.bunakalya@xored.com>
This commit is contained in:
parent
1c01925ed4
commit
ef8c626d92
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { Class, Doc, Ref } from '@hcengineering/core'
|
||||
import { Class, Doc, Ref, Space } from '@hcengineering/core'
|
||||
import { getClient } from '@hcengineering/presentation'
|
||||
import { Button, eventToHTMLElement, IconAdd, IconClose, Icon, showPopup, Label } from '@hcengineering/ui'
|
||||
import { Filter } from '@hcengineering/view'
|
||||
@ -22,6 +22,7 @@
|
||||
import FilterTypePopup from './FilterTypePopup.svelte'
|
||||
|
||||
export let _class: Ref<Class<Doc>> | undefined
|
||||
export let space: Ref<Space> | undefined = undefined
|
||||
|
||||
const client = getClient()
|
||||
const hierarchy = client.getHierarchy()
|
||||
@ -36,6 +37,7 @@
|
||||
FilterTypePopup,
|
||||
{
|
||||
_class,
|
||||
space,
|
||||
target,
|
||||
index: 1,
|
||||
onChange
|
||||
|
@ -13,7 +13,18 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import core, { AnyAttribute, ArrOf, AttachedDoc, Class, Collection, Doc, Ref, RefTo, Type } from '@hcengineering/core'
|
||||
import core, {
|
||||
AnyAttribute,
|
||||
ArrOf,
|
||||
AttachedDoc,
|
||||
Class,
|
||||
Collection,
|
||||
Doc,
|
||||
Ref,
|
||||
RefTo,
|
||||
Type,
|
||||
Space
|
||||
} from '@hcengineering/core'
|
||||
import { getClient } from '@hcengineering/presentation'
|
||||
import { closePopup, closeTooltip, Icon, Label, showPopup, Submenu, resizeObserver } from '@hcengineering/ui'
|
||||
import { Filter, KeyFilter } from '@hcengineering/view'
|
||||
@ -22,6 +33,7 @@
|
||||
import view from '../../plugin'
|
||||
|
||||
export let _class: Ref<Class<Doc>>
|
||||
export let space: Ref<Space> | undefined = undefined
|
||||
export let target: HTMLElement
|
||||
export let filter: Filter | undefined
|
||||
export let index: number
|
||||
@ -144,6 +156,7 @@
|
||||
type.component,
|
||||
{
|
||||
_class,
|
||||
space,
|
||||
filter: filter || {
|
||||
key: type,
|
||||
value: [],
|
||||
@ -183,6 +196,7 @@
|
||||
const targetClass = (hierarchy.getAttribute(_class, type.key).type as RefTo<Doc>).to
|
||||
return {
|
||||
_class: targetClass,
|
||||
space,
|
||||
index,
|
||||
target,
|
||||
onChange: (e: Filter | undefined) => {
|
||||
|
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { Doc, FindResult, getObjectValue, RefTo, SortingOrder } from '@hcengineering/core'
|
||||
import { Doc, FindResult, getObjectValue, RefTo, SortingOrder, Ref, Space } from '@hcengineering/core'
|
||||
import { translate } from '@hcengineering/platform'
|
||||
import presentation, { getClient } from '@hcengineering/presentation'
|
||||
import type { State } from '@hcengineering/task'
|
||||
@ -25,6 +25,7 @@
|
||||
import { buildConfigLookup, getPresenter } from '../../utils'
|
||||
|
||||
export let filter: Filter
|
||||
export let space: Ref<Space> | undefined = undefined
|
||||
export let onChange: (e: Filter) => void
|
||||
|
||||
const client = getClient()
|
||||
@ -68,7 +69,9 @@
|
||||
await objectsPromise
|
||||
}
|
||||
targets.clear()
|
||||
const baseObjects = await client.findAll(filter.key._class, {}, { projection: { [filter.key.key]: 1 } })
|
||||
const baseObjects = await client.findAll(filter.key._class, space ? { space } : {}, {
|
||||
projection: { [filter.key.key]: 1 }
|
||||
})
|
||||
for (const object of baseObjects) {
|
||||
const value = getObjectValue(filter.key.key, object) ?? undefined
|
||||
targets.set(value, (targets.get(value) ?? 0) + 1)
|
||||
@ -84,7 +87,7 @@
|
||||
_id: { $in: Array.from(targets.keys()) }
|
||||
}
|
||||
const options = clazz.sortingKey !== undefined ? { sort: { [clazz.sortingKey]: SortingOrder.Ascending } } : {}
|
||||
objectsPromise = client.findAll(targetClass, resultQuery, options)
|
||||
objectsPromise = client.findAll(targetClass, { ...resultQuery, ...(space ? { space } : {}) }, options)
|
||||
values = await objectsPromise
|
||||
if (targets.has(undefined)) {
|
||||
values.unshift(undefined)
|
||||
|
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { Class, Doc, FindResult, getObjectValue, Ref, SortingOrder } from '@hcengineering/core'
|
||||
import { Class, Doc, FindResult, getObjectValue, Ref, SortingOrder, Space } from '@hcengineering/core'
|
||||
import { translate } from '@hcengineering/platform'
|
||||
import presentation, { getClient } from '@hcengineering/presentation'
|
||||
import ui, { Button, CheckBox, Label, Loading, resizeObserver, deviceOptionsStore } from '@hcengineering/ui'
|
||||
@ -24,6 +24,7 @@
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
|
||||
export let _class: Ref<Class<Doc>>
|
||||
export let space: Ref<Space> | undefined = undefined
|
||||
export let filter: Filter
|
||||
export let onChange: (e: Filter) => void
|
||||
|
||||
@ -59,10 +60,14 @@
|
||||
prefix = attr.attributeOf + '.'
|
||||
console.log('prefix', prefix)
|
||||
}
|
||||
objectsPromise = client.findAll(_class, resultQuery, {
|
||||
sort: { [filter.key.key]: SortingOrder.Ascending },
|
||||
projection: { [prefix + filter.key.key]: 1 }
|
||||
})
|
||||
objectsPromise = client.findAll(
|
||||
_class,
|
||||
{ ...resultQuery, ...(space ? { space } : {}) },
|
||||
{
|
||||
sort: { [filter.key.key]: SortingOrder.Ascending },
|
||||
projection: { [prefix + filter.key.key]: 1 }
|
||||
}
|
||||
)
|
||||
const res = await objectsPromise
|
||||
|
||||
for (const object of res) {
|
||||
|
@ -13,7 +13,7 @@
|
||||
// limitations under the License.
|
||||
-->
|
||||
<script lang="ts">
|
||||
import { Class, Doc, DocumentQuery, Ref } from '@hcengineering/core'
|
||||
import { Class, Doc, DocumentQuery, Ref, Space } from '@hcengineering/core'
|
||||
import { Asset, getEmbeddedLabel, IntlString } from '@hcengineering/platform'
|
||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||
import {
|
||||
@ -32,6 +32,7 @@
|
||||
import SourcePresenter from './search/SourcePresenter.svelte'
|
||||
|
||||
export let _class: Ref<Class<Doc>>
|
||||
export let space: Ref<Space> | undefined = undefined
|
||||
export let icon: Asset
|
||||
export let label: IntlString
|
||||
export let createLabel: IntlString | undefined
|
||||
@ -94,7 +95,7 @@
|
||||
<div class="ac-header__wrap-title mr-3">
|
||||
<span class="ac-header__icon"><Icon {icon} size={'small'} /></span>
|
||||
<span class="ac-header__title"><Label {label} /></span>
|
||||
<div class="ml-4"><FilterButton {_class} /></div>
|
||||
<div class="ml-4"><FilterButton {_class} {space} /></div>
|
||||
</div>
|
||||
|
||||
<SearchEdit bind:value={search} />
|
||||
|
Loading…
Reference in New Issue
Block a user