diff --git a/plugins/recruit-resources/src/components/CreateVacancy.svelte b/plugins/recruit-resources/src/components/CreateVacancy.svelte index f6cf3cae4f..e9d9f5c097 100644 --- a/plugins/recruit-resources/src/components/CreateVacancy.svelte +++ b/plugins/recruit-resources/src/components/CreateVacancy.svelte @@ -47,6 +47,7 @@ let name: string = '' let template: KanbanTemplate | undefined let templateId: Ref | undefined + let appliedTemplateId: Ref | undefined let objectId: Ref = generateId() let issueTemplates: FindResult @@ -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), 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 @@ /> - {#key vacancyData?.fullDescription} + {#key appliedTemplateId} | undefined = draft?.template?.template + let appliedTemplateId: Ref | 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) } @@ -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 @@ {/if} - {#key objectId} + {#key [objectId, appliedTemplateId]}