mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-22 19:11:33 +03:00
TSK-894: Fix template creation and apply (#2785)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
fe69304732
commit
48d32b1841
@ -47,6 +47,7 @@
|
||||
let name: string = ''
|
||||
let template: KanbanTemplate | undefined
|
||||
let templateId: Ref<KanbanTemplate> | undefined
|
||||
let appliedTemplateId: Ref<KanbanTemplate> | undefined
|
||||
let objectId: Ref<VacancyClass> = generateId()
|
||||
let issueTemplates: FindResult<IssueTemplate>
|
||||
|
||||
@ -80,7 +81,10 @@
|
||||
$: templateQ.query(task.class.KanbanTemplate, { _id: templateId }, (result) => {
|
||||
const { _class, _id, description, ...templateData } = result[0]
|
||||
vacancyData = { ...(templateData as unknown as Data<VacancyClass>), fullDescription: description }
|
||||
fullDescription = description ?? ''
|
||||
if (appliedTemplateId !== templateId) {
|
||||
fullDescription = description ?? ''
|
||||
appliedTemplateId = templateId
|
||||
}
|
||||
})
|
||||
|
||||
const issueTemplatesQ = createQuery()
|
||||
@ -128,7 +132,8 @@
|
||||
estimation: template.estimation,
|
||||
reports: 0,
|
||||
relations: [{ _id: id, _class: recruit.class.Vacancy }],
|
||||
childInfo: []
|
||||
childInfo: [],
|
||||
createOn: Date.now()
|
||||
})
|
||||
if ((template.labels?.length ?? 0) > 0) {
|
||||
const tagElements = await client.findAll(tags.class.TagElement, { _id: { $in: template.labels } })
|
||||
@ -240,7 +245,7 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{#key vacancyData?.fullDescription}
|
||||
{#key appliedTemplateId}
|
||||
<AttachmentStyledBox
|
||||
bind:this={descriptionBox}
|
||||
{objectId}
|
||||
|
@ -159,6 +159,7 @@
|
||||
}
|
||||
|
||||
let templateId: Ref<IssueTemplate> | undefined = draft?.template?.template
|
||||
let appliedTemplateId: Ref<IssueTemplate> | undefined = draft?.template?.template
|
||||
|
||||
let template: IssueTemplate | undefined = undefined
|
||||
const templateQuery = createQuery()
|
||||
@ -194,8 +195,7 @@
|
||||
if (object.template?.template === template._id) {
|
||||
return
|
||||
}
|
||||
|
||||
const { _class, _id, space, children, comments, attachments, labels: labels_, ...templBase } = template
|
||||
const { _class, _id, space, children, comments, attachments, labels: labels_, description, ...templBase } = template
|
||||
|
||||
subIssues = template.children.map((p) => {
|
||||
return { ...p, status: currentProject?.defaultIssueStatus ?? ('' as Ref<IssueStatus>) }
|
||||
@ -203,11 +203,13 @@
|
||||
|
||||
object = {
|
||||
...object,
|
||||
description: description ?? '',
|
||||
...templBase,
|
||||
template: {
|
||||
template: template._id
|
||||
}
|
||||
}
|
||||
appliedTemplateId = templateId
|
||||
const tagElements = await client.findAll(tags.class.TagElement, { _id: { $in: labels_ } })
|
||||
labels = tagElements.map(tagAsRef)
|
||||
}
|
||||
@ -680,7 +682,7 @@
|
||||
<ParentIssue issue={parentIssue} on:close={clearParentIssue} />
|
||||
{/if}
|
||||
<EditBox bind:value={object.title} placeholder={tracker.string.IssueTitlePlaceholder} kind={'large-style'} focus />
|
||||
{#key objectId}
|
||||
{#key [objectId, appliedTemplateId]}
|
||||
<AttachmentStyledBox
|
||||
bind:this={descriptionBox}
|
||||
{objectId}
|
||||
|
@ -18,14 +18,14 @@
|
||||
import { Card, getClient, KeyedAttribute, SpaceSelector } from '@hcengineering/presentation'
|
||||
import tags, { TagElement } from '@hcengineering/tags'
|
||||
import { StyledTextBox } from '@hcengineering/text-editor'
|
||||
import { IssuePriority, IssueTemplate, Component as ComponentType, Sprint, Project } from '@hcengineering/tracker'
|
||||
import { Component as ComponentType, IssuePriority, IssueTemplate, Project, Sprint } from '@hcengineering/tracker'
|
||||
import { Component, EditBox, Label } from '@hcengineering/ui'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { activeComponent, activeSprint } from '../../issues'
|
||||
import tracker from '../../plugin'
|
||||
import ComponentSelector from '../ComponentSelector.svelte'
|
||||
import AssigneeEditor from '../issues/AssigneeEditor.svelte'
|
||||
import PriorityEditor from '../issues/PriorityEditor.svelte'
|
||||
import ComponentSelector from '../ComponentSelector.svelte'
|
||||
import SprintSelector from '../sprints/SprintSelector.svelte'
|
||||
import EstimationEditor from './EstimationEditor.svelte'
|
||||
import SubIssueTemplates from './IssueTemplateChilds.svelte'
|
||||
@ -58,8 +58,6 @@
|
||||
const dispatch = createEventDispatcher()
|
||||
const client = getClient()
|
||||
|
||||
let descriptionBox: StyledTextBox
|
||||
|
||||
const key: KeyedAttribute = {
|
||||
key: 'labels',
|
||||
attr: client.getHierarchy().getAttribute(tracker.class.Issue, 'labels')
|
||||
@ -98,8 +96,6 @@
|
||||
}
|
||||
|
||||
await client.createDoc(tracker.class.IssueTemplate, _space, value, objectId)
|
||||
|
||||
await descriptionBox.createAttachments()
|
||||
objectId = generateId()
|
||||
}
|
||||
|
||||
@ -143,7 +139,6 @@
|
||||
|
||||
<EditBox bind:value={object.title} placeholder={tracker.string.IssueTitlePlaceholder} kind={'large-style'} focus />
|
||||
<StyledTextBox
|
||||
bind:this={descriptionBox}
|
||||
alwaysEdit
|
||||
showButtons={false}
|
||||
emphasized
|
||||
|
Loading…
Reference in New Issue
Block a user