mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-14 12:25:17 +00:00
75 lines
2.7 KiB
Svelte
75 lines
2.7 KiB
Svelte
<!--
|
|
// 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">
|
|
import { Doc, DocumentQuery, Ref, SortingOrder } from '@hcengineering/core'
|
|
import { createQuery } from '@hcengineering/presentation'
|
|
import { Issue, Project } from '@hcengineering/tracker'
|
|
import { Label, Spinner } from '@hcengineering/ui'
|
|
import { ViewOptions, Viewlet } from '@hcengineering/view'
|
|
import { createEventDispatcher } from 'svelte'
|
|
import tracker from '../../../plugin'
|
|
import AddIssueDuo from '../../icons/AddIssueDuo.svelte'
|
|
import SubIssueList from '../edit/SubIssueList.svelte'
|
|
|
|
export let object: Doc
|
|
export let viewlet: Viewlet
|
|
export let viewOptions: ViewOptions
|
|
export let disableHeader = false
|
|
|
|
const dispatch = createEventDispatcher()
|
|
|
|
let query: DocumentQuery<Issue>
|
|
$: query = { 'relations._id': object._id, 'relations._class': object._class }
|
|
|
|
const subIssuesQuery = createQuery()
|
|
|
|
let subIssues: Issue[] = []
|
|
|
|
let projects: Map<Ref<Project>, Project> | undefined
|
|
|
|
$: subIssuesQuery.query(tracker.class.Issue, query, async (result) => (subIssues = result), {
|
|
sort: { rank: SortingOrder.Ascending }
|
|
})
|
|
|
|
const projectsQuery = createQuery()
|
|
|
|
$: projectsQuery.query(tracker.class.Project, {}, async (result) => {
|
|
projects = new Map(result.map((it) => [it._id, it]))
|
|
})
|
|
</script>
|
|
|
|
{#if subIssues !== undefined && viewlet !== undefined}
|
|
{#if projects && subIssues.length > 0}
|
|
<SubIssueList bind:viewOptions {viewlet} issues={subIssues} {projects} {disableHeader} />
|
|
{:else}
|
|
<div class="antiSection-empty solid flex-col mt-3">
|
|
<div class="flex-center content-accent-color">
|
|
<AddIssueDuo size={'large'} />
|
|
</div>
|
|
<div class="text-sm dark-color" style:pointer-events="none">
|
|
<Label label={tracker.string.RelatedIssuesNotFound} />
|
|
</div>
|
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
<div class="over-underline text-sm content-accent-color" on:click={() => dispatch('add-issue')}>
|
|
<Label label={tracker.string.NewRelatedIssue} />
|
|
</div>
|
|
</div>
|
|
{/if}
|
|
{:else}
|
|
<div class="flex-center pt-3">
|
|
<Spinner />
|
|
</div>
|
|
{/if}
|