From 4ae2973aea90023f0265e3c6416ed68c0b59607f Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Fri, 8 Nov 2019 11:04:58 +0100 Subject: [PATCH] FEAT #11750 TIME 0:30 add filter doctypes --- .../list/filters/filters-list.component.ts | 20 ++++++++++++++++--- .../list/filters/filters-tool.component.html | 16 +++++++++------ .../list/filters/filters-tool.component.scss | 8 +++++++- .../list/filters/filters-tool.component.ts | 17 ++++++++++++++++ src/frontend/service/filtersList.service.ts | 12 ++++++++++- 5 files changed, 62 insertions(+), 11 deletions(-) diff --git a/src/frontend/app/list/filters/filters-list.component.ts b/src/frontend/app/list/filters/filters-list.component.ts index 53f2740dedb..f29836a31a1 100644 --- a/src/frontend/app/list/filters/filters-list.component.ts +++ b/src/frontend/app/list/filters/filters-list.component.ts @@ -23,6 +23,7 @@ export class FiltersListComponent implements OnInit { categories: any[] = []; entitiesList: any[] = []; statuses: any[] = []; + doctypes: any[] = []; loading: boolean = false; @@ -70,9 +71,22 @@ export class FiltersListComponent implements OnInit { } }); }); + this.http.get("../../rest/doctypes/types") + .subscribe((data: any) => { + this.doctypes = data.doctypes; + this.doctypes.forEach(element => { + element.selected = false; + this.listProperties.doctypes.forEach((listPropertyDoctype: any) => { + if (element.type_id === listPropertyDoctype.id) { + element.selected = true; + } + }); + }); + + this.loading = false; + + }); - this.loading = false; - }); }); }); @@ -88,7 +102,7 @@ export class FiltersListComponent implements OnInit { 'label': element.label }); } - + }); this.updateFilters(); } diff --git a/src/frontend/app/list/filters/filters-tool.component.html b/src/frontend/app/list/filters/filters-tool.component.html index 9ab44bebc43..abbb8d9dbd8 100644 --- a/src/frontend/app/list/filters/filters-tool.component.html +++ b/src/frontend/app/list/filters/filters-tool.component.html @@ -1,18 +1,18 @@ <div class="filtersContent"> <form [formGroup]="stateForm" class="filterTool"> <mat-form-field floatLabel="never" class="basket-search"> - <input class="metaSearch" type="text" matInput placeholder="{{title}}" - formControlName="stateGroup" [matAutocomplete]="autoGroup" (focus)="initFilters()" - (keyup.enter)="metaSearch($event);"> + <input class="metaSearch" type="text" matInput placeholder="{{title}}" formControlName="stateGroup" + [matAutocomplete]="autoGroup" (focus)="initFilters()" (keyup.enter)="metaSearch($event);"> <button mat-icon-button matPrefix> <mat-icon class="fa fa-search"></mat-icon> </button> - <mat-button-toggle matSuffix class="processLimitButton" (click)="$event.stopPropagation();" [checked]="this.listProperties.delayed" value="delayed" - title="{{lang.displayProcessLimitRes}}" (change)="setFilters($event, 'delayed')"> + <mat-button-toggle matSuffix class="processLimitButton" (click)="$event.stopPropagation();" + [checked]="this.listProperties.delayed" value="delayed" title="{{lang.displayProcessLimitRes}}" + (change)="setFilters($event, 'delayed')"> <mat-icon fontSet="fas" fontIcon="fa-stopwatch fa-2x"></mat-icon> </mat-button-toggle> <mat-autocomplete #autoGroup="matAutocomplete" (optionSelected)="selectFilter($event)" - [class]="'autoCompletePanelFilter'"> + [class]="'autoCompletePanelFilter'"> <mat-option *ngIf="isLoading" class="is-loading"> <mat-spinner diameter="50"></mat-spinner> </mat-option> @@ -94,4 +94,8 @@ *ngFor="let subEntity of this.listProperties.subEntities; let i=index" (click)="removeFilter('subEntities', i)">{{subEntity.label}} <i class="fa fa-times-circle"></i></span> + <span class="label badge-doctypes" title="{{lang.doctypes}}" + *ngFor="let doctype of this.listProperties.doctypes; let i=index" + (click)="removeFilter('doctypes', i)">{{doctype.label}} + <i class="fa fa-times-circle"></i></span> </div> \ No newline at end of file diff --git a/src/frontend/app/list/filters/filters-tool.component.scss b/src/frontend/app/list/filters/filters-tool.component.scss index 04cac380031..7c7aa866df0 100644 --- a/src/frontend/app/list/filters/filters-tool.component.scss +++ b/src/frontend/app/list/filters/filters-tool.component.scss @@ -161,11 +161,17 @@ } .filterBadges>.badge-subEntities { - margin: 5px; + margin: 5px; background: #9440D5; cursor: pointer; } +.filterBadges>.badge-doctypes { + margin: 5px; + background: #d6716f; + cursor: pointer; +} + ::ng-deep.autoCompletePanelFilter { left: 25px; min-width: 400px !important; diff --git a/src/frontend/app/list/filters/filters-tool.component.ts b/src/frontend/app/list/filters/filters-tool.component.ts index 3af72bdf931..9f6365f6c13 100644 --- a/src/frontend/app/list/filters/filters-tool.component.ts +++ b/src/frontend/app/list/filters/filters-tool.component.ts @@ -196,6 +196,10 @@ export class FiltersToolComponent implements OnInit { letter: this.lang.subEntities, names: [] }, + { + letter: this.lang.doctypes, + names: [] + }, ]; this.http.get('../..' + this.routeDatas + '?init' + this.filtersListService.getUrlFilters()) @@ -264,6 +268,19 @@ export class FiltersToolComponent implements OnInit { ) } }); + + data.doctypes.forEach((element: any) => { + if (this.listProperties.doctypes.map((doctype: any) => (doctype.id)).indexOf(element.id) === -1 && this.listProperties.doctypes == 0) { + this.stateGroups[5].names.push( + { + id: 'doctypes', + value: element.id, + label: (element.id !== null ? element.label : this.lang.undefined), + count: element.count + } + ) + } + }); this.isLoading = false; if (this.metaSearchInput.length > 0) { setTimeout(() => { diff --git a/src/frontend/service/filtersList.service.ts b/src/frontend/service/filtersList.service.ts index 3809ddfb183..56bbaf28611 100644 --- a/src/frontend/service/filtersList.service.ts +++ b/src/frontend/service/filtersList.service.ts @@ -13,7 +13,8 @@ interface listProperties { 'priorities': string[], 'entities': string[], 'subEntities': string[], - 'statuses': string[] + 'statuses': string[], + 'doctypes': string[], } @Injectable() @@ -60,6 +61,7 @@ export class FiltersListService { 'entities': [], 'subEntities': [], 'statuses': [], + 'doctypes': [], }; this.listsProperties.push(listProperties); this.listsPropertiesIndex = this.listsProperties.length -1; @@ -139,6 +141,14 @@ export class FiltersListService { filters += '&entitiesChildren=' + ent.join(','); } + if (this.listsProperties[this.listsPropertiesIndex].doctypes.length > 0) { + let doct: any[] = []; + this.listsProperties[this.listsPropertiesIndex].doctypes.forEach((element: any) => { + doct.push(element.id); + }); + + filters += '&doctypes=' + doct.join(','); + } } return filters; } -- GitLab