diff --git a/src/frontend/app/printedFolder/printed-folder-modal.component.html b/src/frontend/app/printedFolder/printed-folder-modal.component.html index 81c642b3a8abe2be94177aca848bd910bd1bb247..79c68f132c0f9756c357e38aa56cde70eeba510f 100644 --- a/src/frontend/app/printedFolder/printed-folder-modal.component.html +++ b/src/frontend/app/printedFolder/printed-folder-modal.component.html @@ -10,6 +10,9 @@ <mat-spinner style="margin:auto;"></mat-spinner> </div> <ng-template #loadingTemplate> + <div class="example-loading-shade" *ngIf="isLoadingResults"> + <mat-spinner *ngIf="isLoadingResults"></mat-spinner> + </div> <div style="padding: 10px;"> <mat-slide-toggle color="primary" [(ngModel)]="summarySheet" (change)="$event.checked ? openSummarySheet() : false">{{lang.attachSummarySheet}}</mat-slide-toggle> @@ -40,26 +43,26 @@ </mat-expansion-panel-header> <mat-selection-list [formControl]="selectedPrintedFolderElement[keyVal.key]" color="primary" class="printedFolderElement-content"> - <mat-list-option class="printedFolderElement-option" checkboxPosition="before" - *ngFor="let element of printedFolderElement[keyVal.key]" [value]="element.id"> - <div class="printedFolderElement-item"> - <div color="primary" style="flex:1;font-size: 80%" + <mat-list-option class="printedFolderElement-option" [class.disabled]="!element.canConvert" checkboxPosition="before" + *ngFor="let element of printedFolderElement[keyVal.key]" [disabled]="!element.canConvert" [value]="element.id"> + <div class="printedFolderElement-item {{keyVal.key}}"> + <div color="primary" style="flex:1;font-size: 80%;padding-right: 10px;" *ngIf="!functions.empty(element.chrono)"> {{element.chrono}} </div> - <div color="primary" style="flex:1;display: flex;font-size: 80%;white-space: pre;" + <div color="primary" style="flex:1;display: flex;font-size: 80%;white-space: pre;padding-right: 10px;" *ngIf="!functions.empty(element.recipients)"> {{lang.for | ucfirst}} : {{element.recipients}} </div> <div *ngIf="!functions.empty(element.creator)" color="primary" - style="flex:1;font-size: 80%"> + style="flex:1;font-size: 80%;padding-right: 10px;"> {{element.creator}} </div> - <div style="flex:2" [title]="element.label" + <div style="flex:2;padding-right: 10px;" [title]="element.label" [innerHTML]="element.label | shorten: 150: '...'"> </div> <div *ngIf="!functions.empty(element.type)" color="primary" - style="flex:1;font-size: 80%"> + style="flex:1;font-size: 80%;white-space: pre;padding-right: 10px;"> {{element.type}} </div> @@ -79,6 +82,6 @@ </mat-dialog-content> <div mat-dialog-actions class="actions"> - <button mat-raised-button color="primary" [disabled]="isEmptySelection()" + <button mat-raised-button color="primary" [disabled]="isLoadingResults || isEmptySelection()" (click)="onSubmit()">{{lang.validate}}</button> </div> \ No newline at end of file diff --git a/src/frontend/app/printedFolder/printed-folder-modal.component.scss b/src/frontend/app/printedFolder/printed-folder-modal.component.scss index 31f1fc865360603ba763b74dee7f2a6f62e51ec7..8635fc8cd78082dbe9ddc73f2b77b801f29d74f3 100644 --- a/src/frontend/app/printedFolder/printed-folder-modal.component.scss +++ b/src/frontend/app/printedFolder/printed-folder-modal.component.scss @@ -48,10 +48,16 @@ &-item { font-size: 14px !important; align-items: center; - display: flex; + display: grid; + grid-template-columns: 1fr 2fr 1fr; + grid-gap: 20px; } } +.attachments { + grid-template-columns: 1fr 2fr 1fr 1fr; +} + .printedFolderContainer { display: grid; grid-template-columns: 1fr; @@ -60,4 +66,9 @@ .mat-expansion-panel-header[aria-disabled="true"] { color: initial !important; +} + +.disabled { + opacity: 0.5; + cursor: not-allowed; } \ No newline at end of file diff --git a/src/frontend/app/printedFolder/printed-folder-modal.component.ts b/src/frontend/app/printedFolder/printed-folder-modal.component.ts index b138cc6206c7c70e2355e876a323c42c0fdf98f7..490be6b8c28e5a8e962d224ae7520db0448d8e5f 100644 --- a/src/frontend/app/printedFolder/printed-folder-modal.component.ts +++ b/src/frontend/app/printedFolder/printed-folder-modal.component.ts @@ -3,7 +3,7 @@ import { MAT_DIALOG_DATA, MatDialogRef, MatDialog } from '@angular/material/dial import { LANG } from '../translate.component'; import { HttpClient } from '@angular/common/http'; import { NotificationService } from '../notification.service'; -import { map, tap, catchError } from 'rxjs/operators'; +import { map, tap, catchError, finalize } from 'rxjs/operators'; import { of } from 'rxjs'; import { FunctionsService } from '../../service/functions.service'; import { FormControl } from '@angular/forms'; @@ -26,6 +26,7 @@ export class PrintedFolderModalComponent { mainDocument: boolean = false; summarySheet: boolean = false; withSeparator: boolean = false; + isLoadingResults: boolean = false; printedFolderElement: any = { attachments: [], @@ -70,6 +71,7 @@ export class PrintedFolderModalComponent { chrono: !this.functions.empty(attachment.chrono) ? attachment.chrono : this.lang.undefined, type: attachment.typeLabel, creationDate: attachment.creationDate, + canConvert : attachment.canConvert } }); return data.attachments; @@ -98,6 +100,7 @@ export class PrintedFolderModalComponent { recipients: item.recipients, creationDate: item.creation_date, label: !this.functions.empty(item.object) ? item.object : `<i>${this.lang.emptySubject}<i>`, + canConvert : true } }) return data.emails; @@ -126,6 +129,7 @@ export class PrintedFolderModalComponent { creator: `${item.firstname} ${item.lastname}`, creationDate: item.creation_date, label: item.value, + canConvert : true } }) return data.notes; @@ -167,7 +171,8 @@ export class PrintedFolderModalComponent { sender: false, recipients: item.format === 'html' ? email : name, creationDate: item.creationDate, - label: item.format === 'html' ? this.lang.ARelectronic : this.lang.ARPaper + label: item.format === 'html' ? this.lang.ARelectronic : this.lang.ARPaper, + canConvert : true } }) return data; @@ -189,13 +194,15 @@ export class PrintedFolderModalComponent { toggleAllElements(state: boolean, type: any) { if (state) { - this.selectedPrintedFolderElement[type].setValue(this.printedFolderElement[type].map((item: any) => item.id)); + this.selectedPrintedFolderElement[type].setValue(this.printedFolderElement[type].filter((item: any) => item.canConvert).map((item: any) => item.id)); } else { this.selectedPrintedFolderElement[type].setValue([]); } } onSubmit() { + this.isLoadingResults = true; + this.http.post(`../../rest/resources/folderPrint`, this.formatPrintedFolder(), { responseType: "blob" }).pipe( tap((data: any) => { let downloadLink = document.createElement('a'); @@ -221,6 +228,7 @@ export class PrintedFolderModalComponent { document.body.appendChild(downloadLink); downloadLink.click(); }), + finalize(() => this.isLoadingResults = false), catchError((err: any) => { this.notify.handleSoftErrors(err); return of(false);