report template fix, multi confirmation window support

This commit is contained in:
Timo Bejan 2021-08-17 09:36:55 +03:00
parent e565bc6106
commit 8412e9f9b8
6 changed files with 55 additions and 11 deletions

View File

@ -61,7 +61,9 @@
></div>
<div *ngFor="let template of availableTemplates" class="template">
<div class="name">{{ template.fileName }}</div>
<div class="name">
{{ template.fileName }} {{ template.multiFileReport ? ('reports-screen.multi-file-report' | translate) : '' }}
</div>
<div class="actions">
<iqser-circle-button

View File

@ -13,6 +13,7 @@ import {
import { removeBraces } from '../../../../utils/functions';
import { Toaster } from '../../../../services/toaster.service';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { ConfirmationDialogInput, TitleColors } from '../../../shared/dialogs/confirmation-dialog/confirmation-dialog.component';
interface Placeholder {
placeholder: string;
@ -86,13 +87,32 @@ export class ReportsScreenComponent implements OnInit {
const file = $event.target.files[0];
if (this._isValidFile(file)) {
await this._reportTemplateService.uploadTemplateForm(this._appStateService.activeDossierTemplateId, false, file).toPromise();
if (this._isExcelFile(file)) {
// await this._reportTemplateService.
// uploadTemplateForm(this._appStateService.activeDossierTemplateId, true, file).toPromise();
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) {
await this._reportTemplateService
.uploadTemplateForm(this._appStateService.activeDossierTemplateId, result > 1, file)
.toPromise();
await this._loadReportTemplates();
}
});
} else {
await this._reportTemplateService
.uploadTemplateForm(this._appStateService.activeDossierTemplateId, false, file)
.toPromise();
await this._loadReportTemplates();
}
this._fileInput.nativeElement.value = null;
await this._loadReportTemplates();
} else {
this._toaster.error(_('reports-screen.invalid-upload'));
}

View File

@ -14,9 +14,20 @@
</div>
<div class="dialog-actions">
<button (click)="confirm()" [disabled]="config.requireInput && confirmationDoesNotMatch()" color="primary" mat-flat-button>
<button (click)="confirm(1)" [disabled]="config.requireInput && confirmationDoesNotMatch()" color="primary" mat-flat-button>
{{ config.confirmationText }}
</button>
<button
(click)="confirm(2)"
[disabled]="config.requireInput && confirmationDoesNotMatch()"
color="primary"
mat-flat-button
*ngIf="config.alternativeConfirmationText"
>
{{ config.alternativeConfirmationText }}
</button>
<div (click)="deny()" class="all-caps-label cancel">
{{ config.denyText }}
</div>

View File

@ -16,6 +16,7 @@ export class ConfirmationDialogInput {
question?: string;
details?: string;
confirmationText?: string;
alternativeConfirmationText?: string;
requireInput?: boolean;
denyText?: string;
translateParams?: Record<string, unknown>;
@ -26,6 +27,7 @@ export class ConfirmationDialogInput {
this.question = options?.question || _('common.confirmation-dialog.description');
this.details = options?.details || '';
this.confirmationText = options?.confirmationText || _('common.confirmation-dialog.confirm');
this.alternativeConfirmationText = options?.alternativeConfirmationText;
this.requireInput = options?.requireInput || false;
this.denyText = options?.denyText || _('common.confirmation-dialog.deny');
this.translateParams = options?.translateParams || {};
@ -58,7 +60,7 @@ export class ConfirmationDialogComponent {
@HostListener('window:keyup.enter')
onKeyupEnter() {
if (this.config.requireInput && !this.confirmationDoesNotMatch()) {
this.confirm();
this.confirm(1);
}
}
@ -70,12 +72,12 @@ export class ConfirmationDialogComponent {
this._dialogRef.close();
}
confirm(): void {
this._dialogRef.close(true);
confirm(option: number): void {
this._dialogRef.close(option);
}
translate<T extends ConfirmationDialogInput | string>(obj: T): T {
const translateKeys = ['title', 'question', 'details', 'confirmationText', 'denyText'];
const translateKeys = ['title', 'question', 'details', 'confirmationText', 'alternativeConfirmationText', 'denyText'];
if (typeof obj === 'string') return this._translateService.instant(obj, this.config.translateParams);

View File

@ -360,6 +360,13 @@
"warning": "Warning: this cannot be undone!"
},
"confirmation-dialog": {
"upload-report-template": {
"question": "Please choose if <b>{fileName}</b> is a single or multi-file report template",
"title": "Report Template Upload",
"deny-text": "Cancel Upload",
"confirmation-text": "Upload as single-file report",
"alternate-confirmation-text": "Upload as multi-file report"
},
"assign-file-to-me": {
"question": "This document is currently reviewed by someone else. Do you want to become the reviewer and assign yourself to this document?",
"title": "Re-assign reviewer"
@ -1248,6 +1255,7 @@
},
"reports": "Reports",
"reports-screen": {
"multi-file-report": "(Multi-file)",
"description": "A short text explaining how to create report documents. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.",
"descriptions": {
"dossier-attributes": "This placeholder gets replaced with the value of the dossier attribute <code>{attribute}</code>.",

View File

@ -175,10 +175,11 @@ export class ReportTemplateControllerService {
headers = headers.set('Accept', httpHeaderAcceptSelected);
}
return this.httpClient.request<any>(
return this.httpClient.request(
'get',
`${this.basePath}/templateUpload/${encodeURIComponent(String(dossierTemplateId))}/${encodeURIComponent(String(templateId))}`,
{
responseType: 'blob',
withCredentials: this.configuration.withCredentials,
headers: headers,
observe: observe,