diff --git a/src/frontend/app/document/document.component.html b/src/frontend/app/document/document.component.html index f760de3aa560b5319579cd065e2e404bc30cad2a..22346f39a95508fcc9dc90fe50765b5e2b6a94a5 100644 --- a/src/frontend/app/document/document.component.html +++ b/src/frontend/app/document/document.component.html @@ -96,7 +96,7 @@ <footer class="footer" *ngIf="!this.signaturesService.annotationMode && !freezeSidenavClose"> <button class="btn red" (click)="openDialog()"><i class="fas fa-backspace fa-2x"></i>Refuser</button> <button class="btn green" (click)="openDrawer()" [disabled]="!this.signaturesService.isTaggable">Parapher le document</button> - <button class="btn" (click)="confirmDialog()">Valider<i class="fas fa-check-circle fa-2x"></i></button> + <button class="btn" (click)="confirmDialog('validate')">Valider<i class="fas fa-check-circle fa-2x"></i></button> </footer> <app-drawer></app-drawer> </mat-sidenav-content> diff --git a/src/frontend/app/document/document.component.ts b/src/frontend/app/document/document.component.ts index d34f24c66177ac237f5ea8651a636efe295a05d0..fbfa2ff4c5ccb4cc0aee6e31bb3d4e4f5ce0f3ff 100644 --- a/src/frontend/app/document/document.component.ts +++ b/src/frontend/app/document/document.component.ts @@ -77,6 +77,7 @@ export class DocumentComponent implements OnInit { this.signaturesService.signaturesContent = []; this.signaturesService.notesContent = []; this.mainDocument = data.document; + this.signaturesService.mainDocumentId = this.mainDocument.id; this.docList.push({ 'id': this.mainDocument.id, 'encodedDocument': this.mainDocument.encodedDocument, 'title': this.mainDocument.subject }); this.mainDocument.attachments.forEach((attach: any, index: any) => { this.docList.push({ 'id': attach.id, 'encodedDocument': '', 'title': '' }); @@ -280,10 +281,10 @@ export class DocumentComponent implements OnInit { }); } - confirmDialog(): void { + confirmDialog(mode: any): void { const dialogRef = this.dialog.open(ConfirmModalComponent, { width: '350px', - data: { msg: 'Êtes-vous sûr ?' } + data: { msg: 'Êtes-vous sûr ?', mode : mode } }); dialogRef.afterClosed().subscribe(result => { @@ -369,7 +370,51 @@ export class WarnModalComponent { styleUrls: ['../modal/confirm-modal.component.styl'] }) export class ConfirmModalComponent { - constructor(@Inject(MAT_DIALOG_DATA) public data: any, public dialogRef: MatDialogRef<ConfirmModalComponent>, public signaturesService: SignaturesContentService) { } + constructor(@Inject(MAT_DIALOG_DATA) public data: any, public http: HttpClient, public dialogRef: MatDialogRef<ConfirmModalComponent>, public signaturesService: SignaturesContentService) { } + + confirmDoc () { + const signatures: any[] = []; + if (this.data.mode) { + for (let index = 1; index <= this.signaturesService.totalPage; index++) { + if (this.signaturesService.signaturesContent[index]) { + this.signaturesService.signaturesContent[index].forEach((signature: any) => { + signatures.push( + { + 'fullPath': signature.encodedSignature, + 'height': 'auto', + 'width': this.signaturesService.signWidth, + 'positionX': 1, + 'positionY': 1, + 'page': index, + } + ); + }); + } + if (this.signaturesService.notesContent[index]) { + this.signaturesService.notesContent[index].forEach((note: any) => { + signatures.push( + { + 'fullPath': note.fullPath, + 'height': note.height, + 'width': note.width, + 'positionX': note.positionX, + 'positionY': note.positionY, + 'page': index, + } + ); + }); + } + this.http.put('../rest/documents/' + this.signaturesService.mainDocumentId + '/action', {'action_id': 5, 'signatures': signatures}) + .subscribe(() => { + this.dialogRef.close('sucess'); + }, (err: any) => { + console.log(err); + }); + } + } else { + this.dialogRef.close('sucess'); + } + } } @Component({ @@ -377,6 +422,7 @@ export class ConfirmModalComponent { styleUrls: ['../modal/success-info-valid.styl'] }) export class SuccessInfoValidBottomSheetComponent { + date: Date = new Date(); constructor(private bottomSheetRef: MatBottomSheetRef<SuccessInfoValidBottomSheetComponent>) { } } diff --git a/src/frontend/app/modal/confirm-modal.component.html b/src/frontend/app/modal/confirm-modal.component.html index fe208a824cfaec9623798cad227a38d7ad3f2b5c..eefa55589b5a1858244e2a626fe0cdfe769e1a48 100644 --- a/src/frontend/app/modal/confirm-modal.component.html +++ b/src/frontend/app/modal/confirm-modal.component.html @@ -4,6 +4,6 @@ <p *ngIf="signaturesService.signaturesContent.length == 0">Vous êtes sur le point de valider ce document sans signature !</p> </div> <div mat-dialog-actions> - <button class="btn green" mat-button (click)="this.dialogRef.close('sucess');"><i class="fas fa-check-circle fa-2x"></i> Valider</button> + <button class="btn green" mat-button (click)="confirmDoc();"><i class="fas fa-check-circle fa-2x"></i> Valider</button> <button class="btn red" mat-button cdkFocusInitial (click)="this.dialogRef.close();"><i class="fas fa-times-circle fa-2x"></i> Annuler</button> </div> diff --git a/src/frontend/app/modal/success-info-valid.html b/src/frontend/app/modal/success-info-valid.html index 96509540a4dbd1c0b11922ecf4897f972ee1dff0..13869e89fed257d77a60465901fadc874fa54ee1 100644 --- a/src/frontend/app/modal/success-info-valid.html +++ b/src/frontend/app/modal/success-info-valid.html @@ -2,6 +2,6 @@ <h1><i class="fa fa-thumbs-up fa-4x"></i></h1> <p>Document signé en tant que :</p> - <p style="font-weight:bold;font-size: 30px;">Thierry Lascou (DSI)</p> - <p style="font-weight:bold;font-size: 15px;">le 18/10/2018 à 17h21</p> + <p style="font-weight:bold;font-size: 30px;">Jenny JANE</p> + <p style="font-weight:bold;font-size: 15px;">le {{date | date:'dd/MM/yyyy'}} à {{date | date:'HH:mm'}}</p> </div> diff --git a/src/frontend/app/service/signatures.service.ts b/src/frontend/app/service/signatures.service.ts index 8f447ca8eee09dac768593c701ae08054d6b396b..8fe6b6bc2be6378aa9177b5f0bdd333fc41b6cae 100644 --- a/src/frontend/app/service/signatures.service.ts +++ b/src/frontend/app/service/signatures.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; @Injectable() export class SignaturesContentService { - + mainDocumentId: Number = 0; signaturesContent: any[] = []; notesContent: any[] = []; signaturesList: any[] = []; diff --git a/src/frontend/app/sidebar/sidebar.component.ts b/src/frontend/app/sidebar/sidebar.component.ts index c6ed098ffaaa0177bb23d732d49b135e5ef56355..0e9a660c96d8d43b0e40fc31b6e33b0cf96d9239 100644 --- a/src/frontend/app/sidebar/sidebar.component.ts +++ b/src/frontend/app/sidebar/sidebar.component.ts @@ -3,7 +3,7 @@ import { Observable } from 'rxjs'; import { HttpClient } from '@angular/common/http'; import { Router } from '@angular/router'; import { ScrollEvent } from 'ngx-scroll-event'; -import { MatSidenav } from '@angular/material'; +import { MatSidenav, MatSnackBar } from '@angular/material'; import * as $ from 'jquery'; interface AppState { @@ -24,7 +24,7 @@ export class SidebarComponent implements OnInit { @ViewChild('listContent') listContent: ElementRef; - constructor(public http: HttpClient, private sidenav: MatSidenav, private router: Router) { } + constructor(public http: HttpClient, private sidenav: MatSidenav, private router: Router, public snackBar: MatSnackBar) { } handleScroll(event: ScrollEvent) { if (event.isReachingBottom && !this.loadingList && this.documentsList.length < this.countDocumentsList) { @@ -39,6 +39,13 @@ export class SidebarComponent implements OnInit { this.documentsList = this.documentsList.concat(data.documents); this.loadingList = false; this.listContent.nativeElement.style.overflowY = 'auto'; + this.snackBar.open('Liste des documents actualisée', null, + { + duration: 3000, + panelClass: 'center-snackbar', + verticalPosition: 'top' + } + ); }); } }