RED-4514: Allow multi-file report upload for all files

This commit is contained in:
Adina Țeudan 2022-07-11 23:30:02 +03:00
parent c8af658d06
commit 5918ca03e6
2 changed files with 35 additions and 42 deletions

View File

@ -50,10 +50,6 @@ export class ReportsScreenComponent implements OnInit {
this._loadingService.stop(); this._loadingService.stop();
} }
uploadTemplate($event) {
this._loadingService.loadWhile(this._uploadTemplate($event));
}
async download(template: IReportTemplate) { async download(template: IReportTemplate) {
this._loadingService.start(); this._loadingService.start();
try { try {
@ -74,17 +70,7 @@ export class ReportsScreenComponent implements OnInit {
}); });
} }
private _getAttributeName(placeholder: string): string { uploadTemplate($event) {
return removeBraces(placeholder).split('.').pop();
}
private _getPlaceholderDescriptionTranslation(type: PlaceholderType, placeholder: string): string {
return type === 'generalPlaceholders'
? generalPlaceholdersDescriptionsTranslations[removeBraces(placeholder)]
: placeholdersDescriptionsTranslations[type];
}
private async _uploadTemplate($event) {
const file: File = $event.target.files[0]; const file: File = $event.target.files[0];
if (!this._isValidFile(file)) { if (!this._isValidFile(file)) {
@ -103,40 +89,47 @@ export class ReportsScreenComponent implements OnInit {
}, },
}); });
this._dialogService.openDialog('confirm', null, data, null, async result => { this._dialogService.openDialog('confirm', null, data, null, result => {
if (result) { if (result) {
await this._openConfirmationDialog(file); this._openConfirmationDialog(file);
} }
}); });
} else { } else {
await this._openConfirmationDialog(file); this._openConfirmationDialog(file);
} }
this._fileInput.nativeElement.value = null; this._fileInput.nativeElement.value = null;
} }
private async _openConfirmationDialog(file: File) { private _getAttributeName(placeholder: string): string {
if (this._isExcelFile(file)) { return removeBraces(placeholder).split('.').pop();
const data = new ConfirmationDialogInput({ }
title: _('confirmation-dialog.upload-report-template.title'),
question: _('confirmation-dialog.upload-report-template.question'), private _getPlaceholderDescriptionTranslation(type: PlaceholderType, placeholder: string): string {
confirmationText: _('confirmation-dialog.upload-report-template.confirmation-text'), return type === 'generalPlaceholders'
denyText: _('confirmation-dialog.upload-report-template.deny-text'), ? generalPlaceholdersDescriptionsTranslations[removeBraces(placeholder)]
alternativeConfirmationText: _('confirmation-dialog.upload-report-template.alternate-confirmation-text'), : placeholdersDescriptionsTranslations[type];
translateParams: { }
fileName: file.name,
}, private _openConfirmationDialog(file: File): void {
}); const data = new ConfirmationDialogInput({
this._dialogService.openDialog('confirm', null, data, null, async result => { title: _('confirmation-dialog.upload-report-template.title'),
if (result) { question: _('confirmation-dialog.upload-report-template.question'),
await firstValueFrom(this._reportTemplateService.uploadTemplateForm(this.#dossierTemplateId, result > 1, file)); confirmationText: _('confirmation-dialog.upload-report-template.confirmation-text'),
await this._loadReportTemplates(); denyText: _('confirmation-dialog.upload-report-template.deny-text'),
} alternativeConfirmationText: _('confirmation-dialog.upload-report-template.alternate-confirmation-text'),
}); translateParams: {
} else { fileName: file.name,
await firstValueFrom(this._reportTemplateService.uploadTemplateForm(this.#dossierTemplateId, false, file)); },
await this._loadReportTemplates(); });
} 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();
}
});
} }
private async _deleteTemplate(template: IReportTemplate) { private async _deleteTemplate(template: IReportTemplate) {

View File

@ -1,7 +1,7 @@
{ {
"ADMIN_CONTACT_NAME": null, "ADMIN_CONTACT_NAME": null,
"ADMIN_CONTACT_URL": null, "ADMIN_CONTACT_URL": null,
"API_URL": "https://dev-08.iqser.cloud/redaction-gateway-v1", "API_URL": "https://dev-05.iqser.cloud/redaction-gateway-v1",
"APP_NAME": "RedactManager", "APP_NAME": "RedactManager",
"AUTO_READ_TIME": 3, "AUTO_READ_TIME": 3,
"BACKEND_APP_VERSION": "4.4.40", "BACKEND_APP_VERSION": "4.4.40",
@ -11,7 +11,7 @@
"MAX_RETRIES_ON_SERVER_ERROR": 3, "MAX_RETRIES_ON_SERVER_ERROR": 3,
"OAUTH_CLIENT_ID": "redaction", "OAUTH_CLIENT_ID": "redaction",
"OAUTH_IDP_HINT": null, "OAUTH_IDP_HINT": null,
"OAUTH_URL": "https://dev-08.iqser.cloud/auth/realms/redaction", "OAUTH_URL": "https://dev-05.iqser.cloud/auth/realms/redaction",
"RECENT_PERIOD_IN_HOURS": 24, "RECENT_PERIOD_IN_HOURS": 24,
"SELECTION_MODE": "structural", "SELECTION_MODE": "structural",
"MANUAL_BASE_URL": "https://docs.redactmanager.com/preview" "MANUAL_BASE_URL": "https://docs.redactmanager.com/preview"