From 45c77bd39bbdde33feedcd8c887a2b1efdf778bb Mon Sep 17 00:00:00 2001
From: Alex ORLUC <alex.orluc@maarch.org>
Date: Mon, 2 Dec 2019 17:48:40 +0100
Subject: [PATCH] FEAT #12331 TIME 0:30 add select params processDocument

---
 .../list/list-administration.component.html   | 10 ++-
 .../list/list-administration.component.ts     | 72 ++++++++++++++++++-
 src/frontend/lang/lang-en.ts                  |  1 +
 src/frontend/lang/lang-fr.ts                  |  1 +
 src/frontend/lang/lang-nl.ts                  |  1 +
 5 files changed, 82 insertions(+), 3 deletions(-)

diff --git a/src/frontend/app/administration/basket/list/list-administration.component.html b/src/frontend/app/administration/basket/list/list-administration.component.html
index 98097c5248f..dc3e5b199ad 100644
--- a/src/frontend/app/administration/basket/list/list-administration.component.html
+++ b/src/frontend/app/administration/basket/list/list-administration.component.html
@@ -1,11 +1,19 @@
 <mat-form-field class="eventList" appearance="outline">
     <mat-label>{{lang.eventList}}</mat-label>
-    <mat-select [(ngModel)]="selectedListEvent">
+    <mat-select [(ngModel)]="selectedListEvent" (selectionChange)="changeEventList($event)">
         <mat-option *ngFor="let event of listEvent" [value]="event.value">
             {{lang[event.id]}}
         </mat-option>
     </mat-select>
 </mat-form-field>
+<mat-form-field *ngIf="selectedListEvent === 'processDocument'" class="eventList" appearance="outline">
+    <mat-label>{{lang.tabProcessPosition}}</mat-label>
+    <mat-select [(ngModel)]="selectedProcessTool">
+        <mat-option *ngFor="let tool of processTool" [value]="tool.id">
+            {{tool.label}}
+        </mat-option>
+    </mat-select>
+</mat-form-field>
 <hr />
 <mat-toolbar class="editorTool">
     <span>
diff --git a/src/frontend/app/administration/basket/list/list-administration.component.ts b/src/frontend/app/administration/basket/list/list-administration.component.ts
index c2a21cf718d..3e3dc4fa613 100644
--- a/src/frontend/app/administration/basket/list/list-administration.component.ts
+++ b/src/frontend/app/administration/basket/list/list-administration.component.ts
@@ -157,6 +157,61 @@ export class ListAdministrationComponent implements OnInit {
     selectedListEvent: string = null;
     selectedListEventClone: string = null;
 
+    processTool: any[] = [
+        {
+            id: 'dashboard',
+            icon: 'fas fa-columns',
+            label: this.lang.newsFeed,
+        },
+        {
+            id: 'history',
+            icon: 'fas fa-history',
+            label: this.lang.history,
+        },
+        {
+            id: 'notes',
+            icon: 'fas fa-pen-square',
+            label: this.lang.notesAlt,
+        },
+        {
+            id: 'attachments',
+            icon: 'fas fa-paperclip',
+            label: this.lang.attachments,
+        },
+        {
+            id: 'link',
+            icon: 'fas fa-link',
+            label: this.lang.links,
+        },
+        {
+            id: 'diffusionList',
+            icon: 'fas fa-share-alt',
+            label: this.lang.diffusionList,
+        },
+        {
+            id: 'mails',
+            icon: 'fas fa-envelope',
+            label: this.lang.mailsSentAlt,
+        },
+        {
+            id: 'visa',
+            icon: 'fas fa-list-ol',
+            label: this.lang.visaWorkflow,
+        },
+        {
+            id: 'avis',
+            icon: 'fas fa-comment-alt',
+            label: this.lang.avis,
+        },
+        {
+            id: 'info',
+            icon: 'fas fa-info-circle',
+            label: this.lang.informations,
+        }
+    ];
+    selectedProcessTool: string = null;
+    selectedProcessToolClone: string = null;
+
     @Input('currentBasketGroup') private basketGroup: any;
 
     constructor(public http: HttpClient, private notify: NotificationService) { }
@@ -179,6 +234,9 @@ export class ListAdministrationComponent implements OnInit {
         });
         this.selectedListEvent = this.basketGroup.list_event === null ? 'noEvent' : this.basketGroup.list_event;
         this.selectedListEventClone = this.selectedListEvent;
+
+        this.selectedProcessTool = this.basketGroup.list_event_data === null && this.basketGroup.list_event === 'processDocument' ? 'dashboard' : this.basketGroup.list_event;
+        this.selectedProcessToolClone = this.selectedProcessTool;
         this.displayedSecondaryDataClone = JSON.parse(JSON.stringify(this.displayedSecondaryData));
     }
 
@@ -257,13 +315,14 @@ export class ListAdministrationComponent implements OnInit {
             );
         });
 
-        this.http.put("../../rest/baskets/" + this.basketGroup.basket_id + "/groups/" + this.basketGroup.group_id, { 'list_display': template, 'list_event': this.selectedListEvent })
+        this.http.put("../../rest/baskets/" + this.basketGroup.basket_id + "/groups/" + this.basketGroup.group_id, { 'list_display': template, 'list_event': this.selectedListEvent, 'list_event_data': this.selectedProcessTool })
             .subscribe(() => {
                 this.displayedSecondaryDataClone = JSON.parse(JSON.stringify(this.displayedSecondaryData));
                 this.basketGroup.list_display = template;
                 this.selectedListEvent = this.selectedListEvent === null ? 'noEvent' : this.selectedListEvent;
                 this.basketGroup.list_event = this.selectedListEvent;
                 this.selectedListEventClone = this.selectedListEvent;
+                this.selectedProcessToolClone = this.selectedProcessTool;
                 this.notify.success(this.lang.resultPageUpdated);
             }, (err) => {
                 this.notify.error(err.error.errors);
@@ -282,7 +341,7 @@ export class ListAdministrationComponent implements OnInit {
     }
 
     checkModif() { 
-        if (JSON.stringify(this.displayedSecondaryData) === JSON.stringify(this.displayedSecondaryDataClone) && this.selectedListEvent === this.selectedListEventClone) {
+        if (JSON.stringify(this.displayedSecondaryData) === JSON.stringify(this.displayedSecondaryDataClone) && this.selectedListEvent === this.selectedListEventClone && this.selectedProcessTool === this.selectedProcessToolClone) {
             return true 
         } else {
            return false;
@@ -292,6 +351,7 @@ export class ListAdministrationComponent implements OnInit {
     cancelModification() {
         this.displayedSecondaryData = JSON.parse(JSON.stringify(this.displayedSecondaryDataClone));
         this.selectedListEvent = this.selectedListEventClone;
+        this.selectedProcessTool = this.selectedProcessToolClone;
         this.availableData = JSON.parse(JSON.stringify(this.availableDataClone));
         
         let indexData: number = 0;
@@ -309,4 +369,12 @@ export class ListAdministrationComponent implements OnInit {
             return false;
         }
     }
+
+    changeEventList(ev: any) {
+        if (ev.value === 'processDocument') {
+            this.selectedProcessTool = 'dashboard';
+        } else {
+            this.selectedProcessTool = null;
+        }
+    }
 }
diff --git a/src/frontend/lang/lang-en.ts b/src/frontend/lang/lang-en.ts
index 62d42e264f8..2674ee55162 100755
--- a/src/frontend/lang/lang-en.ts
+++ b/src/frontend/lang/lang-en.ts
@@ -1317,4 +1317,5 @@ export const LANG_EN = {
     "enableGroupMsg": "This group could access to all functionnalities.",
     "sendActivationNotification": "Send activation notification",
     "activationNotificationSend": "Activation notification send",
+    "tabProcessPosition": "Move to tab"
 };
diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts
index a08739e927c..9d98f50f214 100755
--- a/src/frontend/lang/lang-fr.ts
+++ b/src/frontend/lang/lang-fr.ts
@@ -1355,4 +1355,5 @@ export const LANG_FR = {
     "enableGroupMsg": "Ce groupe pourra potentiellement avoir accès à l'ensemble des fonctionnalités de l'application.",
     "sendActivationNotification": "Envoyer à nouveau le courriel d'activation",
     "activationNotificationSend": "Le courriel d'activation a été envoyé",
+    "tabProcessPosition": "Se positionner sur l'onglet"
 };
diff --git a/src/frontend/lang/lang-nl.ts b/src/frontend/lang/lang-nl.ts
index 7eded88d385..a4a30783dc4 100755
--- a/src/frontend/lang/lang-nl.ts
+++ b/src/frontend/lang/lang-nl.ts
@@ -1342,4 +1342,5 @@ export const LANG_NL = {
     "enableGroupMsg": "This group could access to all functionnalities.", //_TO_TRANSLATE
     "sendActivationNotification": "Send activation notification", //_TO_TRANSLATE
     "activationNotificationSend": "Activation notification send", //_TO_TRANSLATE
+    "tabProcessPosition": "Move to tab" //_TO_TRANSLATE
 };
-- 
GitLab