diff --git a/packages/presentation/src/components/Card.svelte b/packages/presentation/src/components/Card.svelte index 9b4ea1b98e..4c4d25275e 100644 --- a/packages/presentation/src/components/Card.svelte +++ b/packages/presentation/src/components/Card.svelte @@ -26,6 +26,7 @@ export let canSave: boolean = false export let createMore: boolean | undefined = undefined export let okLabel: IntlString = presentation.string.Create + export let onCancel: Function | undefined = undefined const dispatch = createEventDispatcher() @@ -54,7 +55,11 @@ icon={IconClose} kind={'transparent'} on:click={() => { - dispatch('close') + if (onCancel) { + onCancel() + } else { + dispatch('close') + } }} /> diff --git a/plugins/tracker-assets/lang/en.json b/plugins/tracker-assets/lang/en.json index 407cf0f27f..e899fda7b1 100644 --- a/plugins/tracker-assets/lang/en.json +++ b/plugins/tracker-assets/lang/en.json @@ -100,6 +100,8 @@ "IssueTitlePlaceholder": "Issue title", "IssueDescriptionPlaceholder": "Add description", "AddIssueTooltip": "Add issue...", + "NewIssueDialogClose": "Do you want to close this dialog?", + "NewIssueDialogCloseNote": "All changes will be lost", "DueDatePopupTitle": "Due on {value}", "DueDatePopupOverdueTitle": "Was due on {value}", "DueDatePopupDescription": "{value, plural, =0 {Today} =1 {Tomorrow} other {# days remaining}}", diff --git a/plugins/tracker-assets/lang/ru.json b/plugins/tracker-assets/lang/ru.json index 82eea5f68d..14fd5b548d 100644 --- a/plugins/tracker-assets/lang/ru.json +++ b/plugins/tracker-assets/lang/ru.json @@ -100,6 +100,8 @@ "IssueTitlePlaceholder": "Имя задачи", "IssueDescriptionPlaceholder": "Описание задачи", "AddIssueTooltip": "Добавить задачу\u2026", + "NewIssueDialogClose": "Вы действительно хотите закрыть окно?", + "NewIssueDialogCloseNote": "Все внесенные изменения будут потеряны", "DueDatePopupTitle": "Срок {value}", "DueDatePopupOverdueTitle": "Должна была завершится {value}", "DueDatePopupDescription": "{value, plural, =0 {Сегодня} =1 {Завтра} other {# дней осталось}}", diff --git a/plugins/tracker-resources/src/components/CreateIssue.svelte b/plugins/tracker-resources/src/components/CreateIssue.svelte index 1680170364..cee5d5db16 100644 --- a/plugins/tracker-resources/src/components/CreateIssue.svelte +++ b/plugins/tracker-resources/src/components/CreateIssue.svelte @@ -300,7 +300,6 @@ sprint: null, subIssues: [], template: undefined, - team: null, title: '' } @@ -329,13 +328,7 @@ return true } - export async function onOutsideClick () { - if (!shouldSaveDraft) { - return - } - - await descriptionBox?.createAttachments() - + function createDraftFromObject () { const newDraft: Data = { issueId: objectId, title: getTitle(object.title), @@ -354,6 +347,17 @@ subIssues } + return newDraft + } + + export async function onOutsideClick () { + if (!shouldSaveDraft) { + return + } + + await descriptionBox?.createAttachments() + + const newDraft = createDraftFromObject() const isEmpty = await isDraftEmpty(newDraft) if (isEmpty) { @@ -610,6 +614,30 @@ } ) } + + async function showConfirmationDialog () { + const newDraft = createDraftFromObject() + const isFormEmpty = await isDraftEmpty(newDraft) + + if (isFormEmpty) { + console.log('isFormEmpty') + dispatch('close') + } else { + showPopup( + MessageBox, + { + label: tracker.string.NewIssueDialogClose, + message: tracker.string.NewIssueDialogCloseNote + }, + 'top', + (result?: boolean) => { + if (result === true) { + dispatch('close') + } + } + ) + } + } { - dispatch('close') - }} + on:close={() => dispatch('close')} createMore={false} + onCancel={showConfirmationDialog} >
diff --git a/plugins/tracker-resources/src/plugin.ts b/plugins/tracker-resources/src/plugin.ts index 3292cdc572..2dabaea063 100644 --- a/plugins/tracker-resources/src/plugin.ts +++ b/plugins/tracker-resources/src/plugin.ts @@ -163,6 +163,8 @@ export default mergeIds(trackerId, tracker, { IssueDescriptionPlaceholder: '' as IntlString, Unassigned: '' as IntlString, AddIssueTooltip: '' as IntlString, + NewIssueDialogClose: '' as IntlString, + NewIssueDialogCloseNote: '' as IntlString, CopyIssueUrl: '' as IntlString, CopyIssueId: '' as IntlString,