2022-06-02 16:57:07 +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-03-22 10:08:19 +00:00
|
|
|
import { Ref, toIdMap } from '@hcengineering/core'
|
2023-03-24 10:23:44 +00:00
|
|
|
import { createQuery, draftsStore } from '@hcengineering/presentation'
|
2023-03-22 10:08:19 +00:00
|
|
|
import { Issue, Project, trackerId } from '@hcengineering/tracker'
|
2023-02-17 09:25:40 +00:00
|
|
|
import {
|
|
|
|
Button,
|
|
|
|
Chevron,
|
|
|
|
ExpandCollapse,
|
|
|
|
IconAdd,
|
|
|
|
IconArrowRight,
|
2023-03-22 10:08:19 +00:00
|
|
|
IconScaleFull,
|
2023-02-17 09:25:40 +00:00
|
|
|
Label,
|
2023-04-14 10:29:15 +00:00
|
|
|
closeTooltip,
|
2023-04-21 16:24:45 +00:00
|
|
|
getCurrentResolvedLocation,
|
2023-02-17 09:25:40 +00:00
|
|
|
navigate
|
|
|
|
} from '@hcengineering/ui'
|
2023-01-18 05:14:59 +00:00
|
|
|
import view, { Viewlet } from '@hcengineering/view'
|
2023-03-15 15:26:33 +00:00
|
|
|
import {
|
2023-04-14 10:29:15 +00:00
|
|
|
ViewletSettingButton,
|
2023-03-15 15:26:33 +00:00
|
|
|
createFilter,
|
|
|
|
getViewOptions,
|
2023-04-14 10:29:15 +00:00
|
|
|
setFilters,
|
2023-03-22 10:08:19 +00:00
|
|
|
viewOptionStore
|
2023-03-15 15:26:33 +00:00
|
|
|
} from '@hcengineering/view-resources'
|
2022-06-02 16:57:07 +00:00
|
|
|
import tracker from '../../../plugin'
|
2022-06-06 15:52:30 +00:00
|
|
|
import CreateSubIssue from './CreateSubIssue.svelte'
|
2022-06-02 16:57:07 +00:00
|
|
|
import SubIssueList from './SubIssueList.svelte'
|
|
|
|
|
|
|
|
export let issue: Issue
|
2023-03-17 06:17:53 +00:00
|
|
|
export let projects: Map<Ref<Project>, Project>
|
2023-03-24 10:23:44 +00:00
|
|
|
export let shouldSaveDraft: boolean = false
|
2022-06-02 16:57:07 +00:00
|
|
|
|
2023-02-13 11:45:57 +00:00
|
|
|
let subIssueEditorRef: HTMLDivElement
|
2022-06-02 16:57:07 +00:00
|
|
|
let isCollapsed = false
|
2023-03-24 10:23:44 +00:00
|
|
|
let isCreating = $draftsStore[issue._id] !== undefined
|
2022-06-02 16:57:07 +00:00
|
|
|
|
2023-01-18 05:14:59 +00:00
|
|
|
$: hasSubIssues = issue.subIssues > 0
|
2022-06-02 16:57:07 +00:00
|
|
|
|
2023-01-18 05:14:59 +00:00
|
|
|
let viewlet: Viewlet | undefined
|
|
|
|
|
|
|
|
const query = createQuery()
|
|
|
|
$: query.query(view.class.Viewlet, { _id: tracker.viewlet.SubIssues }, (res) => {
|
|
|
|
;[viewlet] = res
|
|
|
|
})
|
|
|
|
|
2023-03-17 06:17:53 +00:00
|
|
|
let _projects = projects
|
2023-01-18 05:14:59 +00:00
|
|
|
|
2023-03-17 06:17:53 +00:00
|
|
|
const projectsQuery = createQuery()
|
2023-01-18 05:14:59 +00:00
|
|
|
|
2023-03-17 06:17:53 +00:00
|
|
|
$: if (projects === undefined) {
|
|
|
|
projectsQuery.query(tracker.class.Project, {}, async (result) => {
|
|
|
|
_projects = toIdMap(result)
|
2023-01-18 05:14:59 +00:00
|
|
|
})
|
|
|
|
} else {
|
2023-03-17 06:17:53 +00:00
|
|
|
projectsQuery.unsubscribe()
|
2022-06-02 16:57:07 +00:00
|
|
|
}
|
|
|
|
|
2023-03-15 15:26:33 +00:00
|
|
|
$: viewOptions = viewlet !== undefined ? getViewOptions(viewlet, $viewOptionStore) : undefined
|
2022-06-02 16:57:07 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="flex-between">
|
|
|
|
{#if hasSubIssues}
|
|
|
|
<Button
|
|
|
|
width="min-content"
|
|
|
|
size="small"
|
|
|
|
kind="transparent"
|
2022-06-06 15:52:30 +00:00
|
|
|
on:click={() => {
|
|
|
|
isCollapsed = !isCollapsed
|
|
|
|
isCreating = false
|
|
|
|
}}
|
2023-01-17 01:07:05 +00:00
|
|
|
>
|
|
|
|
<svelte:fragment slot="content">
|
|
|
|
<Chevron size={'small'} expanded={!isCollapsed} outline fill={'var(--caption-color)'} marginRight={'.375rem'} />
|
|
|
|
<Label label={tracker.string.SubIssuesList} params={{ subIssues: issue.subIssues }} />
|
|
|
|
</svelte:fragment>
|
|
|
|
</Button>
|
2022-06-02 16:57:07 +00:00
|
|
|
{/if}
|
2023-01-18 05:14:59 +00:00
|
|
|
<div class="flex-row-center">
|
|
|
|
{#if viewlet && hasSubIssues && viewOptions}
|
|
|
|
<ViewletSettingButton bind:viewOptions {viewlet} kind={'transparent'} />
|
|
|
|
{/if}
|
2023-02-21 08:22:49 +00:00
|
|
|
{#if hasSubIssues}
|
|
|
|
<Button
|
|
|
|
width="min-content"
|
|
|
|
icon={IconScaleFull}
|
|
|
|
kind={'transparent'}
|
|
|
|
size={'small'}
|
|
|
|
showTooltip={{ label: tracker.string.OpenSubIssues, direction: 'bottom' }}
|
|
|
|
on:click={() => {
|
|
|
|
const filter = createFilter(tracker.class.Issue, 'attachedTo', [issue._id])
|
|
|
|
if (filter !== undefined) {
|
|
|
|
closeTooltip()
|
2023-04-21 16:24:45 +00:00
|
|
|
const loc = getCurrentResolvedLocation()
|
2023-02-21 08:22:49 +00:00
|
|
|
loc.fragment = undefined
|
|
|
|
loc.query = undefined
|
|
|
|
loc.path[2] = trackerId
|
|
|
|
loc.path[3] = issue.space
|
|
|
|
loc.path[4] = 'issues'
|
|
|
|
navigate(loc)
|
2023-04-14 10:29:15 +00:00
|
|
|
setFilters([filter])
|
2023-02-21 08:22:49 +00:00
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
{/if}
|
2023-01-18 05:14:59 +00:00
|
|
|
<Button
|
|
|
|
id="add-sub-issue"
|
|
|
|
width="min-content"
|
2023-02-13 11:45:57 +00:00
|
|
|
icon={hasSubIssues ? (isCreating ? IconArrowRight : IconAdd) : undefined}
|
2023-01-18 05:14:59 +00:00
|
|
|
label={hasSubIssues ? undefined : tracker.string.AddSubIssues}
|
|
|
|
labelParams={{ subIssues: 0 }}
|
|
|
|
kind={'transparent'}
|
|
|
|
size={'small'}
|
|
|
|
showTooltip={{ label: tracker.string.AddSubIssues, props: { subIssues: 1 }, direction: 'bottom' }}
|
|
|
|
on:click={() => {
|
|
|
|
closeTooltip()
|
2023-02-13 11:45:57 +00:00
|
|
|
isCreating && subIssueEditorRef && subIssueEditorRef.scrollIntoView({ behavior: 'smooth' })
|
2023-01-18 05:14:59 +00:00
|
|
|
isCreating = true
|
|
|
|
isCollapsed = false
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
2022-06-02 16:57:07 +00:00
|
|
|
</div>
|
2022-06-06 15:52:30 +00:00
|
|
|
<div class="mt-1">
|
2023-03-22 10:08:19 +00:00
|
|
|
{#if hasSubIssues && viewOptions && viewlet}
|
|
|
|
{#if !isCollapsed}
|
|
|
|
<ExpandCollapse isExpanded={!isCollapsed}>
|
|
|
|
<div class="list" class:collapsed={isCollapsed}>
|
|
|
|
<SubIssueList projects={_projects} {viewlet} {viewOptions} query={{ attachedTo: issue._id }} />
|
|
|
|
</div>
|
|
|
|
</ExpandCollapse>
|
2023-01-18 05:14:59 +00:00
|
|
|
{/if}
|
2022-06-06 15:52:30 +00:00
|
|
|
{/if}
|
2023-03-22 10:08:19 +00:00
|
|
|
<ExpandCollapse isExpanded={!isCollapsed}>
|
|
|
|
{#if isCreating}
|
|
|
|
{@const project = projects.get(issue.space)}
|
|
|
|
{#if project !== undefined}
|
|
|
|
<div class="pt-4" bind:this={subIssueEditorRef}>
|
2023-03-24 10:23:44 +00:00
|
|
|
<CreateSubIssue
|
|
|
|
parentIssue={issue}
|
|
|
|
{shouldSaveDraft}
|
|
|
|
currentProject={project}
|
|
|
|
on:close={() => (isCreating = false)}
|
|
|
|
/>
|
2023-03-22 10:08:19 +00:00
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
{/if}
|
|
|
|
</ExpandCollapse>
|
2022-06-06 15:52:30 +00:00
|
|
|
</div>
|
2022-06-02 16:57:07 +00:00
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.list {
|
2022-06-03 14:49:17 +00:00
|
|
|
border-top: 1px solid var(--divider-color);
|
2022-06-02 16:57:07 +00:00
|
|
|
|
|
|
|
&.collapsed {
|
2022-06-03 14:49:17 +00:00
|
|
|
padding-top: 1px;
|
|
|
|
border-top: none;
|
2022-06-02 16:57:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|