tsk-187 Duplicate issue from context menu (#2292)

Signed-off-by: Denis Bunakalya <denis.bunakalya@xored.com>
This commit is contained in:
Denis Bunakalya 2022-10-11 09:39:26 +03:00 committed by GitHub
parent 2298a08327
commit ca6e5edcf8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 86 additions and 21 deletions

View File

@ -1230,6 +1230,32 @@ export function createModel (builder: Builder): void {
},
tracker.action.Relations
)
createAction(
builder,
{
action: view.actionImpl.ShowPopup,
actionProps: {
component: tracker.component.CreateIssue,
element: 'top',
fillProps: {
_object: 'originalIssue',
space: 'space'
}
},
label: tracker.string.Duplicate,
icon: tracker.icon.Duplicate,
keyBinding: [],
input: 'none',
category: tracker.category.Tracker,
target: tracker.class.Issue,
context: {
mode: ['context', 'browser'],
application: tracker.app.Tracker,
group: 'associate'
}
},
tracker.action.Duplicate
)
classPresenter(
builder,

View File

@ -157,6 +157,9 @@
<symbol id="copyBranch" viewBox="0 0 16 16">
<path d="M12.6229 11.528V5.66666C12.5954 4.93866 12.3116 4.29467 11.7624 3.744C11.2132 3.19333 10.5907 2.89467 9.87669 2.86667H8.9613V1L6.21514 3.8L8.9613 6.6V4.73333H9.87669C10.1238 4.752 10.3161 4.836 10.5083 5.02267C10.7005 5.20933 10.7829 5.41466 10.7921 5.66666V11.528C10.4436 11.7327 10.1712 12.049 10.0172 12.4278C9.86328 12.8067 9.83642 13.2268 9.94083 13.6228C10.0452 14.0188 10.2751 14.3685 10.5945 14.6176C10.914 14.8666 11.3053 15.0011 11.7075 15C12.1096 15.0011 12.5009 14.8666 12.8204 14.6176C13.1399 14.3685 13.3697 14.0188 13.4741 13.6228C13.5785 13.2268 13.5517 12.8067 13.3977 12.4278C13.2438 12.049 12.9714 11.7327 12.6229 11.528ZM11.7075 14.2533C11.1033 14.2533 10.609 13.74 10.609 13.1333C10.609 12.5267 11.1125 12.0133 11.7075 12.0133C12.3025 12.0133 12.8059 12.5267 12.8059 13.1333C12.8059 13.74 12.3025 14.2533 11.7075 14.2533ZM6.21514 3.8C6.21514 2.764 5.40045 1.93333 4.38436 1.93333C3.98219 1.93225 3.59093 2.0667 3.27144 2.31576C2.95195 2.56483 2.72213 2.91456 2.61772 3.31057C2.51332 3.70657 2.54018 4.12665 2.69412 4.50548C2.84807 4.88432 3.12047 5.20066 3.46898 5.40533V11.528C3.12047 11.7327 2.84807 12.049 2.69412 12.4278C2.54018 12.8067 2.51332 13.2268 2.61772 13.6228C2.72213 14.0188 2.95195 14.3685 3.27144 14.6176C3.59093 14.8666 3.98219 15.0011 4.38436 15C4.78654 15.0011 5.1778 14.8666 5.49729 14.6176C5.81678 14.3685 6.0466 14.0188 6.15101 13.6228C6.25541 13.2268 6.22855 12.8067 6.07461 12.4278C5.92066 12.049 5.64826 11.7327 5.29975 11.528V5.40533C5.83983 5.088 6.21514 4.49067 6.21514 3.8ZM5.48283 13.1333C5.48283 13.7493 4.97937 14.2533 4.38436 14.2533C3.78936 14.2533 3.2859 13.74 3.2859 13.1333C3.2859 12.5267 3.78936 12.0133 4.38436 12.0133C4.97937 12.0133 5.48283 12.5267 5.48283 13.1333ZM4.38436 4.92C3.78021 4.92 3.2859 4.40667 3.2859 3.8C3.2859 3.19333 3.78936 2.68 4.38436 2.68C4.97937 2.68 5.48283 3.19333 5.48283 3.8C5.48283 4.40667 4.97937 4.92 4.38436 4.92Z" />
</symbol>
<symbol id="duplicate" viewBox="0 0 24 24">
<path d="M17.1,1.2h-4.2C9,1.2,7.2,3,7.2,6.9v0.4H6.9C3,7.2,1.2,9,1.2,12.9v4.2c0,3.9,1.7,5.7,5.6,5.7h4.2 c3.9,0,5.6-1.7,5.6-5.7v-0.3h0.3c3.9,0,5.7-1.7,5.7-5.6V6.9C22.8,3,21,1.2,17.1,1.2z M15.2,17.1c0,3.1-1,4.2-4.1,4.2H6.9 c-3.1,0-4.1-1-4.1-4.2v-4.2c0-3.1,1-4.1,4.1-4.1H8h3.1c3.1,0,4.1,1,4.1,4.1V16V17.1z M21.2,11.1c0,3.1-1,4.1-4.2,4.1h-0.3v-2.4 c0-3.9-1.7-5.6-5.6-5.6H8.8V6.9c0-3.1,1-4.1,4.1-4.1h4.2c3.1,0,4.2,1,4.2,4.1V11.1z" />
</symbol>
<symbol id="sprint" viewBox="0 0 16 16" fill="none">
<path d="M5.99935 3.33337H9.33268M9.33268 3.33337H12.666M9.33268 3.33337V12.6667M5.99935 12.6667H9.33268M9.33268 12.6667H12.666" stroke="currentColor"/>
<path d="M1.33398 10H0.833984V10.5H1.33398V10ZM1.33398 10.5H7.33398V9.5H1.33398V10.5ZM7.33398 5.5H3.33398V6.5H7.33398V5.5ZM0.833984 8V10H1.83398V8H0.833984ZM3.33398 5.5C1.95327 5.5 0.833984 6.61929 0.833984 8H1.83398C1.83398 7.17157 2.50556 6.5 3.33398 6.5V5.5Z" fill="currentColor"/>

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -127,6 +127,7 @@
"ProjectMembersSearchPlaceholder": "Change project members\u2026",
"Roadmap": "Roadmap",
"MoveToTeam": "Move to team",
"Duplicate": "Duplicate",
"GotoIssues": "Go to issues",
"GotoActive": "Go to active issues",

View File

@ -127,6 +127,7 @@
"ProjectMembersSearchPlaceholder": "Измененить участников проекта\u2026",
"Roadmap": "Планирование",
"MoveToTeam": "Изменить команду",
"Duplicate": "Дублировать",
"GotoIssues": "Перейти к задачам",
"GotoActive": "Перейти к активным задачам",

View File

@ -67,6 +67,7 @@ loadMetadata(tracker.icon, {
CopyID: `${icons}#copyID`,
CopyURL: `${icons}#copyURL`,
CopyBranch: `${icons}#copyBranch`,
Duplicate: `${icons}#duplicate`,
TimeReport: `${icons}#timeReport`,
Estimation: `${icons}#timeReport`
})

View File

@ -70,28 +70,40 @@
let issueStatuses: WithLookup<IssueStatus>[] | undefined
export let parentIssue: Issue | undefined
export let originalIssue: Issue | undefined
let labels: TagReference[] = []
let objectId: Ref<Issue> = generateId()
let object: AttachedData<Issue> = {
title: '',
description: '',
assignee: assignee,
project: project,
sprint: sprint,
number: 0,
rank: '',
status: '' as Ref<IssueStatus>,
priority: priority,
dueDate: null,
comments: 0,
subIssues: 0,
parents: [],
reportedTime: 0,
estimation: 0,
reports: 0,
childInfo: []
}
let object: AttachedData<Issue> = originalIssue
? {
...originalIssue,
title: `${originalIssue.title} (copy)`,
subIssues: 0,
attachments: 0,
reportedTime: 0,
reports: 0,
childInfo: []
}
: {
title: '',
description: '',
assignee: assignee,
project: project,
sprint: sprint,
number: 0,
rank: '',
status: '' as Ref<IssueStatus>,
priority: priority,
dueDate: null,
comments: 0,
subIssues: 0,
parents: [],
reportedTime: 0,
estimation: 0,
reports: 0,
childInfo: []
}
function resetObject (): void {
templateId = undefined
@ -187,7 +199,7 @@
}
$: _space = space
$: updateIssueStatusId(_space, status)
$: !originalIssue && updateIssueStatusId(_space, status)
$: canSave = getTitle(object.title ?? '').length > 0
$: statusesQuery.query(
@ -202,6 +214,24 @@
}
)
async function setPropsFromOriginalIssue () {
if (!originalIssue) {
return
}
const { _id, relations, parents } = originalIssue
if (relations?.[0]) {
relatedTo = await client.findOne(tracker.class.Issue, { _id: relations[0]._id as Ref<Issue> })
}
if (parents?.[0]) {
parentIssue = await client.findOne(tracker.class.Issue, { _id: parents[0].parentId })
}
if (originalIssue.labels) {
labels = await client.findAll(tags.class.TagReference, { attachedTo: _id })
}
}
$: originalIssue && setPropsFromOriginalIssue()
async function updateIssueStatusId (teamId: Ref<Team>, issueStatusId?: Ref<IssueStatus>) {
if (issueStatusId !== undefined) {
object.status = issueStatusId
@ -571,7 +601,7 @@
<SprintSelector
value={object.sprint}
onChange={handleSprintIdChanged}
useProject={object.project ?? undefined}
useProject={(!originalIssue && object.project) || undefined}
/>
{#if object.dueDate !== null}
<DatePresenter bind:value={object.dueDate} editable />

View File

@ -153,6 +153,7 @@ export default mergeIds(trackerId, tracker, {
NumberLabels: '' as IntlString,
Roadmap: '' as IntlString,
MoveToTeam: '' as IntlString,
Duplicate: '' as IntlString,
IssueTitlePlaceholder: '' as IntlString,
IssueDescriptionPlaceholder: '' as IntlString,

View File

@ -405,6 +405,7 @@ export default plugin(trackerId, {
CopyID: '' as Asset,
CopyURL: '' as Asset,
CopyBranch: '' as Asset,
Duplicate: '' as Asset,
TimeReport: '' as Asset,
Estimation: '' as Asset
@ -424,6 +425,7 @@ export default plugin(trackerId, {
CopyIssueTitle: '' as Ref<Action>,
CopyIssueLink: '' as Ref<Action>,
MoveToTeam: '' as Ref<Action>,
Duplicate: '' as Ref<Action>,
Relations: '' as Ref<Action>,
NewSubIssue: '' as Ref<Action>,
EditWorkflowStatuses: '' as Ref<Action>,