From 6cd7e70d2fc8e4f8fa6fe9ec47475a40cfe320cf Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Fri, 9 Nov 2018 16:04:36 +0100 Subject: [PATCH] FEAT #8754 add send document action --- .../app/document/document.component.html | 2 +- .../app/document/document.component.ts | 52 +++++++++++++++++-- .../app/modal/confirm-modal.component.html | 2 +- .../app/modal/success-info-valid.html | 4 +- .../app/service/signatures.service.ts | 2 +- src/frontend/app/sidebar/sidebar.component.ts | 11 +++- 6 files changed, 63 insertions(+), 10 deletions(-) diff --git a/src/frontend/app/document/document.component.html b/src/frontend/app/document/document.component.html index f760de3aa5..22346f39a9 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 d34f24c661..fbfa2ff4c5 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 fe208a824c..eefa55589b 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 96509540a4..13869e89fe 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 8f447ca8ee..8fe6b6bc2b 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 c6ed098ffa..0e9a660c96 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' + } + ); }); } } -- GitLab