From 30a9186eabf83dcb07b2723aaac6763e5188c96e Mon Sep 17 00:00:00 2001 From: Sergei Ogorelkov Date: Thu, 2 Jun 2022 23:57:07 +0700 Subject: [PATCH] Tracker: add Sub-issues list (#1989) Signed-off-by: Sergei Ogorelkov --- .../ui/src/components/ExpandCollapse.svelte | 45 ++++++ packages/ui/src/index.ts | 1 + packages/ui/src/utils.ts | 12 ++ plugins/tracker-assets/lang/en.json | 4 +- plugins/tracker-assets/lang/ru.json | 3 + .../src/components/icons/Circles.svelte | 16 ++ .../src/components/issues/StatusEditor.svelte | 5 +- .../components/issues/edit/EditIssue.svelte | 4 + .../issues/edit/SubIssueList.svelte | 142 ++++++++++++++++++ .../issues/edit/SubIssueSelector.svelte | 2 +- .../components/issues/edit/SubIssues.svelte | 108 +++++++++++++ plugins/tracker-resources/src/plugin.ts | 3 +- 12 files changed, 340 insertions(+), 5 deletions(-) create mode 100644 packages/ui/src/components/ExpandCollapse.svelte create mode 100644 plugins/tracker-resources/src/components/icons/Circles.svelte create mode 100644 plugins/tracker-resources/src/components/issues/edit/SubIssueList.svelte create mode 100644 plugins/tracker-resources/src/components/issues/edit/SubIssues.svelte diff --git a/packages/ui/src/components/ExpandCollapse.svelte b/packages/ui/src/components/ExpandCollapse.svelte new file mode 100644 index 0000000000..96b69b0192 --- /dev/null +++ b/packages/ui/src/components/ExpandCollapse.svelte @@ -0,0 +1,45 @@ + + + +
+
+ +
+
+ + diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts index e405593e20..b1f1ec66f2 100644 --- a/packages/ui/src/index.ts +++ b/packages/ui/src/index.ts @@ -141,6 +141,7 @@ export { default as WeekCalendar } from './components/calendar/WeekCalendar.svel export { default as FocusHandler } from './components/FocusHandler.svelte' export { default as ListView } from './components/ListView.svelte' export { default as ToggleButton } from './components/ToggleButton.svelte' +export { default as ExpandCollapse } from './components/ExpandCollapse.svelte' export * from './types' export * from './location' diff --git a/packages/ui/src/utils.ts b/packages/ui/src/utils.ts index e9f3d490fb..d2382a4547 100644 --- a/packages/ui/src/utils.ts +++ b/packages/ui/src/utils.ts @@ -16,6 +16,7 @@ // import type { Metadata } from '@anticrm/platform' import type { Metadata } from '@anticrm/platform' import { setMetadata } from '@anticrm/platform' +import { Writable, writable } from 'svelte/store' export function setMetadataLocalStorage (id: Metadata, value: string | null): void { if (value != null) { @@ -33,3 +34,14 @@ export function fetchMetadataLocalStorage (id: Metadata): string | null } return value } + +export function syncHeight (element: HTMLElement | undefined): Writable { + return writable(0, (set) => { + if (element != null) { + const observer = new ResizeObserver(() => set(element.offsetHeight)) + observer.observe(element) + + return () => observer.disconnect() + } + }) +} diff --git a/plugins/tracker-assets/lang/en.json b/plugins/tracker-assets/lang/en.json index dd618e200f..37a85a0112 100644 --- a/plugins/tracker-assets/lang/en.json +++ b/plugins/tracker-assets/lang/en.json @@ -69,7 +69,9 @@ "ChangeParent": "Change parent issue\u2026", "RemoveParent": "Remove parent issue", "OpenParent": "Open parent issue", - "OpenSub": "Open sub-issues", + "SubIssues": "Sub-issues ({subIssues})", + "OpenSubIssues": "Open sub-issues", + "AddSubIssues": "{subIssues, plural, =1 {Add sub-issue} other {+ Add sub-issues}}", "BlockedBy": "", "RelatedTo": "", "Comments": "", diff --git a/plugins/tracker-assets/lang/ru.json b/plugins/tracker-assets/lang/ru.json index 9468f24994..91db78d1e8 100644 --- a/plugins/tracker-assets/lang/ru.json +++ b/plugins/tracker-assets/lang/ru.json @@ -43,6 +43,9 @@ "Low": "Низкий", "Unassigned": "Не назначен", "AddIssueTooltip": "Добавить задачу\u2026", + "SubIssues": "Подзадачи ({subIssues})", + "OpenSubIssues": "Открыть подзадачи", + "AddSubIssues": "{subIssues, plural, =1 {Добавить подзадачу} other {+ Добавить подзадачи}}", "Title": "Заголовок", "Description": "", diff --git a/plugins/tracker-resources/src/components/icons/Circles.svelte b/plugins/tracker-resources/src/components/icons/Circles.svelte new file mode 100644 index 0000000000..4cb9010e01 --- /dev/null +++ b/plugins/tracker-resources/src/components/icons/Circles.svelte @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + diff --git a/plugins/tracker-resources/src/components/issues/StatusEditor.svelte b/plugins/tracker-resources/src/components/issues/StatusEditor.svelte index e550c71f6d..6b1b884496 100644 --- a/plugins/tracker-resources/src/components/issues/StatusEditor.svelte +++ b/plugins/tracker-resources/src/components/issues/StatusEditor.svelte @@ -16,7 +16,7 @@ import { Ref, WithLookup } from '@anticrm/core' import { Issue, IssueStatus } from '@anticrm/tracker' import { getClient } from '@anticrm/presentation' - import { Tooltip } from '@anticrm/ui' + import { Tooltip, TooltipAlignment } from '@anticrm/ui' import type { ButtonKind, ButtonSize } from '@anticrm/ui' import tracker from '../../plugin' import StatusSelector from '../StatusSelector.svelte' @@ -25,6 +25,7 @@ export let statuses: WithLookup[] export let isEditable: boolean = true export let shouldShowLabel: boolean = false + export let tooltipAlignment: TooltipAlignment | undefined = undefined export let kind: ButtonKind = 'link' export let size: ButtonSize = 'large' @@ -52,7 +53,7 @@ {#if value} {#if isEditable} - + export let _class: Ref> @@ -239,6 +240,9 @@ {/if} +
+ +
{/if} diff --git a/plugins/tracker-resources/src/components/issues/edit/SubIssueList.svelte b/plugins/tracker-resources/src/components/issues/edit/SubIssueList.svelte new file mode 100644 index 0000000000..431a6f4761 --- /dev/null +++ b/plugins/tracker-resources/src/components/issues/edit/SubIssueList.svelte @@ -0,0 +1,142 @@ + + + +{#each issues as issue, index (issue._id)} +
openIssue(issue)} + on:dragstart={(ev) => handleDragStart(ev, index)} + on:dragover|preventDefault={() => false} + on:dragenter={() => (hoveringIndex = index)} + on:drop|preventDefault={(ev) => handleDrop(ev, index)} + on:dragend={resetDrag} + > +
+
+
+
+ + openIssue(issue)}> + {issue.title} + +
+
+ + + +
+
+{/each} + + diff --git a/plugins/tracker-resources/src/components/issues/edit/SubIssueSelector.svelte b/plugins/tracker-resources/src/components/issues/edit/SubIssueSelector.svelte index 377a312a80..3016db0f97 100644 --- a/plugins/tracker-resources/src/components/issues/edit/SubIssueSelector.svelte +++ b/plugins/tracker-resources/src/components/issues/edit/SubIssueSelector.svelte @@ -121,7 +121,7 @@ {:else} - +
+ + +
+ {#if hasSubIssues} +
+{#if hasSubIssues} +
+ {#if subIssues && issueStatuses} +
+ + + +
+ {:else} +
+ +
+ {/if} +
+{/if} + + diff --git a/plugins/tracker-resources/src/plugin.ts b/plugins/tracker-resources/src/plugin.ts index 0e7fa43498..e0c55cf569 100644 --- a/plugins/tracker-resources/src/plugin.ts +++ b/plugins/tracker-resources/src/plugin.ts @@ -91,7 +91,8 @@ export default mergeIds(trackerId, tracker, { ChangeParent: '' as IntlString, RemoveParent: '' as IntlString, OpenParent: '' as IntlString, - OpenSub: '' as IntlString, + OpenSubIssues: '' as IntlString, + AddSubIssues: '' as IntlString, BlockedBy: '' as IntlString, RelatedTo: '' as IntlString, Comments: '' as IntlString,