Merge pull request #2504 from hcengineering/show-filter-items-current-space

Allow to show filter items only for current space
This commit is contained in:
Denis Bunakalya 2023-01-18 12:12:47 +03:00 committed by GitHub
commit a02d882774
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 45 additions and 17 deletions

View File

@ -1,4 +1,5 @@
<script lang="ts">
import { Ref, Space } from '@hcengineering/core'
import { Icon, TabList, SearchEdit } from '@hcengineering/ui'
import { Viewlet } from '@hcengineering/view'
import { FilterButton, setActiveViewletId } from '@hcengineering/view-resources'
@ -6,6 +7,7 @@
import { WithLookup } from '@hcengineering/core'
import { deviceOptionsStore as deviceInfo } from '@hcengineering/ui'
export let space: Ref<Space> | undefined = undefined
export let viewlet: WithLookup<Viewlet> | undefined
export let viewlets: WithLookup<Viewlet>[] = []
export let label: string
@ -32,7 +34,7 @@
<div class="ac-header__icon"><Icon icon={tracker.icon.Issues} size={'small'} /></div>
<span class="ac-header__title">{label}</span>
{/if}
<div class="ml-4"><FilterButton _class={tracker.class.Issue} /></div>
<div class="ml-4"><FilterButton _class={tracker.class.Issue} {space} /></div>
</div>
<SearchEdit bind:value={search} on:change={() => {}} />
</div>

View File

@ -11,10 +11,10 @@
import IssuesContent from './IssuesContent.svelte'
import IssuesHeader from './IssuesHeader.svelte'
export let space: Ref<Space> | undefined = undefined
export let query: DocumentQuery<Issue> = {}
export let title: IntlString | undefined = undefined
export let label: string = ''
export let space: Ref<Space> | undefined
export let panelWidth: number = 0
@ -100,7 +100,7 @@
$: viewOptions = getViewOptions(viewlet)
</script>
<IssuesHeader {viewlets} {label} bind:viewlet bind:search showLabelSelector={$$slots.label_selector}>
<IssuesHeader {viewlets} {label} {space} bind:viewlet bind:search showLabelSelector={$$slots.label_selector}>
<svelte:fragment slot="label_selector">
<slot name="label_selector" />
</svelte:fragment>

View File

@ -23,4 +23,4 @@
const query: DocumentQuery<IssueTemplate> = { space: currentSpace }
</script>
<IssueTemplatesView {query} title={tracker.string.IssueTemplates} />
<IssueTemplatesView {query} space={currentSpace} title={tracker.string.IssueTemplates} />

View File

@ -1,5 +1,5 @@
<script lang="ts">
import { DocumentQuery, WithLookup } from '@hcengineering/core'
import { DocumentQuery, WithLookup, Ref, Space } from '@hcengineering/core'
import { IntlString, translate } from '@hcengineering/platform'
import { getClient } from '@hcengineering/presentation'
import { IssueTemplate } from '@hcengineering/tracker'
@ -12,6 +12,7 @@
import CreateIssueTemplate from './CreateIssueTemplate.svelte'
import IssueTemplatesContent from './IssueTemplatesContent.svelte'
export let space: Ref<Space> | undefined = undefined
export let query: DocumentQuery<IssueTemplate> = {}
export let title: IntlString | undefined = undefined
export let label: string = ''
@ -72,7 +73,7 @@
$: viewOptions = getViewOptions(viewlet)
</script>
<IssuesHeader {viewlets} {label} bind:viewlet bind:search showLabelSelector={$$slots.label_selector}>
<IssuesHeader {space} {viewlets} {label} bind:viewlet bind:search showLabelSelector={$$slots.label_selector}>
<svelte:fragment slot="label_selector">
<slot name="label_selector" />
</svelte:fragment>

View File

@ -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

View File

@ -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) => {

View File

@ -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)

View File

@ -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) {

View File

@ -13,7 +13,7 @@
// limitations under the License.
-->
<script lang="ts">
import { Class, Doc, DocumentQuery, Ref, WithLookup } from '@hcengineering/core'
import { Class, Doc, DocumentQuery, Ref, WithLookup, Space } from '@hcengineering/core'
import { Asset, IntlString } from '@hcengineering/platform'
import { createQuery, getClient } from '@hcengineering/presentation'
import {
@ -32,6 +32,7 @@
import { FilterBar, FilterButton, getViewOptions, ViewletSettingButton } from '@hcengineering/view-resources'
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
@ -100,7 +101,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} />