diff --git a/plugins/attachment-resources/src/components/AttachmentRefInput.svelte b/plugins/attachment-resources/src/components/AttachmentRefInput.svelte index 1c8758b1ea..74fa2b1234 100644 --- a/plugins/attachment-resources/src/components/AttachmentRefInput.svelte +++ b/plugins/attachment-resources/src/components/AttachmentRefInput.svelte @@ -14,7 +14,7 @@ --> -{#if projectType !== undefined && items.length > 1} +{#if projectType !== undefined && (items.length > 1 || showAlways)} import { Person } from '@hcengineering/contact' import { Data, Doc, Ref, generateId } from '@hcengineering/core' - import { Card, KeyedAttribute, SpaceSelector, getClient } from '@hcengineering/presentation' - import tags, { TagElement } from '@hcengineering/tags' + import { Card, KeyedAttribute, SpaceSelector, createQuery, getClient } from '@hcengineering/presentation' + import tags, { TagElement, TagReference } from '@hcengineering/tags' + import { TaskType } from '@hcengineering/task' + import { TaskKindSelector } from '@hcengineering/task-resources' import { StyledTextBox } from '@hcengineering/text-editor-resources' import { Component as ComponentType, IssuePriority, IssueTemplate, Milestone, Project } from '@hcengineering/tracker' import { Component, EditBox, Label } from '@hcengineering/ui' @@ -39,6 +41,7 @@ export let relatedTo: Doc | undefined let labels: TagElement[] = [] + let kind: Ref | undefined = undefined let objectId: Ref = generateId() let object: Data = { @@ -93,6 +96,7 @@ comments: 0, attachments: 0, labels: labels.map((it) => it._id), + kind, relations: relatedTo !== undefined ? [{ _id: relatedTo._id, _class: relatedTo._class }] : [] } @@ -119,6 +123,19 @@ function addTagRef (tag: TagElement): void { labels = [...labels, tag] } + + let currentProject: Project | undefined + const spaceQuery = createQuery() + $: if (_space !== undefined) { + spaceQuery.query(tracker.class.Project, { _id: _space }, (res) => { + currentProject = res[0] + }) + } else { + spaceQuery.unsubscribe() + currentProject = undefined + } + + $: labelRefs = labels.map((it) => ({ ...(it as unknown as TagReference), _id: generateId(), tag: it._id })) - void let labels: TagElement[] = [] + let canSave = getTitle(newIssue.title ?? '').length > 0 + $: canSave = getTitle(newIssue.title ?? '').length > 0 const labelsQuery = createQuery() @@ -72,20 +74,25 @@ } } - function resetToDefaults () { + function resetToDefaults (): void { newIssue = getIssueDefaults() + labels = [] focusIssueTitle?.() } - function getTitle (value: string) { + function getTitle (value: string): string { return value.trim() } - function close () { + function close (): void { dispatch('close') } - async function createIssue () { + function onDelete (): void { + dispatch('close', ['delete', newIssue]) + } + + function createIssue (): void { if (!canSave) { return } @@ -99,7 +106,7 @@ if (childIssue === undefined) { dispatch('create', value) } else { - dispatch('close', value) + dispatch('close', ['update', value]) } resetToDefaults() @@ -121,8 +128,7 @@ ) let currentProject: Project | undefined = undefined - $: thisRef && thisRef.scrollIntoView({ behavior: 'smooth' }) - $: canSave = getTitle(newIssue.title ?? '').length > 0 + $: thisRef !== undefined && thisRef.scrollIntoView({ behavior: 'smooth' }) $: labelRefs = labels.map((it) => ({ ...(it as unknown as TagReference), _id: generateId(), tag: it._id })) @@ -200,6 +206,9 @@ />
+ {#if childIssue !== undefined} +
diff --git a/plugins/tracker-resources/src/components/templates/TemplateControlPanel.svelte b/plugins/tracker-resources/src/components/templates/TemplateControlPanel.svelte index beaa5843be..0499c1b9f6 100644 --- a/plugins/tracker-resources/src/components/templates/TemplateControlPanel.svelte +++ b/plugins/tracker-resources/src/components/templates/TemplateControlPanel.svelte @@ -14,8 +14,10 @@ -->
+ + + { + if (evt.detail !== undefined) { + await client.update(issue, { kind: evt.detail }) + } + }} + /> - +