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