diff --git a/lang/fr.json b/lang/fr.json index 8911826ba1f095adaf4a06decd88c5147abac78a..12825abea8cceb92c96ad881f020a04b0bccd333 100755 --- a/lang/fr.json +++ b/lang/fr.json @@ -328,8 +328,8 @@ "attachDocToSign": "Annexe attaché au(x) document(s) à signer", "titleSearch": "Sujet du document à signer", "referenceSearch": "Référence du document à signer", - "workflowStateSearch": "État du circuit", - "usersWorkflowSearch": "Personne du circuit", + "workflowStatesSearch": "État du circuit", + "workflowUsersSearch": "Personne du circuit", "end": "Terminé", "interrupt": "Interrompu", "inprogress": "En cours", @@ -338,6 +338,8 @@ "newWorkflow": "Nouveau circuit...", "proof": "Faisceau de preuve", "processing": "Traitement", - "mandatory": "Obligatoire" + "mandatory": "Obligatoire", + "addReason": "Saisir un motif", + "refused": "Refusé" } } diff --git a/src/frontend/app/document/document.component.ts b/src/frontend/app/document/document.component.ts index eab0076290d060306c9edca57a06924da9b8c353..49e6fa18aea19998e3e114451c9d619f171d5957 100755 --- a/src/frontend/app/document/document.component.ts +++ b/src/frontend/app/document/document.component.ts @@ -315,7 +315,6 @@ export class DocumentComponent implements OnInit { 'modes': item.userSignatureModes }; }); - console.log(this.mainDocument.workflow); this.totalPages = this.mainDocument.pages; @@ -574,12 +573,11 @@ export class DocumentComponent implements OnInit { header: this.translate.instant('lang.warning'), message: this.translate.instant('lang.areYouSure'), inputs: [ - // multiline input. { name: 'paragraph', id: 'paragraph', type: 'textarea', - placeholder: this.translate.instant('lang.addNote') + placeholder: this.translate.instant('lang.addReason') }, ], buttons: [ @@ -587,7 +585,7 @@ export class DocumentComponent implements OnInit { text: this.translate.instant('lang.rejectDocument'), handler: () => { this.loadingController.create({ - message: 'Envoi ...', + message: this.translate.instant('lang.processing') + ' ...', spinner: 'dots' }).then(async (load: HTMLIonLoadingElement) => { load.present(); @@ -614,12 +612,20 @@ export class DocumentComponent implements OnInit { cssClass: 'custom-alert-success', header: this.translate.instant('lang.warning'), message: this.signaturesService.signaturesContent.length === 0 && this.signaturesService.notesContent.length === 0 ? this.translate.instant('lang.validateDocumentWithoutSignOrNote') : this.translate.instant('lang.areYouSure'), + inputs: [ + { + name: 'paragraph', + id: 'paragraph', + type: 'textarea', + placeholder: this.translate.instant('lang.addReason') + }, + ], buttons: [ { text: this.translate.instant('lang.validate'), handler: () => { this.loadingController.create({ - message: 'Envoi ...', + message: this.translate.instant('lang.processing') + ' ...', spinner: 'dots' }).then(async (load: HTMLIonLoadingElement) => { load.present(); diff --git a/src/frontend/app/document/visa-workflow/visa-workflow.component.ts b/src/frontend/app/document/visa-workflow/visa-workflow.component.ts index 3755f009c6b5cb6b24598e547b64e9a2e2c09243..510fc43b2ffbb4bb4dca678ca13f349300ec7e50 100644 --- a/src/frontend/app/document/visa-workflow/visa-workflow.component.ts +++ b/src/frontend/app/document/visa-workflow/visa-workflow.component.ts @@ -138,4 +138,10 @@ export class VisaWorkflowComponent implements OnInit { getRole(id: string) { return this.authService.signatureRoles.filter((mode: any) => mode.id === id)[0]; } + + loadWorkflow(workflow: any) { + console.log('loadWorkflow', workflow); + + this.visaWorkflow = workflow; + } } diff --git a/src/frontend/app/indexation/indexation.component.ts b/src/frontend/app/indexation/indexation.component.ts index 4e3442087049c602155ac190706a12e3892610b0..b6c527c8b7c075e3586ccd392419bf280b5027a8 100644 --- a/src/frontend/app/indexation/indexation.component.ts +++ b/src/frontend/app/indexation/indexation.component.ts @@ -1,7 +1,7 @@ import { DatePipe } from '@angular/common'; import { HttpClient } from '@angular/common/http'; import { Component, OnInit, TemplateRef, ViewChild, ViewContainerRef } from '@angular/core'; -import { Router } from '@angular/router'; +import { Route, Router } from '@angular/router'; import { AlertController, LoadingController, MenuController } from '@ionic/angular'; import { TranslateService } from '@ngx-translate/core'; import { of } from 'rxjs'; @@ -21,6 +21,7 @@ export class IndexationComponent implements OnInit { loading: boolean = false; filesToUpload: any[] = []; errors: any[] = []; + fromDocument: number = null; @ViewChild('appVisaWorkflow', { static: false }) appVisaWorkflow: VisaWorkflowComponent; @ViewChild('rightContent', { static: true }) rightContent: TemplateRef<any>; @@ -46,6 +47,81 @@ export class IndexationComponent implements OnInit { this.menu.enable(true, 'right-menu'); this.signaturesService.initTemplate(this.rightContent, this.viewContainerRef, 'rightContent'); + + if (window.history.state.documentId !== undefined) { + this.fromDocument = window.history.state.documentId; + this.getDocumentData(this.fromDocument); + } + } + + getDocumentData(resId: number) { + return new Promise((resolve) => { + this.http.get(`../rest/documents/${resId}`).pipe( + tap((data: any) => { + this.filesToUpload.push({ + title: data.document.title, + reference: '', + mainDocument: true, + content: '', + linkId : data.document.linkId, + metadata : data.document.metadata, + }); + this.getDocumentContent(resId); + this.appVisaWorkflow.loadWorkflow(data.document.workflow.map((item: any) => { + item.userSignatureModes.unshift('visa'); + return { + ...item, + 'processDate': null, + 'current': false, + 'role': item.mode === 'visa' ? 'visa' : item.signatureMode, + 'modes': item.userSignatureModes + }; + })); + for (let index = 0; index < data.document.attachments.length; index++) { + this.getAttachment(data.document.attachments[index].id); + } + resolve(true); + }), + catchError((err: any) => { + this.notificationService.handleErrors(err); + return of(false); + }) + ).subscribe(); + }); + } + + getDocumentContent(resId: number) { + return new Promise((resolve) => { + this.http.get(`../rest/documents/${resId}/content`).pipe( + tap((data: any) => { + this.filesToUpload[0].content = data.encodedDocument; + resolve(true); + }), + catchError((err: any) => { + this.notificationService.handleErrors(err); + return of(false); + }) + ).subscribe(); + }); + } + + getAttachment(attachId: number) { + return new Promise((resolve) => { + this.http.get(`../rest/attachments/${attachId}`).pipe( + tap((data: any) => { + this.filesToUpload.push({ + title: data.attachment.title, + mainDocument: false, + content: data.attachment.encodedDocument + }); + resolve(true); + }), + catchError((err: any) => { + this.notificationService.handleErrors(err); + return of(false); + }) + ).subscribe(); + }); } ionViewWillLeave() { @@ -123,10 +199,10 @@ export class IndexationComponent implements OnInit { let linkId: string = null; if (note !== '') { - noteObj = { - value : note, - creator : `${this.authService.user.firstname} ${this.authService.user.lastname}`, - creationDate : this.datePipe.transform(today, 'dd-MM-y') + noteObj = { + value: note, + creator: `${this.authService.user.firstname} ${this.authService.user.lastname}`, + creationDate: this.datePipe.transform(today, 'dd-MM-y') }; } @@ -141,10 +217,10 @@ export class IndexationComponent implements OnInit { signedFiles.forEach((file: any) => { formattedObj.push({ title: file.title, - reference : this.datePipe.transform(today, 'y/MM/dd') + '/' + file.reference, + reference: this.datePipe.transform(today, 'y/MM/dd') + '/' + file.reference, encodedDocument: file.content, isZipped: false, - linkId: linkId, + linkId: this.fromDocument !== null ? file.linkId : linkId, sender: `${this.authService.user.firstname} ${this.authService.user.lastname}`, notes: noteObj, attachments: attachFiles.map((item: any) => { @@ -159,7 +235,8 @@ export class IndexationComponent implements OnInit { mode: this.authService.getWorkflowMode(item.role), signatureMode: this.authService.getSignatureMode(item.role) }; - }) + }), + metadata : this.fromDocument !== null ? file.metadata : [] }); }); @@ -191,7 +268,7 @@ export class IndexationComponent implements OnInit { reader.onload = (value: any) => { file.mainDocument = this.filesToUpload.length === 0; file.reference = this.filesToUpload.length === 0 ? file.reference : '', - file.content = this.getBase64Document(value.target.result); + file.content = this.getBase64Document(value.target.result); this.filesToUpload.push(file); }; } diff --git a/src/frontend/app/search/search.component.html b/src/frontend/app/search/search.component.html index 9b505872b3468e23769fbebd5701c34c40891da5..ab93ad5f3fc4eeb42d40c3a7df440df54316ab1c 100644 --- a/src/frontend/app/search/search.component.html +++ b/src/frontend/app/search/search.component.html @@ -28,7 +28,7 @@ <ion-icon *ngIf="i>0" name="chevron-forward-outline"></ion-icon> <span class="workflow-item success" [class.success]="itemW.processDate!==null" [class.typist-interrupt]="itemW.status==='REF'" - [class.interrupt]="itemW.processDate===null && itemW.status==='END'" + [class.interrupt]="itemW.processDate===null && ['END','STOP'].indexOf(itemW.status) > -1" [class.current]="itemW.current" [class.no-visa]="itemW.processDate===null && itemW.status===null && !itemW.current">{{itemW.userDisplay}} <ion-icon *ngIf="itemW.processDate!==null && itemW.status!=='REF'" @@ -36,7 +36,7 @@ <ion-icon *ngIf="itemW.processDate!==null && itemW.status==='REF'" name="thumbs-down-outline"></ion-icon> <ion-badge - *ngIf="itemW.processDate===null && (itemW.status===null || itemW.status==='END')" + *ngIf="itemW.processDate===null && (itemW.status===null || ['END','STOP'].indexOf(itemW.status) > -1)" color="medium">{{itemW.mode}}</ion-badge> </span> </ng-container> @@ -45,18 +45,15 @@ </ion-toolbar> <ion-item-sliding #slidingItem> <ion-item lines="none"> - <ion-icon *ngIf="element.status == 'SIGN'" color="primary" slot="start" name="pencil-outline"> + <ion-icon *ngIf="element.state == 'PROG'" color="primary" slot="start" name="hourglass-outline"> </ion-icon> - <ion-icon *ngIf="element.status == 'VISA'" color="primary" slot="start" - name="checkmark-done-outline"> + <ion-icon *ngIf="element.state == 'STOP'" color="primary" slot="start" + name="hand-left-outline"> </ion-icon> - <ion-icon *ngIf="element.status == 'NOTE'" color="primary" slot="start" - name="chatbubble-ellipses-outline"> - </ion-icon> - <ion-icon *ngIf="element.status == 'VAL'" color="success" slot="start" + <ion-icon *ngIf="element.state == 'VAL'" color="success" slot="start" name="thumbs-up-outline"> </ion-icon> - <ion-icon *ngIf="element.status == 'REF'" color="danger" slot="start" + <ion-icon *ngIf="element.state == 'REF'" color="danger" slot="start" name="thumbs-down-outline"> </ion-icon> <ion-label> diff --git a/src/frontend/app/search/search.component.ts b/src/frontend/app/search/search.component.ts index cab63b3ab161ee163bd7b354bb3fe602e8035d1f..8ed94f2f98f23be4f4c248e6141a66b31ec0d45f 100644 --- a/src/frontend/app/search/search.component.ts +++ b/src/frontend/app/search/search.component.ts @@ -36,26 +36,30 @@ export class SearchComponent implements OnInit { values: [] }, { - id: 'workflowState', + id: 'workflowStates', type: 'checkbox', val: [], values: [ { - id: 'INPROGRESS', + id: 'PROG', label: 'lang.inprogress' }, { - id: 'INTERRUPT', + id: 'STOP', label: 'lang.interrupt' }, { - id: 'END', + id: 'VAL', label: 'lang.end' + }, + { + id: 'REF', + label: 'lang.refused' } ] }, { - id: 'usersWorkflow', + id: 'workflowUsers', type: 'autocompleteUsers', val: [], values: [] @@ -138,7 +142,7 @@ export class SearchComponent implements OnInit { text: this.translate.instant('lang.' + element.id), icon: element.icon, handler: () => { - this[element.id](); + this[element.id](item); } }); }); @@ -209,26 +213,8 @@ export class SearchComponent implements OnInit { await alert.present(); } - async newWorkflow() { - const alert = await this.alertController.create({ - header: this.translate.instant('lang.warning'), - message: this.translate.instant('lang.areYouSure'), - buttons: [ - { - text: this.translate.instant('lang.cancel'), - role: 'cancel', - cssClass: 'secondary', - handler: () => { } - }, - { - text: this.translate.instant('lang.validate'), - handler: () => { - this.router.navigate(['/indexation']); - } - } - ] - }); - await alert.present(); + async newWorkflow(item: any) { + this.router.navigate(['/indexation'], { state: { documentId: item.id } }); } async openPromptProof(item: any) {