From 7d9bd20f1c2e1539e8120106aad5e916f1f7fe16 Mon Sep 17 00:00:00 2001
From: Alex ORLUC <alex.orluc@maarch.org>
Date: Thu, 7 Jan 2021 11:38:21 +0000
Subject: [PATCH] FEAT #15677 TIME 0:45 fix load history in panel + remove
 modal

(cherry picked from commit 79e90f92ed05e6f5c6f45e66e0fb525ead891805)
---
 src/frontend/app/app-common.module.ts         |  8 ----
 .../diffusions/diffusions-list.component.html | 41 +++++++++++++------
 .../diffusions/diffusions-list.component.ts   |  6 +--
 .../history-diffusions-list.component.scss    |  7 ----
 ...story-diffusions-list-modal.component.html | 10 -----
 ...story-diffusions-list-modal.component.scss |  0
 ...history-diffusions-list-modal.component.ts | 16 --------
 .../app/process/process.component.html        |  4 +-
 src/frontend/app/profile.component.css        |  0
 .../history-visa-workflow.component.scss      |  7 ----
 ...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     | 18 +++++---
 .../app/visa/visa-workflow.component.ts       |  5 ---
 15 files changed, 44 insertions(+), 104 deletions(-)
 delete mode 100644 src/frontend/app/diffusions/history/modal/history-diffusions-list-modal.component.html
 delete mode 100644 src/frontend/app/diffusions/history/modal/history-diffusions-list-modal.component.scss
 delete mode 100644 src/frontend/app/diffusions/history/modal/history-diffusions-list-modal.component.ts
 mode change 100755 => 100644 src/frontend/app/profile.component.css
 delete mode 100644 src/frontend/app/visa/history/modal/history-visa-workflow-modal.component.html
 delete mode 100644 src/frontend/app/visa/history/modal/history-visa-workflow-modal.component.scss
 delete 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 0b5d180a270..a879fd64297 100755
--- a/src/frontend/app/app-common.module.ts
+++ b/src/frontend/app/app-common.module.ts
@@ -61,10 +61,8 @@ import { HistoryComponent } from './history/history.component';
 
 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';
@@ -120,7 +118,6 @@ import { CriteriaToolComponent } from '@appRoot/search/criteria-tool/criteria-to
         PluginSelectAutocompleteSearchComponent,
         DiffusionsListComponent,
         HistoryDiffusionsListComponent,
-        HistoryDiffusionsListModalComponent,
         DragDropDirective,
         ContactAutocompleteComponent,
         ContactsFormComponent,
@@ -128,7 +125,6 @@ import { CriteriaToolComponent } from '@appRoot/search/criteria-tool/criteria-to
         AddressBanAutocompleteComponent,
         VisaWorkflowComponent,
         HistoryVisaWorkflowComponent,
-        HistoryVisaWorkflowModalComponent,
         AvisWorkflowComponent,
         MaarchTreeComponent,
         MaarchFlatTreeComponent,
@@ -168,7 +164,6 @@ import { CriteriaToolComponent } from '@appRoot/search/criteria-tool/criteria-to
         PluginSelectAutocompleteSearchComponent,
         DiffusionsListComponent,
         HistoryDiffusionsListComponent,
-        HistoryDiffusionsListModalComponent,
         DragDropDirective,
         ContactAutocompleteComponent,
         ContactsFormComponent,
@@ -176,7 +171,6 @@ import { CriteriaToolComponent } from '@appRoot/search/criteria-tool/criteria-to
         AddressBanAutocompleteComponent,
         VisaWorkflowComponent,
         HistoryVisaWorkflowComponent,
-        HistoryVisaWorkflowModalComponent,
         AvisWorkflowComponent,
         MaarchTreeComponent,
         MaarchFlatTreeComponent,
@@ -200,8 +194,6 @@ import { CriteriaToolComponent } from '@appRoot/search/criteria-tool/criteria-to
     entryComponents: [
         IndexingGroupModalComponent,
         RegisteredMailImportComponent,
-        HistoryDiffusionsListModalComponent,
-        HistoryVisaWorkflowModalComponent,
         AlertComponent,
         ConfirmComponent
     ],
diff --git a/src/frontend/app/diffusions/diffusions-list.component.html b/src/frontend/app/diffusions/diffusions-list.component.html
index 4a47ebf4c98..641b0580d73 100644
--- a/src/frontend/app/diffusions/diffusions-list.component.html
+++ b/src/frontend/app/diffusions/diffusions-list.component.html
@@ -1,11 +1,14 @@
 <ng-container *ngIf="!loading">
-    <plugin-autocomplete *ngIf="adminMode && canUpdateRoles()" #test [labelPlaceholder]="'lang.addUserOrEntity' | translate"
+    <plugin-autocomplete *ngIf="adminMode && canUpdateRoles()" #test
+        [labelPlaceholder]="'lang.addUserOrEntity' | translate"
         [routeDatas]="['/rest/autocomplete/users','/rest/autocomplete/entities']" [targetSearchKey]="'idToDisplay'"
-        [subInfoKey]="'descriptionToDisplay'" (triggerEvent)="addElem($event)" appearance="ouline"></plugin-autocomplete>
+        [subInfoKey]="'descriptionToDisplay'" (triggerEvent)="addElem($event)" appearance="ouline">
+    </plugin-autocomplete>
     <div *ngIf="isEmptyList() && !loading" style="text-align:center;font-size:24px;font-weight:bold;opacity:0.3;">
         {{'lang.noDiffusionList' | translate}}
     </div>
-    <div *ngIf="hasNoDest" class="alert-message alert-message-danger" role="alert" [innerHTML]="'lang.diffNoDestmsg' | translate"></div>
+    <div *ngIf="hasNoDest" class="alert-message alert-message-danger" role="alert"
+        [innerHTML]="'lang.diffNoDestmsg' | translate"></div>
     <ng-container *ngFor="let role of availableRoles">
         <mat-expansion-panel *ngIf="diffList[role.id].items.length > 0" class="diffusionList"
             [expanded]="role.id === 'dest' || this.adminMode || expanded">
@@ -20,13 +23,14 @@
                     *ngFor="let diffusion of diffList[role.id].items;let i=index">
                     <mat-icon mat-list-icon color="primary" class="fa"
                         [class.fa-user]="diffusion.item_type === 'user_id' || diffusion.item_type === 'user'"
-                        [class.fa-sitemap]="diffusion.item_type === 'entity_id' || diffusion.item_type === 'entity'"></mat-icon>
+                        [class.fa-sitemap]="diffusion.item_type === 'entity_id' || diffusion.item_type === 'entity'">
+                    </mat-icon>
                     <div class="item-diffusion">
                         <p mat-line [title]="diffusion.itemLabel">{{diffusion.itemLabel}}</p>
                         <p mat-line class="subInfo" [title]="diffusion.itemSubLabel">
                             {{diffusion.itemSubLabel}}</p>
                     </div>
-                    <div *ngIf="role.id === 'dest' && target === 'redirect' && adminMode" >
+                    <div *ngIf="role.id === 'dest' && target === 'redirect' && adminMode">
                         <button mat-icon-button (click)="loadDestUserList()" [matMenuTriggerFor]="menuDestUserList"
                             title="{{'lang.chooseAnotherEntityUser' | translate}}">
                             <mat-icon class="fa fa-edit" color="primary"></mat-icon>
@@ -37,19 +41,22 @@
                             </button>
                         </mat-menu>
                     </div>
-                    <div *ngIf="role.id !== 'dest' && adminMode && (diffusion.item_type === 'user_id' || diffusion.item_type === 'user')">
+                    <div
+                        *ngIf="role.id !== 'dest' && adminMode && (diffusion.item_type === 'user_id' || diffusion.item_type === 'user')">
                         <button mat-button [matMenuTriggerFor]="menu" [disabled]="!canUpdateRoles()">{{role.label}} <i
                                 class="fa fa-chevron-down"></i></button>
                         <mat-menu #menu="matMenu" [class]="'roleListMenu'">
                             <ng-container *ngFor="let selectRole of availableRoles">
-                                <button mat-menu-item *ngIf="(selectRole.canUpdate && target !== 'redirect')  || (selectRole.id !== 'dest' && target === 'redirect' && selectRole.canUpdate)"
+                                <button mat-menu-item
+                                    *ngIf="(selectRole.canUpdate && target !== 'redirect')  || (selectRole.id !== 'dest' && target === 'redirect' && selectRole.canUpdate)"
                                     (click)="changeRole(diffusion,role,selectRole)"
                                     style="font-size:13px;">{{selectRole.label}}</button>
                             </ng-container>
                         </mat-menu>
                     </div>
                     <div *ngIf="role.id !== 'dest' && adminMode">
-                        <button mat-icon-button color="warn" (click)="deleteItem(role.id,i)" [disabled]="!canUpdateRoles()">
+                        <button mat-icon-button color="warn" (click)="deleteItem(role.id,i)"
+                            [disabled]="!canUpdateRoles()">
                             <mat-icon class="fa fa-trash" style="height:auto;"></mat-icon>
                         </button>
                     </div>
@@ -61,8 +68,16 @@
 <div *ngIf="loading" style="display:flex;">
     <mat-spinner style="margin:auto;"></mat-spinner>
 </div>
-<div style="text-align: right;">
-    <button mat-button color="primary" (click)="openHistory()" *ngIf="!loading && hasHistory">
-        {{'lang.showDiffusionHistory' | translate}}
-    </button>
-</div>
+<ng-container *ngIf="!loading && hasHistory">
+    <mat-divider></mat-divider>
+    <mat-expansion-panel style="box-shadow: none;">
+        <mat-expansion-panel-header>
+            <mat-panel-title color="primary">
+                {{'lang.showDiffusionHistory' | translate}}
+            </mat-panel-title>
+        </mat-expansion-panel-header>
+        <ng-template matExpansionPanelContent>
+            <app-history-diffusions-list [resId]="resId" style="display: contents;"></app-history-diffusions-list>
+        </ng-template>
+    </mat-expansion-panel>
+</ng-container>
\ No newline at end of file
diff --git a/src/frontend/app/diffusions/diffusions-list.component.ts b/src/frontend/app/diffusions/diffusions-list.component.ts
index c1b10215979..2da33a13023 100644
--- a/src/frontend/app/diffusions/diffusions-list.component.ts
+++ b/src/frontend/app/diffusions/diffusions-list.component.ts
@@ -10,7 +10,6 @@ import { AlertComponent } from '../../plugins/modal/alert.component';
 import { MatDialog } from '@angular/material/dialog';
 import { FunctionsService } from '@service/functions.service';
 import { HeaderService } from '@service/header.service';
-import { HistoryDiffusionsListModalComponent } from './history/modal/history-diffusions-list-modal.component';
 
 @Component({
     selector: 'app-diffusions-list',
@@ -299,6 +298,7 @@ export class DiffusionsListComponent implements OnInit {
     }
 
     async loadListinstance(resId: number) {
+        this.resId = resId;
         this.http.get(`../rest/resources/${resId}/fields/destination?alt=true`).pipe(
             tap((data: any) => {
                 this.currentEntityId = data.field;
@@ -667,8 +667,4 @@ export class DiffusionsListComponent implements OnInit {
     isModified() {
         return JSON.stringify(this.listinstanceClone) !== JSON.stringify(this.getCurrentListinstance());
     }
-
-    openHistory() {
-        this.dialog.open(HistoryDiffusionsListModalComponent, { panelClass: 'maarch-modal', autoFocus: false, data: { resId: this.resId} });
-    }
 }
diff --git a/src/frontend/app/diffusions/history/history-diffusions-list.component.scss b/src/frontend/app/diffusions/history/history-diffusions-list.component.scss
index d9b622cfb85..284fa60bddf 100644
--- a/src/frontend/app/diffusions/history/history-diffusions-list.component.scss
+++ b/src/frontend/app/diffusions/history/history-diffusions-list.component.scss
@@ -73,11 +73,4 @@
         font-size: 13px;
         color: #4A4A4A;
     }
-}
-
-.dateTitle {
-    position: sticky;
-    top: 0px;
-    z-index: 2;
-    background: white;
 }
\ No newline at end of file
diff --git a/src/frontend/app/diffusions/history/modal/history-diffusions-list-modal.component.html b/src/frontend/app/diffusions/history/modal/history-diffusions-list-modal.component.html
deleted file mode 100644
index 6c9d50f24dc..00000000000
--- a/src/frontend/app/diffusions/history/modal/history-diffusions-list-modal.component.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<div class="mat-dialog-content-container">
-    <h1 mat-dialog-title>{{'lang.diffusionHistory' | translate}}</h1>
-    <div mat-dialog-content style="padding-top: 0px;">
-        <app-history-diffusions-list [resId]="data.resId" style="display: contents;"></app-history-diffusions-list>
-    </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/diffusions/history/modal/history-diffusions-list-modal.component.scss b/src/frontend/app/diffusions/history/modal/history-diffusions-list-modal.component.scss
deleted file mode 100644
index e69de29bb2d..00000000000
diff --git a/src/frontend/app/diffusions/history/modal/history-diffusions-list-modal.component.ts b/src/frontend/app/diffusions/history/modal/history-diffusions-list-modal.component.ts
deleted file mode 100644
index 658b23a901f..00000000000
--- a/src/frontend/app/diffusions/history/modal/history-diffusions-list-modal.component.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { Component,  Inject,  OnInit, Renderer2 } from '@angular/core';
-import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
-
-@Component({
-    templateUrl: 'history-diffusions-list-modal.component.html',
-    styleUrls: ['history-diffusions-list-modal.component.scss'],
-})
-export class HistoryDiffusionsListModalComponent implements OnInit {
-    constructor(
-        public dialog: MatDialog,
-        @Inject(MAT_DIALOG_DATA) public data: any,
-        public dialogRef: MatDialogRef<HistoryDiffusionsListModalComponent>,
-    ) { }
-
-    ngOnInit() { }
-}
diff --git a/src/frontend/app/process/process.component.html b/src/frontend/app/process/process.component.html
index 0de1f8eb286..d2442615fe7 100644
--- a/src/frontend/app/process/process.component.html
+++ b/src/frontend/app/process/process.component.html
@@ -331,8 +331,8 @@
                 </app-document-viewer>
             </div>
         </div>
-        <div class="modal-module {{modal.id}}" cdkDrag *ngFor="let modal of modalModule; let i=index"
-            [class.largeModal]="modal.id === 'info' || modal.id === 'history'" cdkDragBoundary=".process-content">
+        <div class="modal-module {{modal.id}} largeModal" cdkDrag *ngFor="let modal of modalModule; let i=index"
+            cdkDragBoundary=".process-content">
             <div class="modal-module-title" cdkDragHandle>
                 <span>
                     {{modal.label}}
diff --git a/src/frontend/app/profile.component.css b/src/frontend/app/profile.component.css
old mode 100755
new mode 100644
diff --git a/src/frontend/app/visa/history/history-visa-workflow.component.scss b/src/frontend/app/visa/history/history-visa-workflow.component.scss
index 2994df0aab4..360c8464bd1 100644
--- a/src/frontend/app/visa/history/history-visa-workflow.component.scss
+++ b/src/frontend/app/visa/history/history-visa-workflow.component.scss
@@ -75,13 +75,6 @@
     }
 }
 
-.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/modal/history-visa-workflow-modal.component.html b/src/frontend/app/visa/history/modal/history-visa-workflow-modal.component.html
deleted file mode 100644
index 39e0e32830a..00000000000
--- a/src/frontend/app/visa/history/modal/history-visa-workflow-modal.component.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<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
deleted file mode 100644
index e69de29bb2d..00000000000
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
deleted file mode 100644
index f1e0b18be26..00000000000
--- a/src/frontend/app/visa/history/modal/history-visa-workflow-modal.component.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-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 999d0816e55..e2a12649151 100755
--- a/src/frontend/app/visa/visa-workflow.component.html
+++ b/src/frontend/app/visa/visa-workflow.component.html
@@ -135,8 +135,16 @@
 <div *ngIf="loading" style="display:flex;padding: 10px;">
     <mat-spinner style="margin:auto;"></mat-spinner>
 </div>
-<div style="text-align: right;" *ngIf="!loading && hasHistory">
-    <button mat-button color="primary" (click)="openHistory()">
-        {{'lang.showVisaWorkflowHistory' | translate}}
-    </button>
-</div>
+<ng-container *ngIf="!loading && hasHistory">
+    <mat-divider></mat-divider>
+    <mat-expansion-panel style="box-shadow: none;">
+        <mat-expansion-panel-header>
+            <mat-panel-title color="primary">
+                {{'lang.showVisaWorkflowHistory' | translate}}
+            </mat-panel-title>
+        </mat-expansion-panel-header>
+        <ng-template matExpansionPanelContent>
+            <app-history-visa-workflow [resId]="resId" style="display: contents;"></app-history-visa-workflow>
+        </ng-template>
+    </mat-expansion-panel>
+</ng-container>
\ 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 ffd75a440a3..1b20a158297 100644
--- a/src/frontend/app/visa/visa-workflow.component.ts
+++ b/src/frontend/app/visa/visa-workflow.component.ts
@@ -13,7 +13,6 @@ import { AddVisaModelModalComponent } from './addVisaModel/add-visa-model-modal.
 import { ConfirmComponent } from '@plugins/modal/confirm.component';
 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',
@@ -656,8 +655,4 @@ export class VisaWorkflowComponent implements OnInit {
             return false;
         }
     }
-
-    openHistory() {
-        this.dialog.open(HistoryVisaWorkflowModalComponent, { panelClass: 'maarch-modal', autoFocus: false, data: { resId: this.resId } });
-    }
 }
-- 
GitLab