From ad466d6428fb0225a02764a22909e28ad09a60cf Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Thu, 27 Dec 2018 15:34:38 +0100 Subject: [PATCH] FEAT #8956 add bages filters lang vars --- .../app/list/filters/filters-tool.component.html | 10 +++++----- .../app/list/filters/filters-tool.component.ts | 12 +++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/frontend/app/list/filters/filters-tool.component.html b/src/frontend/app/list/filters/filters-tool.component.html index 2b35d0f25e9..3a0843d159a 100644 --- a/src/frontend/app/list/filters/filters-tool.component.html +++ b/src/frontend/app/list/filters/filters-tool.component.html @@ -59,13 +59,13 @@ </mat-menu> </mat-button-toggle-group> <div class="filterBadges"> - <span class="label badge-meta" *ngIf="this.listProperties.search !== ''" title="{{lang.currentFilters}}">{{this.listProperties.search}} + <span class="label badge-meta" *ngIf="this.listProperties.search !== ''" title="{{lang.subject}} / {{lang.chronoNumber}}">{{this.listProperties.search}} <i class="fa fa-times-circle" (click)="this.listProperties.search='';updateFilters();"></i></span> - <span class="label badge-cat" title="{{lang.currentFilters}}" *ngFor="let category of this.listProperties.categories; let i=index">{{category.label}} + <span class="label badge-cat" title="{{lang.categories}}" *ngFor="let category of this.listProperties.categories; let i=index">{{category.label}} <i class="fa fa-times-circle" (click)="removeFilter('categories', i)"></i></span> - <span class="label badge-prio" title="{{lang.currentFilters}}" *ngFor="let priority of this.listProperties.priorities; let i=index">{{priority.label}} + <span class="label badge-prio" title="{{lang.priorities}}" *ngFor="let priority of this.listProperties.priorities; let i=index">{{priority.label}} <i class="fa fa-times-circle" (click)="removeFilter('priorities', i)"></i></span> - <span class="label badge-stat" title="{{lang.currentFilters}}" *ngFor="let status of this.listProperties.statuses; let i=index">{{status.label}} + <span class="label badge-stat" title="{{lang.statuses}}" *ngFor="let status of this.listProperties.statuses; let i=index">{{status.label}} <i class="fa fa-times-circle" (click)="removeFilter('statuses', i)"></i></span> - <span class="label badge-ent" title="{{lang.currentFilters}}" *ngFor="let entity of this.listProperties.entities; let i=index">{{entity.label}} <i class="fa fa-times-circle" (click)="removeFilter('entities', i)"></i></span> + <span class="label badge-ent" title="{{lang.entities}}" *ngFor="let entity of this.listProperties.entities; let i=index">{{entity.label}} <i class="fa fa-times-circle" (click)="removeFilter('entities', i)"></i></span> </div> \ No newline at end of file diff --git a/src/frontend/app/list/filters/filters-tool.component.ts b/src/frontend/app/list/filters/filters-tool.component.ts index d020394c47d..a4792d7d141 100644 --- a/src/frontend/app/list/filters/filters-tool.component.ts +++ b/src/frontend/app/list/filters/filters-tool.component.ts @@ -16,9 +16,11 @@ export interface StateGroup { export const _filter = (opt: string[], value: string): string[] => { - const filterValue = value.toLowerCase(); + if (typeof value === 'string') { + const filterValue = value.toLowerCase(); - return opt.filter(item => item['label'].toLowerCase().indexOf(filterValue) != -1); + return opt.filter(item => item['label'].toLowerCase().indexOf(filterValue) != -1); + } }; @Component({ selector: 'app-filters-tool', @@ -72,7 +74,7 @@ export class FiltersToolComponent implements OnInit { } private _filterGroup(value: string): StateGroup[] { - if (value) { + if (value && typeof value === 'string') { return this.stateGroups .map(group => ({ letter: group.letter, names: _filter(group.names, value) })) .filter(group => group.names.length > 0); @@ -158,7 +160,7 @@ export class FiltersToolComponent implements OnInit { }, ]; - this.http.get('../../rest/resourcesList/users/' + this.currentBasketInfo.ownerId + '/groups/' + this.currentBasketInfo.groupId + '/baskets/' + this.currentBasketInfo.basketId + '/filters') + this.http.get('../../rest/resourcesList/users/' + this.currentBasketInfo.ownerId + '/groups/' + this.currentBasketInfo.groupId + '/baskets/' + this.currentBasketInfo.basketId + '/filters?init' + this.filtersListService.getUrlFilters()) .subscribe((data: any) => { data.categories.forEach((element: any) => { if (this.listProperties.categories.map((category: any) => (category.id)).indexOf(element.id) === -1) { @@ -199,7 +201,7 @@ export class FiltersToolComponent implements OnInit { }); data.entities.forEach((element: any) => { - if (this.listProperties.entities.map((entity: any) => (entity.id)).indexOf(element.id) === -1) { + if (this.listProperties.entities.map((entity: any) => (entity.id)).indexOf(element.entityId) === -1) { this.stateGroups[3].names.push( { id: 'entities', -- GitLab