From 92b68fbd9002ec954a37c6344113123919a9c8d7 Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Thu, 17 Dec 2020 15:20:20 +0100 Subject: [PATCH] FEAT #15016 TIME 0:45 WIP history visa workflow --- src/frontend/app/app-common.module.ts | 7 + .../history-visa-workflow.component.html | 33 ++++ .../history-visa-workflow.component.scss | 87 ++++++++++ .../history-visa-workflow.component.ts | 148 ++++++++++++++++++ ...history-visa-workflow-modal.component.html | 10 ++ ...history-visa-workflow-modal.component.scss | 0 .../history-visa-workflow-modal.component.ts | 16 ++ .../app/visa/visa-workflow.component.html | 5 + .../app/visa/visa-workflow.component.ts | 17 +- src/lang/lang-fr.json | 4 +- 10 files changed, 321 insertions(+), 6 deletions(-) create mode 100644 src/frontend/app/visa/history/history-visa-workflow.component.html create mode 100644 src/frontend/app/visa/history/history-visa-workflow.component.scss create mode 100644 src/frontend/app/visa/history/history-visa-workflow.component.ts create mode 100644 src/frontend/app/visa/history/modal/history-visa-workflow-modal.component.html create mode 100644 src/frontend/app/visa/history/modal/history-visa-workflow-modal.component.scss create mode 100644 src/frontend/app/visa/history/modal/history-visa-workflow-modal.component.ts diff --git a/src/frontend/app/app-common.module.ts b/src/frontend/app/app-common.module.ts index 9e6a0c75109..b4fa417e728 100755 --- a/src/frontend/app/app-common.module.ts +++ b/src/frontend/app/app-common.module.ts @@ -63,6 +63,8 @@ import { DiffusionsListComponent } from './diffusions/diffusions-list.component' import { HistoryDiffusionsListComponent } from './diffusions/history/history-diffusions-list.component'; import { HistoryDiffusionsListModalComponent } from './diffusions/history/modal/history-diffusions-list-modal.component'; import { VisaWorkflowComponent } from './visa/visa-workflow.component'; +import { HistoryVisaWorkflowComponent } from './visa/history/history-visa-workflow.component'; +import { HistoryVisaWorkflowModalComponent } from './visa/history/modal/history-visa-workflow-modal.component'; import { AvisWorkflowComponent } from './avis/avis-workflow.component'; import { ContactResourceComponent } from './contact/contact-resource/contact-resource.component'; @@ -125,6 +127,8 @@ import { CriteriaToolComponent } from '@appRoot/search/criteria-tool/criteria-to HistoryComponent, AddressBanAutocompleteComponent, VisaWorkflowComponent, + HistoryVisaWorkflowComponent, + HistoryVisaWorkflowModalComponent, AvisWorkflowComponent, MaarchTreeComponent, MaarchFlatTreeComponent, @@ -171,6 +175,8 @@ import { CriteriaToolComponent } from '@appRoot/search/criteria-tool/criteria-to HistoryComponent, AddressBanAutocompleteComponent, VisaWorkflowComponent, + HistoryVisaWorkflowComponent, + HistoryVisaWorkflowModalComponent, AvisWorkflowComponent, MaarchTreeComponent, MaarchFlatTreeComponent, @@ -195,6 +201,7 @@ import { CriteriaToolComponent } from '@appRoot/search/criteria-tool/criteria-to IndexingGroupModalComponent, RegisteredMailImportComponent, HistoryDiffusionsListModalComponent, + HistoryVisaWorkflowModalComponent, AlertComponent, ConfirmComponent ], diff --git a/src/frontend/app/visa/history/history-visa-workflow.component.html b/src/frontend/app/visa/history/history-visa-workflow.component.html new file mode 100644 index 00000000000..1460f96e81c --- /dev/null +++ b/src/frontend/app/visa/history/history-visa-workflow.component.html @@ -0,0 +1,33 @@ +<ng-container *ngIf="!loading"> + <ng-container *ngFor="let visaWorkflow of visaWorkflowHistory"> + <mat-list> + <div class="dateTitle"> + <div mat-subheader class="primary" [title]="visaWorkflow.creationDate | fullDate"> + Actif <b>{{visaWorkflow.creationDate | timeAgo : 'full'}}</b> par <b>{{visaWorkflow.user}}</b> + </div> + <mat-divider></mat-divider> + </div> + <mat-list-item disableRipple *ngFor="let diffusion of visaWorkflow.items;let i=index" class="workflow"> + <mat-icon class="fa fa-2x fa-user" mat-list-icon color="primary"> + </mat-icon> + <div mat-line class="workflowLine"> + <div class="workflowLineContainer"> + <div class="workflowLineLabel"> + {{diffusion.labelToDisplay}} + </div> + <div class="workflowLineSubLabel"> + {{diffusion.item_entity}} + </div> + </div> + <div> + <button class="currentRoleButton" color="primary" disabled mat-raised-button + title="{{'lang.' + diffusion.currentRole + 'User' | translate}}">{{diffusion.requested_signature ? ('lang.signUser' | translate) : ('lang.visaUser' | translate)}}</button> + </div> + </div> + </mat-list-item> + </mat-list> + </ng-container> +</ng-container> +<div *ngIf="loading" style="display:flex;padding: 10px;"> + <mat-spinner style="margin:auto;"></mat-spinner> +</div> \ No newline at end of file diff --git a/src/frontend/app/visa/history/history-visa-workflow.component.scss b/src/frontend/app/visa/history/history-visa-workflow.component.scss new file mode 100644 index 00000000000..2994df0aab4 --- /dev/null +++ b/src/frontend/app/visa/history/history-visa-workflow.component.scss @@ -0,0 +1,87 @@ +@import '../../../css/vars.scss'; + +.mat-form-field-appearance-outline { + font-size: 11px; +} + +.visaSignList { + ::ng-deep.mat-optgroup-label { + color: $primary; + position: sticky; + top: 0px; + background: white !important; + z-index: 1; + } +} + +.currentRoleButton { + overflow: hidden; + text-overflow: ellipsis; + font-size: 13px; + width: 120px; + text-align: center; +} + +.emptyContent { + opacity: 0.5; + text-align: center; + font-size: 10px; + padding: 10px; +} + +.workflow { + padding-top: 10px; + padding-bottom: 10px; + height: auto !important; + margin-bottom: 10px; + background: rgba(216, 216, 216, 0.1); + border-radius: 10px; + font-size: 13px; +} + +.workflowLine { + display: flex !important; + align-items: center; + + &Container { + flex: 1; + overflow: hidden; + text-overflow: ellipsis; + } + + &Label { + text-overflow: ellipsis; + overflow: hidden; + } + + &SubLabel { + font-size: 80%; + opacity: 0.5; + flex: 1; + text-overflow: ellipsis; + overflow: hidden; + } + + &ProcessDate { + flex: 1; + text-align: left; + font-size: 80%; + } + + .mat-raised-button[disabled] { + background: none; + color: $primary !important; + opacity: 1; + } +} + +.dateTitle { + position: sticky; + top: 0px; + z-index: 2; + background: white; +} + +.primary { + color: $primary; +} \ No newline at end of file diff --git a/src/frontend/app/visa/history/history-visa-workflow.component.ts b/src/frontend/app/visa/history/history-visa-workflow.component.ts new file mode 100644 index 00000000000..0fbe516c807 --- /dev/null +++ b/src/frontend/app/visa/history/history-visa-workflow.component.ts @@ -0,0 +1,148 @@ +import { Component, Input, OnInit } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { TranslateService } from '@ngx-translate/core'; +import { NotificationService } from '@service/notification/notification.service'; +import { FunctionsService } from '@service/functions.service'; +import { tap, catchError, finalize } from 'rxjs/operators'; +import { of } from 'rxjs'; +import { MatDialog } from '@angular/material/dialog'; + + +@Component({ + selector: 'app-history-visa-workflow', + templateUrl: 'history-visa-workflow.component.html', + styleUrls: ['history-visa-workflow.component.scss'], +}) +export class HistoryVisaWorkflowComponent implements OnInit { + + visaWorkflowHistory: any[] = []; + + loading: boolean = false; + data: any; + + @Input() resId: number = null; + + constructor( + public translate: TranslateService, + public http: HttpClient, + private notify: NotificationService, + public functions: FunctionsService, + public dialog: MatDialog, + ) { } + + ngOnInit(): void { + if (!this.functions.empty(this.resId)) { + this.loadWorkflowHistory(); + } + this.loading = false; + } + + + loadWorkflowHistory() { + this.loading = true; + this.visaWorkflowHistory = [ + { + user: 'Bernard BLIER', + creationDate: '2020-10-06 17:02:19.558904', + 'items': [ + { + 'listinstance_id': 101, + 'sequence': 0, + 'item_id': 7, + 'item_type': 'user', + 'item_firstname': 'Edith', + 'item_lastname': 'ERINA', + 'item_entity': 'Cabinet du Maire', + 'viewed': 0, + 'process_date': '2020-11-02 16:51:00.635663', + 'process_comment': null, + 'signatory': false, + 'requested_signature': true, + 'delegate': null, + 'isValid': false, + 'labelToDisplay': 'Edith ERINA', + 'delegatedBy': null, + 'hasPrivilege': true, + 'difflist_type': 'VISA_CIRCUIT' + }, + { + 'listinstance_id': 102, + 'sequence': 1, + 'item_id': 26, + 'item_type': 'user', + 'item_firstname': 'test', + 'item_lastname': 'test', + 'item_entity': 'Service Courrier', + 'viewed': 0, + 'process_date': '2020-11-30 09:35:11.06508', + 'process_comment': null, + 'signatory': false, + 'requested_signature': false, + 'delegate': 21, + 'isValid': true, + 'labelToDisplay': 'Bernard BLIER', + 'delegatedBy': 'test test', + 'hasPrivilege': true, + 'difflist_type': 'VISA_CIRCUIT' + }, + { + 'listinstance_id': 103, + 'sequence': 2, + 'item_id': 18, + 'item_type': 'user', + 'item_firstname': 'Denis', + 'item_lastname': 'DAULL', + 'item_entity': 'Secrétariat Général', + 'viewed': 0, + 'process_date': null, + 'process_comment': null, + 'signatory': false, + 'requested_signature': false, + 'delegate': null, + 'isValid': true, + 'labelToDisplay': 'Denis DAULL', + 'delegatedBy': null, + 'hasPrivilege': true, + 'difflist_type': 'VISA_CIRCUIT' + }, + { + 'listinstance_id': 104, + 'sequence': 3, + 'item_id': 6, + 'item_type': 'user', + 'item_firstname': 'Jenny', + 'item_lastname': 'JANE', + 'item_entity': 'Centre Communal d\'Action Sociale', + 'viewed': 0, + 'process_date': null, + 'process_comment': null, + 'signatory': false, + 'requested_signature': false, + 'delegate': null, + 'isValid': true, + 'labelToDisplay': 'Jenny JANE', + 'delegatedBy': null, + 'hasPrivilege': true, + 'difflist_type': 'VISA_CIRCUIT' + } + ] + } + ]; + + /* return new Promise((resolve, reject) => { + this.http.get(`../rest/resources/${this.resId}/visaCircuitHistory`).pipe( + tap((data: any) => { + + }), + finalize(() => { + this.loading = false; + resolve(true); + }), + catchError((err: any) => { + this.notify.handleSoftErrors(err); + return of(false); + }) + ).subscribe(); + });*/ + } +} diff --git a/src/frontend/app/visa/history/modal/history-visa-workflow-modal.component.html b/src/frontend/app/visa/history/modal/history-visa-workflow-modal.component.html new file mode 100644 index 00000000000..39e0e32830a --- /dev/null +++ b/src/frontend/app/visa/history/modal/history-visa-workflow-modal.component.html @@ -0,0 +1,10 @@ +<div class="mat-dialog-content-container"> + <h1 mat-dialog-title>{{'lang.visaWorkflowHistory' | translate}}</h1> + <div mat-dialog-content style="padding-top: 0px;"> + <app-history-visa-workflow [resId]="data.resId" style="display: contents;"></app-history-visa-workflow> + </div> + <span class="divider-modal"></span> + <div mat-dialog-actions class="actions"> + <button mat-raised-button mat-button [mat-dialog-close]="">{{'lang.close' | translate}}</button> + </div> +</div> diff --git a/src/frontend/app/visa/history/modal/history-visa-workflow-modal.component.scss b/src/frontend/app/visa/history/modal/history-visa-workflow-modal.component.scss new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/frontend/app/visa/history/modal/history-visa-workflow-modal.component.ts b/src/frontend/app/visa/history/modal/history-visa-workflow-modal.component.ts new file mode 100644 index 00000000000..f1e0b18be26 --- /dev/null +++ b/src/frontend/app/visa/history/modal/history-visa-workflow-modal.component.ts @@ -0,0 +1,16 @@ +import { Component, Inject, OnInit } from '@angular/core'; +import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; + +@Component({ + templateUrl: 'history-visa-workflow-modal.component.html', + styleUrls: ['history-visa-workflow-modal.component.scss'], +}) +export class HistoryVisaWorkflowModalComponent implements OnInit { + constructor( + public dialog: MatDialog, + @Inject(MAT_DIALOG_DATA) public data: any, + public dialogRef: MatDialogRef<HistoryVisaWorkflowModalComponent>, + ) { } + + ngOnInit() { } +} diff --git a/src/frontend/app/visa/visa-workflow.component.html b/src/frontend/app/visa/visa-workflow.component.html index 4de97a80b4a..7586290f178 100755 --- a/src/frontend/app/visa/visa-workflow.component.html +++ b/src/frontend/app/visa/visa-workflow.component.html @@ -133,3 +133,8 @@ <div *ngIf="loading" style="display:flex;padding: 10px;"> <mat-spinner style="margin:auto;"></mat-spinner> </div> +<div style="text-align: right;"> + <button mat-button color="primary" (click)="openHistory()"> + {{'lang.showVisaWorkflowHistory' | translate}} + </button> +</div> \ No newline at end of file diff --git a/src/frontend/app/visa/visa-workflow.component.ts b/src/frontend/app/visa/visa-workflow.component.ts index 0a1c443b3b6..fe11412800d 100644 --- a/src/frontend/app/visa/visa-workflow.component.ts +++ b/src/frontend/app/visa/visa-workflow.component.ts @@ -1,4 +1,4 @@ -import {Component, Input, OnInit, ElementRef, ViewChild, Output, EventEmitter} from '@angular/core'; +import { Component, Input, OnInit, ElementRef, ViewChild, Output, EventEmitter } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { TranslateService } from '@ngx-translate/core'; import { NotificationService } from '@service/notification/notification.service'; @@ -11,8 +11,9 @@ import { Observable, of, Subject } from 'rxjs'; import { MatDialog } from '@angular/material/dialog'; import { AddVisaModelModalComponent } from './addVisaModel/add-visa-model-modal.component'; import { ConfirmComponent } from '../../plugins/modal/confirm.component'; -import {ActivatedRoute} from "@angular/router"; -import {PrivilegeService} from '@service/privileges.service'; +import { ActivatedRoute } from '@angular/router'; +import { PrivilegeService } from '@service/privileges.service'; +import { HistoryVisaWorkflowModalComponent } from './history/modal/history-visa-workflow-modal.component'; @Component({ selector: 'app-visa-workflow', @@ -103,7 +104,7 @@ export class VisaWorkflowComponent implements OnInit { moveItemInArray(event.container.data, event.previousIndex, event.currentIndex); this.workflowUpdated.emit(event.container); } else { - this.notify.error(this.translate.instant('lang.moveVisaUserErr', {value1: this.visaWorkflow.items[event.previousIndex].labelToDisplay})); + this.notify.error(this.translate.instant('lang.moveVisaUserErr', { value1: this.visaWorkflow.items[event.previousIndex].labelToDisplay })); } } } @@ -297,6 +298,8 @@ export class VisaWorkflowComponent implements OnInit { difflist_type: 'VISA_CIRCUIT' }); }); + console.log(this.visaWorkflow); + this.visaWorkflowClone = JSON.parse(JSON.stringify(this.visaWorkflow.items)) }), finalize(() => { @@ -406,7 +409,7 @@ export class VisaWorkflowComponent implements OnInit { }*/ getNextVisaUser() { - let index = this.getCurrentVisaUserIndex(); + let index = this.getCurrentVisaUserIndex(); index = index + 1; const realIndex = this.getRealIndex(index); @@ -642,4 +645,8 @@ export class VisaWorkflowComponent implements OnInit { return false; } } + + openHistory() { + this.dialog.open(HistoryVisaWorkflowModalComponent, { panelClass: 'maarch-modal', autoFocus: false, data: { resId: this.resId } }); + } } diff --git a/src/lang/lang-fr.json b/src/lang/lang-fr.json index b80e74fb8ce..9dcce81c4c7 100644 --- a/src/lang/lang-fr.json +++ b/src/lang/lang-fr.json @@ -2191,5 +2191,7 @@ "confirmRescanToNotDistributed": "Ce recommandé a déjà été scanné «Distribué». Voulez-vous le rescanner en «Non distribué» ?", "selectReturnReason": "Veuillez sélectionner un motif de retour", "diffusionHistory": "Historique de diffusion", - "showDiffusionHistory": "Afficher l'historique de diffusion" + "showDiffusionHistory": "Afficher l'historique de diffusion", + "visaWorkflowHistory": "Historique du circuit de visa", + "showVisaWorkflowHistory": "Afficher l'historique du circuit de visa" } -- GitLab