From ee6e3c6b2af39c66e4975fdacafda8a68176cf33 Mon Sep 17 00:00:00 2001 From: Edi Cziszter Date: Mon, 17 Jan 2022 13:33:24 +0200 Subject: [PATCH 1/2] confirmation dialog for template upload with the same name --- .../reports/reports-screen.component.ts | 23 ++++++++++++++++++- apps/red-ui/src/assets/i18n/en.json | 6 +++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen.component.ts index 3d34001ee..1d51481ec 100644 --- a/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen.component.ts @@ -92,6 +92,28 @@ export class ReportsScreenComponent implements OnInit { } const dossierTemplateId = this._dossierTemplatesService.activeDossierTemplateId; + + if (!!this.availableTemplates.find(template => template.fileName === file.name)) { + const data = new ConfirmationDialogInput({ + title: _('confirmation-dialog.report-template-same-name.title'), + question: _('confirmation-dialog.report-template-same-name.question'), + confirmationText: _('confirmation-dialog.report-template-same-name.confirmation-text'), + denyText: _('confirmation-dialog.report-template-same-name.deny-text'), + }); + + this._dialogService.openDialog('confirm', null, data, null, async result => { + if (result) { + await this._openConfirmationDialog(file, dossierTemplateId); + } + }); + } else { + await this._openConfirmationDialog(file, dossierTemplateId); + } + + this._fileInput.nativeElement.value = null; + } + + private async _openConfirmationDialog(file: File, dossierTemplateId: string) { if (this._isExcelFile(file)) { const data = new ConfirmationDialogInput({ title: _('confirmation-dialog.upload-report-template.title'), @@ -113,7 +135,6 @@ export class ReportsScreenComponent implements OnInit { await this._reportTemplateService.uploadTemplateForm(dossierTemplateId, false, file).toPromise(); await this._loadReportTemplates(); } - this._fileInput.nativeElement.value = null; } private async _deleteTemplate(template: IReportTemplate) { diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index fa8141da2..b651fd42b 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -454,6 +454,12 @@ "deny-text": "Cancel Upload", "question": "Please choose if {fileName} is a single or multi-file report template", "title": "Report Template Upload" + }, + "report-template-same-name": { + "confirmation-text": "Yes. Continue upload.", + "deny-text": "No. Cancel Upload", + "question": "There is already a Report Template with the name: {fileName}. Do you wish to continue?", + "title": "Report Template Upload" } }, "content": "Reason", From efa924f3bf7fdf96923f6b25fc68420ba6edf44c Mon Sep 17 00:00:00 2001 From: Edi Cziszter Date: Mon, 17 Jan 2022 14:27:38 +0200 Subject: [PATCH 2/2] some instead of find --- .../admin/screens/reports/reports-screen.component.ts | 2 +- apps/red-ui/src/assets/i18n/de.json | 6 ++++++ apps/red-ui/src/assets/i18n/en.json | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen.component.ts index 1d51481ec..55e61d9a6 100644 --- a/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen.component.ts @@ -93,7 +93,7 @@ export class ReportsScreenComponent implements OnInit { const dossierTemplateId = this._dossierTemplatesService.activeDossierTemplateId; - if (!!this.availableTemplates.find(template => template.fileName === file.name)) { + if (this.availableTemplates.some(template => template.fileName === file.name)) { const data = new ConfirmationDialogInput({ title: _('confirmation-dialog.report-template-same-name.title'), question: _('confirmation-dialog.report-template-same-name.question'), diff --git a/apps/red-ui/src/assets/i18n/de.json b/apps/red-ui/src/assets/i18n/de.json index 3d1ce9f6f..a3ad0ee77 100644 --- a/apps/red-ui/src/assets/i18n/de.json +++ b/apps/red-ui/src/assets/i18n/de.json @@ -449,6 +449,12 @@ "deny-text": "Uploads abbrechen", "question": "Wählen Sie bitte aus, ob {fileName} eine Berichtsvorlage für eine oder für mehrere Dateien ist", "title": "Upload der Berichtsvorlage" + }, + "report-template-same-name": { + "confirmation-text": "", + "deny-text": "", + "question": "{fileName}", + "title": "" } }, "content": "Begründung", diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index b651fd42b..ba5a448b6 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -456,7 +456,7 @@ "title": "Report Template Upload" }, "report-template-same-name": { - "confirmation-text": "Yes. Continue upload.", + "confirmation-text": "Yes. Continue upload", "deny-text": "No. Cancel Upload", "question": "There is already a Report Template with the name: {fileName}. Do you wish to continue?", "title": "Report Template Upload"