diff --git a/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen/reports-screen.component.ts b/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen/reports-screen.component.ts index b9f5c4a6d..ac8c10e67 100644 --- a/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen/reports-screen.component.ts +++ b/apps/red-ui/src/app/modules/admin/screens/reports/reports-screen/reports-screen.component.ts @@ -78,25 +78,25 @@ export class ReportsScreenComponent implements OnInit { return; } - if (this.availableTemplates$.value.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'), - confirmationText: _('confirmation-dialog.report-template-same-name.confirmation-text'), - denyText: _('confirmation-dialog.report-template-same-name.deny-text'), - translateParams: { - fileName: file.name, - }, - }); - - this._dialogService.openDialog('confirm', null, data, null, result => { - if (result) { - this._openConfirmationDialog(file); + const data = new ConfirmationDialogInput({ + title: _('confirmation-dialog.upload-report-template.title'), + question: _('confirmation-dialog.upload-report-template.question'), + confirmationText: _('confirmation-dialog.upload-report-template.confirmation-text'), + denyText: _('confirmation-dialog.upload-report-template.deny-text'), + alternativeConfirmationText: _('confirmation-dialog.upload-report-template.alternate-confirmation-text'), + translateParams: { + fileName: file.name, + }, + }); + this._dialogService.openDialog('confirm', null, data, null, async result => { + if (result) { + if (this.availableTemplates$.value.some(template => template.fileName === file.name)) { + await this._openOverwriteConfirmationDialog(file, result > 1); + } else { + await this._uploadTemplateForm(file, result > 1); } - }); - } else { - this._openConfirmationDialog(file); - } + } + }); this._fileInput.nativeElement.value = null; } @@ -111,27 +111,31 @@ export class ReportsScreenComponent implements OnInit { : placeholdersDescriptionsTranslations[type]; } - private _openConfirmationDialog(file: File): void { + private async _openOverwriteConfirmationDialog(file: File, multiFileReport: boolean): Promise { const data = new ConfirmationDialogInput({ - title: _('confirmation-dialog.upload-report-template.title'), - question: _('confirmation-dialog.upload-report-template.question'), - confirmationText: _('confirmation-dialog.upload-report-template.confirmation-text'), - denyText: _('confirmation-dialog.upload-report-template.deny-text'), - alternativeConfirmationText: _('confirmation-dialog.upload-report-template.alternate-confirmation-text'), + 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'), translateParams: { fileName: file.name, }, }); + this._dialogService.openDialog('confirm', null, data, null, async result => { if (result) { - this._loadingService.start(); - await firstValueFrom(this._reportTemplateService.uploadTemplateForm(this.#dossierTemplateId, result > 1, file)); - await this._loadReportTemplates(); - this._loadingService.stop(); + await this._uploadTemplateForm(file, multiFileReport); } }); } + private async _uploadTemplateForm(file: File, multiFileReport: boolean): Promise { + this._loadingService.start(); + await firstValueFrom(this._reportTemplateService.uploadTemplateForm(this.#dossierTemplateId, multiFileReport, file)); + await this._loadReportTemplates(); + this._loadingService.stop(); + } + private async _deleteTemplate(template: IReportTemplate) { await firstValueFrom(this._reportTemplateService.delete(template.dossierTemplateId, template.templateId)); await this._loadReportTemplates();