From 3802ac5f68c5afb385725a89beff5c573daa17dd Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Wed, 5 Aug 2020 10:38:58 +0200 Subject: [PATCH] FEAT #14454 TIME 0:40 add field filter save --- .../app/administration/administration.service.ts | 14 ++++++++++---- .../user/users-administration.component.html | 4 ++-- .../user/users-administration.component.ts | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/frontend/app/administration/administration.service.ts b/src/frontend/app/administration/administration.service.ts index 4c1b1775ed0..690cef276f2 100644 --- a/src/frontend/app/administration/administration.service.ts +++ b/src/frontend/app/administration/administration.service.ts @@ -20,6 +20,7 @@ export class AdministrationService { sort: 'user_id', sortDirection: 'asc', page: 0, + field : '' }, }; dataSource: MatTableDataSource<any>; @@ -53,7 +54,7 @@ export class AdministrationService { this.dataSource.paginator = paginator; this.dataSource.sortingDataAccessor = this.functionsService.listSortingDataAccessor; - if (this.functionsService.empty(this.getFilter('users'))) { + if (this.functionsService.empty(this.getFilter(adminId))) { this.setFilter( adminId, this.defaultFilters[adminId] @@ -66,6 +67,8 @@ export class AdministrationService { this.dataSource.sort = sort; + this.applyFilter(adminId, this.getFilter(adminId, 'field')); + merge(sort.sortChange, paginator.page) .pipe( startWith({}), @@ -76,6 +79,7 @@ export class AdministrationService { sort: sort.active, sortDirection: sort.direction, page: paginator.pageIndex, + field: this.getFilter(adminId, 'field') } ); }), @@ -89,16 +93,18 @@ export class AdministrationService { getFilter(id: string, idFilter: string = null) { if (!this.functionsService.empty(this.filters[id])) { if (!this.functionsService.empty(idFilter)) { - return this.filters[id][idFilter]; + return !this.functionsService.empty(this.filters[id][idFilter]) ? this.filters[id][idFilter] : ''; } else { - return this.filters[id]; + return !this.functionsService.empty(this.filters[id]) ? this.filters[id] : ''; } } else { return null; } } - applyFilter(filterValue: string) { + applyFilter(adminId: string, filterValue: string) { + this.filters[adminId]['field'] = filterValue; + this.setFilter(adminId, this.filters[adminId]); filterValue = filterValue.trim(); // Remove whitespace filterValue = filterValue.toLowerCase(); // MatTableDataSource defaults to lowercase matches this.dataSource.filter = filterValue; diff --git a/src/frontend/app/administration/user/users-administration.component.html b/src/frontend/app/administration/user/users-administration.component.html index f2b2a98f5e0..8354cd380ab 100755 --- a/src/frontend/app/administration/user/users-administration.component.html +++ b/src/frontend/app/administration/user/users-administration.component.html @@ -52,8 +52,8 @@ <div class="row"> <div class="col-md-6 col-xs-6"> <mat-form-field> - <input matInput (keyup)="adminService.applyFilter($event.target.value)" - placeholder="{{lang.filterBy}}"> + <input matInput (keyup)="adminService.applyFilter('admin_users', $event.target.value)" + placeholder="{{lang.filterBy}}" [value]="adminService.getFilter('admin_users', 'field')"> <mat-button-toggle class="webserviceAccount" matSuffix (click)="$event.stopPropagation();toggleWebserviceAccount()" [checked]="this.withWebserviceAccount" title="{{lang.displayWebserviceAccount}}"> diff --git a/src/frontend/app/administration/user/users-administration.component.ts b/src/frontend/app/administration/user/users-administration.component.ts index 638e7504ac7..995e73c8741 100755 --- a/src/frontend/app/administration/user/users-administration.component.ts +++ b/src/frontend/app/administration/user/users-administration.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, ViewChild, Inject, TemplateRef, ViewContainerRef } from '@angular/core'; +import { Component, OnInit, ViewChild, Inject, TemplateRef, ViewContainerRef, ElementRef } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { LANG } from '../../translate.component'; import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; -- GitLab