diff --git a/models/tracker/src/index.ts b/models/tracker/src/index.ts index 89d063f976..f9089c62e9 100644 --- a/models/tracker/src/index.ts +++ b/models/tracker/src/index.ts @@ -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, diff --git a/models/tracker/src/plugin.ts b/models/tracker/src/plugin.ts index ee0cd84958..527dc75d5e 100644 --- a/models/tracker/src/plugin.ts +++ b/models/tracker/src/plugin.ts @@ -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>>> } }) diff --git a/packages/ui/src/popups.ts b/packages/ui/src/popups.ts index 7a1365590a..86e3f57d4b 100644 --- a/packages/ui/src/popups.ts +++ b/packages/ui/src/popups.ts @@ -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 diff --git a/plugins/tracker-assets/lang/en.json b/plugins/tracker-assets/lang/en.json index 1209893eaa..285bc9ac4a 100644 --- a/plugins/tracker-assets/lang/en.json +++ b/plugins/tracker-assets/lang/en.json @@ -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", diff --git a/plugins/tracker-assets/lang/ru.json b/plugins/tracker-assets/lang/ru.json index 6f3150ab79..c515607228 100644 --- a/plugins/tracker-assets/lang/ru.json +++ b/plugins/tracker-assets/lang/ru.json @@ -196,6 +196,9 @@ "NewSubIssue": "Добавить под-задачу...", "AddLabel": "Добавить метку", + "DeleteIssue": "Удалить {issueCount, plural, =1 {задачу} other {задачи}}", + "DeleteIssueConfirm": "Вы действительно хотите удалить {issueCount, plural, =1 {задачу} other {задачи}}{subIssueCount, plural, =0 {?} =1 { и под-задачу?} other { и под-задачи?}}", + "Milestone": "Майлстоун", "NoMilestone": "Без Майлстоуна", "MoveToMilestone": "Выбрать Майлстоун", diff --git a/plugins/tracker-resources/src/components/NewIssueHeader.svelte b/plugins/tracker-resources/src/components/NewIssueHeader.svelte index 9d78ba8ef2..d8648913be 100644 --- a/plugins/tracker-resources/src/components/NewIssueHeader.svelte +++ b/plugins/tracker-resources/src/components/NewIssueHeader.svelte @@ -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> diff --git a/plugins/tracker-resources/src/components/workflow/RemoveStatus.svelte b/plugins/tracker-resources/src/components/workflow/RemoveStatus.svelte index 1794661dfa..ebc5408582 100644 --- a/plugins/tracker-resources/src/components/workflow/RemoveStatus.svelte +++ b/plugins/tracker-resources/src/components/workflow/RemoveStatus.svelte @@ -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> diff --git a/plugins/tracker-resources/src/index.ts b/plugins/tracker-resources/src/index.ts index 51fcd4499d..44d3bcf2b4 100644 --- a/plugins/tracker-resources/src/index.ts +++ b/plugins/tracker-resources/src/index.ts @@ -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 diff --git a/plugins/tracker-resources/src/plugin.ts b/plugins/tracker-resources/src/plugin.ts index 95d30139d0..63504a2ecf 100644 --- a/plugins/tracker-resources/src/plugin.ts +++ b/plugins/tracker-resources/src/plugin.ts @@ -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,