Skip to content

Commit

Permalink
[UBER-71] Use "New issue" dialog for creating sub-issues (#3199)
Browse files Browse the repository at this point in the history
Signed-off-by: Sergei Ogorelkov <sergei.ogorelkov@icloud.com>
  • Loading branch information
s0gorelkov committed May 17, 2023
1 parent a5a464a commit 673e7b8
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 464 deletions.
4 changes: 0 additions & 4 deletions plugins/tracker-resources/src/components/CreateIssue.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@
draftController.remove()
resetObject()
descriptionBox?.removeDraft(false)
subIssuesComponent.removeChildDraft()
}
async function showMoreActions (ev: Event) {
Expand Down Expand Up @@ -518,7 +517,6 @@
if (result === true) {
dispatch('close')
resetObject()
subIssuesComponent.removeChildDraft()
draftController.remove()
descriptionBox?.removeDraft(true)
}
Expand Down Expand Up @@ -624,11 +622,9 @@
<SubIssues
bind:this={subIssuesComponent}
projectId={_space}
parendIssueId={object._id}
project={currentProject}
milestone={object.milestone}
component={object.component}
{shouldSaveDraft}
bind:subIssues={object.subIssues}
/>
<svelte:fragment slot="pool">
Expand Down
71 changes: 9 additions & 62 deletions plugins/tracker-resources/src/components/SubIssues.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,21 @@
import { DraftController, draftsStore, getClient } from '@hcengineering/presentation'
import tags from '@hcengineering/tags'
import { Component, Issue, IssueDraft, IssueParentInfo, Project, Milestone, calcRank } from '@hcengineering/tracker'
import { Button, ExpandCollapse, IconAdd, Scroller, closeTooltip } from '@hcengineering/ui'
import { Button, ExpandCollapse, Scroller } from '@hcengineering/ui'
import { onDestroy } from 'svelte'
import tracker from '../plugin'
import Collapsed from './icons/Collapsed.svelte'
import Expanded from './icons/Expanded.svelte'
import DraftIssueChildEditor from './templates/DraftIssueChildEditor.svelte'
import DraftIssueChildList from './templates/DraftIssueChildList.svelte'
export let parendIssueId: Ref<Issue>
export let projectId: Ref<Project>
export let project: Project | undefined
export let milestone: Ref<Milestone> | null = null
export let component: Ref<Component> | null = null
export let subIssues: IssueDraft[] = []
export let shouldSaveDraft: boolean = false
let lastProject = project
let lastProject = project
let isCollapsed = false
$: isCreatingMode = $draftsStore[`${parendIssueId}_subIssue`] !== undefined
let isManualCreating = false
$: isCreating = isCreatingMode || isManualCreating
async function handleIssueSwap (ev: CustomEvent<{ fromIndex: number; toIndex: number }>) {
if (subIssues) {
Expand All @@ -65,6 +59,7 @@
const client = getClient()
// TODO: move to utils
export async function save (parents: IssueParentInfo[], _id: Ref<Doc>) {
if (project === undefined) return
saved = true
Expand Down Expand Up @@ -162,6 +157,7 @@
}
})
// TODO: move to utils
export async function removeDraft (_id: string, removeFiles: boolean = false): Promise<void> {
const draftAttachments = $draftsStore[`${_id}_attachments`]
DraftController.remove(`${_id}_attachments`)
Expand All @@ -172,49 +168,22 @@
}
}
}
export function removeChildDraft () {
draftChild?.removeDraft()
}
$: hasSubIssues = subIssues.length > 0
let draftChild: DraftIssueChildEditor
</script>

<div class="flex-between clear-mins">
{#if hasSubIssues}
<!-- TODO: check if sub issues list is empty in a parent component -->
{#if subIssues.length > 0}
<div class="flex-between clear-mins">
<Button
width="min-content"
icon={isCollapsed ? Collapsed : Expanded}
size="small"
kind="transparent"
label={tracker.string.SubIssuesList}
labelParams={{ subIssues: subIssues.length }}
on:click={() => {
isCollapsed = !isCollapsed
isCreating = false
}}
on:click={() => (isCollapsed = !isCollapsed)}
/>
{/if}
</div>

<Button
id="add-sub-issue"
width="min-content"
icon={hasSubIssues ? IconAdd : undefined}
label={hasSubIssues ? undefined : tracker.string.AddSubIssues}
labelParams={{ subIssues: 0 }}
kind={'transparent'}
size={'small'}
showTooltip={{ label: tracker.string.AddSubIssues, props: { subIssues: 1 } }}
on:click={() => {
closeTooltip()
isManualCreating = true
isCollapsed = false
}}
/>
</div>
{#if hasSubIssues}
<ExpandCollapse isExpanded={!isCollapsed} on:changeContent>
<div class="flex-col flex-no-shrink max-h-30 list clear-mins" class:collapsed={isCollapsed}>
<Scroller>
Expand All @@ -230,28 +199,6 @@
</div>
</ExpandCollapse>
{/if}
{#if isCreating && project}
<ExpandCollapse isExpanded={!isCollapsed} on:changeContent>
<DraftIssueChildEditor
bind:this={draftChild}
{parendIssueId}
{project}
{component}
{milestone}
{shouldSaveDraft}
on:close={() => {
isManualCreating = false
}}
on:create={(evt) => {
if (subIssues === undefined) {
subIssues = []
}
subIssues = [...subIssues, evt.detail]
}}
on:changeContent
/>
</ExpandCollapse>
{/if}

<style lang="scss">
.list {
Expand Down

0 comments on commit 673e7b8

Please sign in to comment.