From a5bf5ae456399b747ff278b85065f44608eb85c7 Mon Sep 17 00:00:00 2001
From: "hamza.hramchi" <hamza.hramchi@xelians.fr>
Date: Wed, 30 Dec 2020 10:55:11 +0100
Subject: [PATCH] FEAT #15550 TIME 0:05 not being able to save active filters
 in the history

---
 .../history/history-list.component.html       |  2 +-
 .../history/history-list.component.ts         | 33 ++++---------------
 2 files changed, 8 insertions(+), 27 deletions(-)

diff --git a/src/frontend/app/administration/history/history-list.component.html b/src/frontend/app/administration/history/history-list.component.html
index d50e9bfb67..94fcff8b7b 100644
--- a/src/frontend/app/administration/history/history-list.component.html
+++ b/src/frontend/app/administration/history/history-list.component.html
@@ -18,7 +18,7 @@
                 shape="round" size="small" slot="start" color="primary" (click)="clearFilters()" [title]="'lang.clearFilters' | translate">
                 <ion-icon slot="icon-only" name="backspace" color="light"></ion-icon>
             </ion-button>
-                <ion-chip *ngFor="let filter of uniqueArray(this.filters.messageTypes)" [title]="'lang.actions' | translate"  color="light" (click)="removeFilter(filter)">
+                <ion-chip *ngFor="let filter of this.filters.messageTypes" [title]="'lang.actions' | translate"  color="light" (click)="removeFilter(filter)">
                     <ion-icon name="options-outline"></ion-icon>
                     <ion-label>{{ 'lang.' + filter | translate }}</ion-label>
                     <ion-icon name="close-circle"></ion-icon>
diff --git a/src/frontend/app/administration/history/history-list.component.ts b/src/frontend/app/administration/history/history-list.component.ts
index 64fe731365..41a735c676 100644
--- a/src/frontend/app/administration/history/history-list.component.ts
+++ b/src/frontend/app/administration/history/history-list.component.ts
@@ -87,19 +87,15 @@ export class HistoryListComponent {
         this.menu.open('right-menu');
     }
 
-    ionViewWillEnter() { 
+    ionViewWillEnter() {
+        this.filters.messageTypes = [];
+        this.filters.user = '';
+        this.filters.date.start = this.filters.date.end = null;
         this.menu.enable(true, 'left-menu');
         this.menu.enable(true, 'right-menu');
         this.signaturesService.initTemplate(this.rightContent, this.viewContainerRef, 'rightContent');
         this.gesActions();
         this.getDatas();
-        setTimeout(() => {
-            $(".checkedAction").each((index, element) => {
-                if (this.filters.messageTypes.includes($(element).val())) {
-                    $(element).prop("checked", true);
-                }
-            });
-        }, 100);
     }
 
     gesActions() {
@@ -175,8 +171,8 @@ export class HistoryListComponent {
         if (this.filters.date.end !== null) {
             nb++;
         }
-        if (this.uniqueArray(this.filters.messageTypes).length > 0) {
-            nb += this.uniqueArray(this.filters.messageTypes).length;
+        if (this.filters.messageTypes.length > 0) {
+            nb += this.filters.messageTypes.length;
         }
         return nb;
     }
@@ -199,6 +195,7 @@ export class HistoryListComponent {
          });  
         this.filters.user = ''; 
         this.filters.date.start = this.filters.date.end = null;
+        this.getDatas();
     }
 
     removeFilter(filter: any) {
@@ -224,20 +221,4 @@ export class HistoryListComponent {
         }
         this.getDatas();
     }
-
-    // to remove duplicates in array
-    uniqueArray(array: any[]) {
-        let i: number, j: any;
-        const length = array.length;
-        const uniqueArray = [];
-        const obj = {};
-        for (i = 0; i < length; i++) {
-            obj[array[i]] = 0;
-        }
-        for (j in obj) {
-            uniqueArray.push(j);
-        }
-        array = uniqueArray;
-        return array;
-    }
 }
-- 
GitLab