Skip to content
Snippets Groups Projects
Commit d0809df5 authored by Hamza HRAMCHI's avatar Hamza HRAMCHI
Browse files

FEAT #15550 TIME 0:20 fix duplicate filters

parent a1b5a9f5
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
shape="round" size="small" slot="start" color="primary" (click)="clearFilters()" [title]="'lang.clearFilters' | translate"> 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-icon slot="icon-only" name="backspace" color="light"></ion-icon>
</ion-button> </ion-button>
<ion-chip *ngFor="let filter of filters.messageTypes" [title]="'lang.actions' | translate" color="light" (click)="removeFilter(filter)"> <ion-chip *ngFor="let filter of uniqueArray(this.filters.messageTypes)" [title]="'lang.actions' | translate" color="light" (click)="removeFilter(filter)">
<ion-icon name="options-outline"></ion-icon> <ion-icon name="options-outline"></ion-icon>
<ion-label>{{ 'lang.' + filter | translate }}</ion-label> <ion-label>{{ 'lang.' + filter | translate }}</ion-label>
<ion-icon name="close-circle"></ion-icon> <ion-icon name="close-circle"></ion-icon>
......
...@@ -91,15 +91,15 @@ export class HistoryListComponent { ...@@ -91,15 +91,15 @@ export class HistoryListComponent {
this.menu.enable(true, 'left-menu'); this.menu.enable(true, 'left-menu');
this.menu.enable(true, 'right-menu'); this.menu.enable(true, 'right-menu');
this.signaturesService.initTemplate(this.rightContent, this.viewContainerRef, 'rightContent'); this.signaturesService.initTemplate(this.rightContent, this.viewContainerRef, 'rightContent');
this.gesActions(); this.gesActions();
this.getDatas().finally(() => { this.getDatas();
setTimeout(() => {
$(".checkedAction").each((index, element) => { $(".checkedAction").each((index, element) => {
if (this.filters.messageTypes.includes($(element).val())) { if (this.filters.messageTypes.includes($(element).val())) {
$(element).prop("checked", true); $(element).prop("checked", true);
} }
}); });
}); }, 100);
} }
gesActions() { gesActions() {
...@@ -175,8 +175,8 @@ export class HistoryListComponent { ...@@ -175,8 +175,8 @@ export class HistoryListComponent {
if (this.filters.date.end !== null) { if (this.filters.date.end !== null) {
nb++; nb++;
} }
if (this.filters.messageTypes.length > 0) { if (this.uniqueArray(this.filters.messageTypes).length > 0) {
nb += this.filters.messageTypes.length; nb += this.uniqueArray(this.filters.messageTypes).length;
} }
return nb; return nb;
} }
...@@ -223,4 +223,20 @@ export class HistoryListComponent { ...@@ -223,4 +223,20 @@ export class HistoryListComponent {
this.filters.date.end = null; this.filters.date.end = null;
} }
} }
// 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;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment