mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-28 04:25:03 +02:00
Fix create draft issue duplicate id (#2935)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
@@ -304,6 +304,7 @@
|
||||
}
|
||||
|
||||
async function createIssue () {
|
||||
const _id: Ref<Issue> = generateId()
|
||||
if (!canSave || object.status === undefined) {
|
||||
return
|
||||
}
|
||||
@@ -350,19 +351,19 @@
|
||||
parentIssue?._class ?? tracker.class.Issue,
|
||||
'subIssues',
|
||||
value,
|
||||
object._id
|
||||
_id
|
||||
)
|
||||
for (const label of object.labels) {
|
||||
await client.addCollection(label._class, label.space, object._id, tracker.class.Issue, 'labels', {
|
||||
await client.addCollection(label._class, label.space, _id, tracker.class.Issue, 'labels', {
|
||||
title: label.title,
|
||||
color: label.color,
|
||||
tag: label.tag
|
||||
})
|
||||
}
|
||||
await descriptionBox.createAttachments()
|
||||
await descriptionBox.createAttachments(_id)
|
||||
|
||||
if (relatedTo !== undefined) {
|
||||
const doc = await client.findOne(tracker.class.Issue, { _id: object._id })
|
||||
const doc = await client.findOne(tracker.class.Issue, { _id })
|
||||
if (doc !== undefined) {
|
||||
if (client.getHierarchy().isDerived(relatedTo._class, tracker.class.Issue)) {
|
||||
await updateIssueRelation(client, relatedTo as Issue, doc, 'relations', '$push')
|
||||
@@ -374,14 +375,14 @@
|
||||
}
|
||||
const parents = parentIssue
|
||||
? [
|
||||
{ parentId: object._id, parentTitle: value.title },
|
||||
{ parentId: _id, parentTitle: value.title },
|
||||
{ parentId: parentIssue._id, parentTitle: parentIssue.title },
|
||||
...parentIssue.parents
|
||||
]
|
||||
: [{ parentId: object._id, parentTitle: value.title }]
|
||||
await subIssuesComponent.save(parents)
|
||||
: [{ parentId: _id, parentTitle: value.title }]
|
||||
await subIssuesComponent.save(parents, _id)
|
||||
addNotification(await translate(tracker.string.IssueCreated, {}), getTitle(object.title), IssueNotification, {
|
||||
issueId: object._id,
|
||||
issueId: _id,
|
||||
subTitlePostfix: (await translate(tracker.string.Created, { value: 1 })).toLowerCase(),
|
||||
issueUrl: currentProject && generateIssueShortLink(getIssueId(currentProject, value as Issue))
|
||||
})
|
||||
@@ -598,7 +599,6 @@
|
||||
<SubIssues
|
||||
bind:this={subIssuesComponent}
|
||||
projectId={_space}
|
||||
parent={object._id}
|
||||
project={currentProject}
|
||||
sprint={object.sprint}
|
||||
component={object.component}
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
<script lang="ts">
|
||||
import attachment, { Attachment } from '@hcengineering/attachment'
|
||||
import { deleteFile } from '@hcengineering/attachment-resources/src/utils'
|
||||
import core, { AttachedData, Ref, SortingOrder } from '@hcengineering/core'
|
||||
import core, { AttachedData, Doc, Ref, SortingOrder } from '@hcengineering/core'
|
||||
import { DraftController, draftsStore, getClient } from '@hcengineering/presentation'
|
||||
import tags from '@hcengineering/tags'
|
||||
import { calcRank, Component, Issue, IssueDraft, IssueParentInfo, Project, Sprint } from '@hcengineering/tracker'
|
||||
import { Button, closeTooltip, ExpandCollapse, IconAdd, Scroller } from '@hcengineering/ui'
|
||||
import { Component, Issue, IssueDraft, IssueParentInfo, Project, Sprint, calcRank } from '@hcengineering/tracker'
|
||||
import { Button, ExpandCollapse, IconAdd, Scroller, closeTooltip } from '@hcengineering/ui'
|
||||
import { onDestroy } from 'svelte'
|
||||
import tracker from '../plugin'
|
||||
import Collapsed from './icons/Collapsed.svelte'
|
||||
@@ -27,7 +27,6 @@
|
||||
import DraftIssueChildEditor from './templates/DraftIssueChildEditor.svelte'
|
||||
import DraftIssueChildList from './templates/DraftIssueChildList.svelte'
|
||||
|
||||
export let parent: Ref<Issue>
|
||||
export let projectId: Ref<Project>
|
||||
export let project: Project | undefined
|
||||
export let sprint: Ref<Sprint> | null = null
|
||||
@@ -63,7 +62,7 @@
|
||||
|
||||
const client = getClient()
|
||||
|
||||
export async function save (parents: IssueParentInfo[]) {
|
||||
export async function save (parents: IssueParentInfo[], _id: Ref<Doc>) {
|
||||
if (project === undefined) return
|
||||
saved = true
|
||||
|
||||
@@ -104,7 +103,7 @@
|
||||
await client.addCollection(
|
||||
tracker.class.Issue,
|
||||
project._id,
|
||||
parent,
|
||||
_id,
|
||||
tracker.class.Issue,
|
||||
'subIssues',
|
||||
cvalue,
|
||||
|
||||
@@ -100,6 +100,7 @@
|
||||
if (!canSave) {
|
||||
return
|
||||
}
|
||||
const _id: Ref<Issue> = generateId()
|
||||
loading = true
|
||||
try {
|
||||
const space = currentProject._id
|
||||
@@ -135,13 +136,13 @@
|
||||
parentIssue._class,
|
||||
'subIssues',
|
||||
value,
|
||||
object._id
|
||||
_id
|
||||
)
|
||||
|
||||
await descriptionBox.createAttachments()
|
||||
await descriptionBox.createAttachments(_id)
|
||||
|
||||
for (const label of object.labels) {
|
||||
await client.addCollection(label._class, label.space, object._id, tracker.class.Issue, 'labels', {
|
||||
await client.addCollection(label._class, label.space, _id, tracker.class.Issue, 'labels', {
|
||||
title: label.title,
|
||||
color: label.color,
|
||||
tag: label.tag
|
||||
@@ -149,7 +150,7 @@
|
||||
}
|
||||
|
||||
addNotification(await translate(tracker.string.IssueCreated, {}), getTitle(object.title), IssueNotification, {
|
||||
issueId: object._id,
|
||||
issueId: _id,
|
||||
subTitlePostfix: (await translate(tracker.string.Created, { value: 1 })).toLowerCase()
|
||||
})
|
||||
draftController.remove()
|
||||
|
||||
@@ -177,23 +177,25 @@
|
||||
{/if}
|
||||
<EditBox bind:value={title} placeholder={tracker.string.IssueTitlePlaceholder} kind="large-style" on:blur={save} />
|
||||
<div class="w-full mt-6">
|
||||
<AttachmentStyledBox
|
||||
bind:this={descriptionBox}
|
||||
useAttachmentPreview={true}
|
||||
objectId={_id}
|
||||
_class={tracker.class.Issue}
|
||||
space={issue.space}
|
||||
alwaysEdit
|
||||
on:attached={save}
|
||||
on:detached={save}
|
||||
showButtons
|
||||
on:blur={save}
|
||||
on:changeContent={triggerSave}
|
||||
maxHeight={'card'}
|
||||
focusable
|
||||
bind:content={description}
|
||||
placeholder={tracker.string.IssueDescriptionPlaceholder}
|
||||
/>
|
||||
{#key _id}
|
||||
<AttachmentStyledBox
|
||||
bind:this={descriptionBox}
|
||||
useAttachmentPreview={true}
|
||||
objectId={_id}
|
||||
_class={tracker.class.Issue}
|
||||
space={issue.space}
|
||||
alwaysEdit
|
||||
on:attached={save}
|
||||
on:detached={save}
|
||||
showButtons
|
||||
on:blur={save}
|
||||
on:changeContent={triggerSave}
|
||||
maxHeight={'card'}
|
||||
focusable
|
||||
bind:content={description}
|
||||
placeholder={tracker.string.IssueDescriptionPlaceholder}
|
||||
/>
|
||||
{/key}
|
||||
</div>
|
||||
|
||||
<div class="mt-6">
|
||||
|
||||
Reference in New Issue
Block a user