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-17 08:14:58 +00:00
|
|
|
import { DocumentQuery, Ref } from '@hcengineering/core'
|
|
|
|
import { Issue, Project } from '@hcengineering/tracker'
|
2022-06-28 06:53:39 +00:00
|
|
|
import tracker from '../../plugin'
|
|
|
|
import IssuesView from './IssuesView.svelte'
|
2023-05-17 08:14:58 +00:00
|
|
|
import { IntlString } from '@hcengineering/platform'
|
|
|
|
import { createQuery } from '@hcengineering/presentation'
|
|
|
|
import { IModeSelector } from '../../utils'
|
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
|
2022-06-28 06:53:39 +00:00
|
|
|
|
2023-05-17 08:14:58 +00:00
|
|
|
const config: [string, IntlString, object][] = [
|
|
|
|
['all', tracker.string.All, {}],
|
|
|
|
['active', tracker.string.Active, {}],
|
|
|
|
['backlog', tracker.string.Backlog, {}]
|
|
|
|
]
|
|
|
|
|
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
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
let [[mode]] = config
|
|
|
|
function handleChangeMode (newMode: string) {
|
|
|
|
if (newMode === mode) return
|
|
|
|
mode = newMode
|
|
|
|
}
|
|
|
|
|
|
|
|
function getQuery (mode: string, queries: { [key: string]: DocumentQuery<Issue> }) {
|
|
|
|
return { ...queries[mode], '$lookup.space.archived': false }
|
|
|
|
}
|
|
|
|
$: query = getQuery(mode, { all, active, backlog })
|
|
|
|
$: modeSelectorProps = {
|
|
|
|
config,
|
|
|
|
mode,
|
|
|
|
onChange: handleChangeMode
|
|
|
|
} as IModeSelector
|
2022-06-28 06:53:39 +00:00
|
|
|
</script>
|
|
|
|
|
2023-05-17 18:29:49 +00:00
|
|
|
{#key query && currentSpace}
|
|
|
|
<IssuesView {query} space={currentSpace} {title} {modeSelectorProps} />
|
|
|
|
{/key}
|