mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-13 03:40:48 +00:00
[UBER-353] Warn about sub-issues when issues are deleted (#3356)
Signed-off-by: Ruslan Bayandinov <wazsone@ya.ru>
This commit is contained in:
parent
1ceec126f0
commit
f05d817a7c
@ -1270,6 +1270,24 @@ export function createModel (builder: Builder): void {
|
||||
tracker.action.DeleteProject
|
||||
)
|
||||
|
||||
createAction(
|
||||
builder,
|
||||
{
|
||||
action: tracker.actionImpl.DeleteIssue,
|
||||
label: workbench.string.Delete,
|
||||
icon: view.icon.Delete,
|
||||
input: 'any',
|
||||
category: tracker.category.Tracker,
|
||||
target: tracker.class.Issue,
|
||||
context: {
|
||||
mode: ['context', 'browser'],
|
||||
group: 'edit'
|
||||
},
|
||||
override: [view.action.Delete]
|
||||
},
|
||||
tracker.action.DeleteIssue
|
||||
)
|
||||
|
||||
builder.createDoc(
|
||||
view.class.ActionCategory,
|
||||
core.space.Model,
|
||||
|
@ -79,11 +79,13 @@ export default mergeIds(trackerId, tracker, {
|
||||
EditWorkflowStatuses: '' as ViewAction,
|
||||
EditProject: '' as ViewAction,
|
||||
DeleteProject: '' as ViewAction,
|
||||
DeleteIssue: '' as ViewAction,
|
||||
DeleteMilestone: '' as ViewAction
|
||||
},
|
||||
action: {
|
||||
NewRelatedIssue: '' as Ref<Action<Doc, Record<string, any>>>,
|
||||
DeleteMilestone: '' as Ref<Action<Doc, Record<string, any>>>,
|
||||
DeleteProject: '' as Ref<Action<Doc, Record<string, any>>>
|
||||
DeleteProject: '' as Ref<Action<Doc, Record<string, any>>>,
|
||||
DeleteIssue: '' as Ref<Action<Doc, Record<string, any>>>
|
||||
}
|
||||
})
|
||||
|
@ -53,8 +53,8 @@ export function showPopup (
|
||||
component: AnySvelteComponent | AnyComponent | ComponentType,
|
||||
props: any,
|
||||
element?: PopupAlignment,
|
||||
onClose?: (result: any) => void,
|
||||
onUpdate?: (result: any) => void,
|
||||
onClose?: (result: any) => void | Promise<void>,
|
||||
onUpdate?: (result: any) => void | Promise<void>,
|
||||
options: {
|
||||
category: string
|
||||
overlay: boolean
|
||||
|
@ -196,6 +196,9 @@
|
||||
"NewSubIssue": "Add sub-issue...",
|
||||
"AddLabel": "Add label",
|
||||
|
||||
"DeleteIssue": "Delete {issueCount, plural, =1 {issue} other {# issues}}",
|
||||
"DeleteIssueConfirm": "Do you want to delete {issueCount, plural, =1 {issue} other {issues}}{subIssueCount, plural, =0 {?} =1 { and sub-issue?} other { and sub-issues?}}",
|
||||
|
||||
"Milestone": "Milestone",
|
||||
"NoMilestone": "No Milestone",
|
||||
"MoveToMilestone": "Select Milestone",
|
||||
|
@ -196,6 +196,9 @@
|
||||
"NewSubIssue": "Добавить под-задачу...",
|
||||
"AddLabel": "Добавить метку",
|
||||
|
||||
"DeleteIssue": "Удалить {issueCount, plural, =1 {задачу} other {задачи}}",
|
||||
"DeleteIssueConfirm": "Вы действительно хотите удалить {issueCount, plural, =1 {задачу} other {задачи}}{subIssueCount, plural, =0 {?} =1 { и под-задачу?} other { и под-задачи?}}",
|
||||
|
||||
"Milestone": "Майлстоун",
|
||||
"NoMilestone": "Без Майлстоуна",
|
||||
"MoveToMilestone": "Выбрать Майлстоун",
|
||||
|
@ -53,7 +53,9 @@
|
||||
space = project?._id
|
||||
}
|
||||
closed = false
|
||||
showPopup(CreateIssue, { space, shouldSaveDraft: true }, 'top', () => (closed = true))
|
||||
showPopup(CreateIssue, { space, shouldSaveDraft: true }, 'top', () => {
|
||||
closed = true
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -54,7 +54,9 @@
|
||||
SelectPopup,
|
||||
{ value: statusesInfo, placeholder: tracker.string.SetStatus, searchable: true },
|
||||
eventToHTMLElement(event),
|
||||
(val) => (newStatus = $statusStore.getIdMap().get(val) ?? newStatus)
|
||||
(val) => {
|
||||
newStatus = $statusStore.getIdMap().get(val) ?? newStatus
|
||||
}
|
||||
)
|
||||
}
|
||||
</script>
|
||||
|
@ -16,6 +16,7 @@
|
||||
import {
|
||||
Class,
|
||||
Client,
|
||||
Doc,
|
||||
DocumentQuery,
|
||||
getCurrentAccount,
|
||||
Ref,
|
||||
@ -104,7 +105,7 @@ import ComponentSelector from './components/ComponentSelector.svelte'
|
||||
import IssueTemplatePresenter from './components/templates/IssueTemplatePresenter.svelte'
|
||||
import IssueTemplates from './components/templates/IssueTemplates.svelte'
|
||||
|
||||
import { deleteObject } from '@hcengineering/view-resources'
|
||||
import { deleteObject, deleteObjects } from '@hcengineering/view-resources'
|
||||
import MoveAndDeleteMilestonePopup from './components/milestones/MoveAndDeleteMilestonePopup.svelte'
|
||||
import EditIssueTemplate from './components/templates/EditIssueTemplate.svelte'
|
||||
import TemplateEstimationEditor from './components/templates/EstimationEditor.svelte'
|
||||
@ -208,6 +209,37 @@ async function editProject (project: Project | undefined): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteIssue (issue: Issue | Issue[]): Promise<void> {
|
||||
const issueCount = Array.isArray(issue) ? issue.length : 1
|
||||
let subissues: number = 0
|
||||
if (Array.isArray(issue)) {
|
||||
issue.forEach((it) => {
|
||||
subissues += it.subIssues
|
||||
})
|
||||
} else {
|
||||
subissues = issue.subIssues
|
||||
}
|
||||
showPopup(
|
||||
MessageBox,
|
||||
{
|
||||
label: tracker.string.DeleteIssue,
|
||||
labelProps: { issueCount },
|
||||
message: tracker.string.DeleteIssueConfirm,
|
||||
params: {
|
||||
issueCount,
|
||||
subIssueCount: subissues
|
||||
}
|
||||
},
|
||||
undefined,
|
||||
async (result?: boolean) => {
|
||||
if (result === true) {
|
||||
const objs = Array.isArray(issue) ? issue : [issue]
|
||||
await deleteObjects(getClient(), objs as unknown as Doc[]).catch((err) => console.error(err))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async function deleteProject (project: Project | undefined): Promise<void> {
|
||||
if (project !== undefined) {
|
||||
const client = getClient()
|
||||
@ -472,7 +504,8 @@ export default async (): Promise<Resources> => ({
|
||||
EditWorkflowStatuses: editWorkflowStatuses,
|
||||
EditProject: editProject,
|
||||
DeleteMilestone: deleteMilestone,
|
||||
DeleteProject: deleteProject
|
||||
DeleteProject: deleteProject,
|
||||
DeleteIssue: deleteIssue
|
||||
},
|
||||
resolver: {
|
||||
Location: resolveLocation
|
||||
|
@ -108,6 +108,8 @@ export default mergeIds(trackerId, tracker, {
|
||||
EditWorkflowStatuses: '' as IntlString,
|
||||
EditProject: '' as IntlString,
|
||||
DeleteProject: '' as IntlString,
|
||||
DeleteIssue: '' as IntlString,
|
||||
DeleteIssueConfirm: '' as IntlString,
|
||||
ArchiveProjectName: '' as IntlString,
|
||||
ArchiveProjectConfirm: '' as IntlString,
|
||||
ProjectHasIssues: '' as IntlString,
|
||||
|
Loading…
Reference in New Issue
Block a user