diff --git a/models/tracker/src/index.ts b/models/tracker/src/index.ts index 0c951dfd51..5d88c0c832 100644 --- a/models/tracker/src/index.ts +++ b/models/tracker/src/index.ts @@ -541,12 +541,7 @@ export function createModel (builder: Builder): void { displayProps: { key: 'assignee', fixed: 'right' }, props: { kind: 'list', shouldShowName: false, avatarSize: 'x-small' } } - ], - options: { - lookup: { - space: tracker.class.Project - } - } + ] }, tracker.viewlet.IssueList ) @@ -1052,7 +1047,6 @@ export function createModel (builder: Builder): void { icon: tracker.icon.Issues, component: tracker.component.Issues, componentProps: { - baseQuery: { '$lookup.space.archived': false }, space: undefined, title: tracker.string.AllIssues, config: [ diff --git a/plugins/contact-resources/src/components/PersonRefPresenter.svelte b/plugins/contact-resources/src/components/PersonRefPresenter.svelte index 82a43daad6..5f05b77d05 100644 --- a/plugins/contact-resources/src/components/PersonRefPresenter.svelte +++ b/plugins/contact-resources/src/components/PersonRefPresenter.svelte @@ -59,4 +59,5 @@ {disabled} {inline} {accent} + on:accent-color /> diff --git a/plugins/tracker-resources/src/components/issues/Issues.svelte b/plugins/tracker-resources/src/components/issues/Issues.svelte index 471d05fe80..2f900fc11a 100644 --- a/plugins/tracker-resources/src/components/issues/Issues.svelte +++ b/plugins/tracker-resources/src/components/issues/Issues.svelte @@ -60,13 +60,28 @@ } ) + const archivedProjectQuery = createQuery() + let archived: Ref[] = [] + + archivedProjectQuery.query( + tracker.class.Project, + { archived: true }, + (res) => { + archived = res.map((it) => it._id) + }, + { projection: { _id: 1 } } + ) + $: queries = { all, active, backlog } $: mode = $resolvedLocationStore.query?.mode ?? undefined $: if (mode === undefined || queries[mode] === undefined) { ;[[mode]] = config } $: if (mode !== undefined) { - query = { ...queries[mode], '$lookup.space.archived': false } + query = { ...queries[mode] } + if (query?.space === undefined) { + query = { ...query, space: { $nin: archived } } + } modeSelectorProps = { config, mode, diff --git a/plugins/tracker-resources/src/components/myissues/MyIssues.svelte b/plugins/tracker-resources/src/components/myissues/MyIssues.svelte index 229e01cf04..fedfcf88f6 100644 --- a/plugins/tracker-resources/src/components/myissues/MyIssues.svelte +++ b/plugins/tracker-resources/src/components/myissues/MyIssues.svelte @@ -18,7 +18,7 @@ import { Doc, DocumentQuery, getCurrentAccount, Ref } from '@hcengineering/core' import type { IntlString } from '@hcengineering/platform' import { createQuery } from '@hcengineering/presentation' - import type { Issue } from '@hcengineering/tracker' + import type { Issue, Project } from '@hcengineering/tracker' import { resolvedLocationStore } from '@hcengineering/ui' import { IModeSelector } from '@hcengineering/ui' @@ -50,13 +50,28 @@ { sort: { _id: 1 } } ) + const archivedProjectQuery = createQuery() + let archived: Ref[] = [] + + archivedProjectQuery.query( + tracker.class.Project, + { archived: true }, + (res) => { + archived = res.map((it) => it._id) + }, + { projection: { _id: 1 } } + ) + $: queries = { assigned, created, subscribed } $: mode = $resolvedLocationStore.query?.mode ?? undefined $: if (mode === undefined || queries[mode] === undefined) { ;[[mode]] = config } $: if (mode !== undefined) { - query = { ...queries[mode], '$lookup.space.archived': false } + query = { ...queries[mode] } + if (query?.space === undefined) { + query = { ...query, space: { $nin: archived } } + } modeSelectorProps = { config, mode, diff --git a/plugins/view-resources/src/components/ViewletSelector.svelte b/plugins/view-resources/src/components/ViewletSelector.svelte index c286ae117e..a3ad056383 100644 --- a/plugins/view-resources/src/components/ViewletSelector.svelte +++ b/plugins/view-resources/src/components/ViewletSelector.svelte @@ -46,7 +46,7 @@ activeViewlet: Record | null>, key: string ) { - if (viewlets.length === 0) return + if (viewlets == null || viewlets.length === 0) return const newViewlet = viewlets.find((viewlet) => viewlet?._id === activeViewlet[key]) ?? viewlets[0] if (viewlet?._id !== newViewlet?._id) { viewlet = newViewlet @@ -55,7 +55,7 @@ } } - $: viewslist = viewlets.map((views) => { + $: viewslist = viewlets?.map((views) => { return { id: views._id, icon: views.$lookup?.descriptor?.icon, diff --git a/plugins/view-resources/src/components/filter/ValueFilter.svelte b/plugins/view-resources/src/components/filter/ValueFilter.svelte index d20b81e3cf..d481941b12 100644 --- a/plugins/view-resources/src/components/filter/ValueFilter.svelte +++ b/plugins/view-resources/src/components/filter/ValueFilter.svelte @@ -73,11 +73,17 @@ prefix = attr.attributeOf + '.' } const isDerivedFromSpace = hierarchy.isDerived(_class, core.class.Space) + + const archived = + space === undefined || isDerivedFromSpace + ? [] + : (await client.findAll(core.class.Space, { archived: true }, { projection: { _id: 1 } })).map((it) => it._id) + objectsPromise = client.findAll( _class, { ...resultQuery, - ...(space ? { space } : isDerivedFromSpace ? { archived: false } : { '$lookup.space.archived': false }) + ...(space ? { space } : isDerivedFromSpace ? { archived: false } : { space: { $nin: archived } }) }, { sort: { [filter.key.key]: SortingOrder.Ascending }, diff --git a/plugins/view-resources/src/components/list/List.svelte b/plugins/view-resources/src/components/list/List.svelte index 9968c39834..7f8df629aa 100644 --- a/plugins/view-resources/src/components/list/List.svelte +++ b/plugins/view-resources/src/components/list/List.svelte @@ -48,6 +48,7 @@ $: orderBy = viewOptions.orderBy const docsQuery = createQuery() + $: lookup = buildConfigLookup(client.getHierarchy(), _class, config, options?.lookup) $: resultOptions = { ...options, lookup, ...(orderBy !== undefined ? { sort: { [orderBy[0]]: orderBy[1] } } : {}) } @@ -59,17 +60,38 @@ $: if (documents === undefined) { docsQuery.query( _class, - resultQuery, + noLookup(resultQuery), (res) => { docs = res }, - resultOptions + { + ...resultOptions, + projection: { ...resultOptions.projection, _id: 1, _class: 1, ...getProjection(viewOptions.groupBy) } + } ) } else { docsQuery.unsubscribe() docs = documents } + function getProjection (fields: string[]): Record { + const res: Record = {} + for (const f of fields) { + res[f] = 1 + } + return res + } + + function noLookup (query: DocumentQuery): DocumentQuery { + const newQuery: DocumentQuery = {} + for (const [k, v] of Object.entries(query)) { + if (!k.startsWith('$lookup.')) { + newQuery[k] = v + } + } + return newQuery + } + $: dispatch('content', docs) const dispatch = createEventDispatcher() @@ -153,6 +175,8 @@ select(-2, evt.detail) }} on:collapsed + {resultQuery} + {resultOptions} /> diff --git a/plugins/view-resources/src/components/list/ListCategories.svelte b/plugins/view-resources/src/components/list/ListCategories.svelte index 3fce049331..31e6284e74 100644 --- a/plugins/view-resources/src/components/list/ListCategories.svelte +++ b/plugins/view-resources/src/components/list/ListCategories.svelte @@ -13,7 +13,17 @@ // limitations under the License. -->