2022-06-28 06:53:39 +00:00
|
|
|
<!--
|
|
|
|
// Copyright © 2022 Hardcore Engineering Inc.
|
|
|
|
//
|
|
|
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License. You may
|
|
|
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
//
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
-->
|
|
|
|
<script lang="ts">
|
2023-05-24 06:47:58 +00:00
|
|
|
import { createEventDispatcher } from 'svelte'
|
2023-05-17 08:14:58 +00:00
|
|
|
import { DocumentQuery, Ref } from '@hcengineering/core'
|
|
|
|
import { Issue, Project } from '@hcengineering/tracker'
|
|
|
|
import { IntlString } from '@hcengineering/platform'
|
|
|
|
import { createQuery } from '@hcengineering/presentation'
|
2023-05-24 06:47:58 +00:00
|
|
|
import { resolvedLocationStore } from '@hcengineering/ui'
|
|
|
|
|
2023-05-23 10:19:35 +00:00
|
|
|
import { IModeSelector } from '@hcengineering/ui'
|
2023-05-24 06:47:58 +00:00
|
|
|
import tracker from '../../plugin'
|
|
|
|
import IssuesView from './IssuesView.svelte'
|
2022-06-28 06:53:39 +00:00
|
|
|
|
2023-05-17 18:29:49 +00:00
|
|
|
export let currentSpace: Ref<Project> | undefined = undefined
|
|
|
|
export let baseQuery: DocumentQuery<Issue> = {}
|
|
|
|
export let title: IntlString
|
2023-05-24 06:47:58 +00:00
|
|
|
export let config: [string, IntlString, object][]
|
2022-06-28 06:53:39 +00:00
|
|
|
|
2023-05-24 06:47:58 +00:00
|
|
|
const dispatch = createEventDispatcher()
|
|
|
|
let query: DocumentQuery<Issue> | undefined = undefined
|
|
|
|
let modeSelectorProps: IModeSelector | undefined = undefined
|
2023-05-17 08:14:58 +00:00
|
|
|
|
2023-05-17 18:29:49 +00:00
|
|
|
$: spaceQuery = currentSpace ? { space: currentSpace } : {}
|
|
|
|
|
|
|
|
$: all = { ...baseQuery, ...spaceQuery }
|
2023-05-17 08:14:58 +00:00
|
|
|
|
|
|
|
const activeStatusQuery = createQuery()
|
|
|
|
let active: DocumentQuery<Issue>
|
|
|
|
$: activeStatusQuery.query(
|
|
|
|
tracker.class.IssueStatus,
|
|
|
|
{
|
|
|
|
category: { $in: [tracker.issueStatusCategory.Unstarted, tracker.issueStatusCategory.Started] },
|
2023-05-17 18:29:49 +00:00
|
|
|
...spaceQuery
|
2023-05-17 08:14:58 +00:00
|
|
|
},
|
|
|
|
(result) => {
|
2023-05-17 18:29:49 +00:00
|
|
|
active = { status: { $in: result.map(({ _id }) => _id) }, ...spaceQuery }
|
2023-05-17 08:14:58 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
const backlogStatusQuery = createQuery()
|
|
|
|
let backlog: DocumentQuery<Issue> = {}
|
|
|
|
$: backlogStatusQuery.query(
|
|
|
|
tracker.class.IssueStatus,
|
2023-05-17 18:29:49 +00:00
|
|
|
{ category: tracker.issueStatusCategory.Backlog, ...spaceQuery },
|
2023-05-17 08:14:58 +00:00
|
|
|
(result) => {
|
2023-05-17 18:29:49 +00:00
|
|
|
backlog = { status: { $in: result.map(({ _id }) => _id) }, ...spaceQuery }
|
2023-05-17 08:14:58 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2023-08-10 15:12:48 +00:00
|
|
|
const archivedProjectQuery = createQuery()
|
|
|
|
let archived: Ref<Project>[] = []
|
|
|
|
|
|
|
|
archivedProjectQuery.query(
|
|
|
|
tracker.class.Project,
|
|
|
|
{ archived: true },
|
|
|
|
(res) => {
|
|
|
|
archived = res.map((it) => it._id)
|
|
|
|
},
|
|
|
|
{ projection: { _id: 1 } }
|
|
|
|
)
|
|
|
|
|
2023-05-24 06:47:58 +00:00
|
|
|
$: queries = { all, active, backlog }
|
|
|
|
$: mode = $resolvedLocationStore.query?.mode ?? undefined
|
|
|
|
$: if (mode === undefined || queries[mode] === undefined) {
|
|
|
|
;[[mode]] = config
|
2023-05-17 08:14:58 +00:00
|
|
|
}
|
2023-05-24 06:47:58 +00:00
|
|
|
$: if (mode !== undefined) {
|
2023-08-10 15:12:48 +00:00
|
|
|
query = { ...queries[mode] }
|
|
|
|
if (query?.space === undefined) {
|
|
|
|
query = { ...query, space: { $nin: archived } }
|
|
|
|
}
|
2023-05-24 06:47:58 +00:00
|
|
|
modeSelectorProps = {
|
|
|
|
config,
|
|
|
|
mode,
|
|
|
|
onChange: (newMode: string) => dispatch('action', { mode: newMode })
|
|
|
|
}
|
2023-05-17 08:14:58 +00:00
|
|
|
}
|
2022-06-28 06:53:39 +00:00
|
|
|
</script>
|
|
|
|
|
2023-05-24 06:47:58 +00:00
|
|
|
{#if query !== undefined && modeSelectorProps !== undefined}
|
|
|
|
{#key query && currentSpace}
|
|
|
|
<IssuesView {query} space={currentSpace} {title} {modeSelectorProps} />
|
|
|
|
{/key}
|
|
|
|
{/if}
|