[Libraryr | Trunk]: Fix filters on admin tools pages

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60315 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2021-01-29 10:47:37 +00:00
parent db682c9e4b
commit 5479040318
4 changed files with 34 additions and 82 deletions

View File

@ -51,10 +51,11 @@ export class DivIdsComponent implements OnInit {
keyword: [''],
type: ['all', Validators.required]});
this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => {
this.filterBySearch(value);
this.searchText = new RegExp(value, 'i');
this.applyFilters();
}));
this.subscriptions.push(this.filterForm.get('type').valueChanges.subscribe(value => {
this.applyTypeFilter();
this.applyFilters();
}));
this.getDivIds();
this.subscriptions.push(this.route.queryParams.subscribe(params => {
@ -128,8 +129,7 @@ export class DivIdsComponent implements OnInit {
let i = this.divIds.findIndex(_ => _._id == id);
this.divIds.splice(i, 1);
}
this.applyTypeFilter();
this.applyFilter();
this.applyFilters();
}
public confirmDeleteDivId(id: string) {
@ -264,34 +264,22 @@ export class DivIdsComponent implements OnInit {
public divIdSavedSuccessfully(divId: DivId) {
this.divIds.push(divId);
this.applyTypeFilter();
this.applyFilter();
this.applyFilters();
this.applyCheck(false);
}
public divIdUpdatedSuccessfully(divId: DivId) {
this.divIds[this.index] = divId;
this.applyTypeFilter();
this.applyFilter();
this.applyFilters();
this.applyCheck(false);
}
public filterBySearch(text: string) {
this.searchText = new RegExp(text, 'i');
this.applyFilter();
}
public applyFilter() {
this.checkboxes = [];
this.divIds.filter(item => this.filterDivIds(item)).forEach(
_ => this.checkboxes.push(<CheckDivId>{divId: _, checked: false})
);
}
public applyTypeFilter() {
public applyFilters() {
this.checkboxes = [];
this.divIds.filter(item => this.filterByType(item)).forEach(
_ => this.checkboxes.push(<CheckDivId>{divId: _, checked: false})
item => this.checkboxes.push(<CheckDivId>{divId: item, checked: false})
);
this.checkboxes = this.checkboxes.filter(item => this.filterDivIds(item.divId));
}
public filterByType(divId: DivId): boolean {

View File

@ -62,10 +62,11 @@ export class EntitiesComponent implements OnInit {
status: ['all', Validators.required]
});
this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => {
this.filterBySearch(value);
this.searchText = new RegExp(value, 'i');
this.applyFilters();
}));
this.subscriptions.push(this.filterForm.get('status').valueChanges.subscribe(value => {
this.applyStatusFilter();
this.applyFilters();
}));
this.userManagementService.getUserInfo().subscribe(user => {
this.portal = (this.route.snapshot.data.portal) ? this.route.snapshot.data.portal : this.route.snapshot.params[this.route.snapshot.data.param];
@ -145,7 +146,7 @@ export class EntitiesComponent implements OnInit {
let i = this.entities.findIndex(_ => _._id == id);
this.entities.splice(i, 1);
}
this.applyFilter();
this.applyFilters();
}
public confirmDeleteEntity(id: string) {
@ -258,26 +259,22 @@ export class EntitiesComponent implements OnInit {
public entitySavedSuccessfully(entity: Entity) {
this.entities.push(entity);
this.applyFilter();
this.applyFilters();
this.applyCheck(false);
}
public entityUpdatedSuccessfully(entity: Entity) {
this.entities[this.index] = entity;
this.applyFilter();
this.applyFilters();
this.applyCheck(false);
}
public filterBySearch(text: string) {
this.searchText = new RegExp(text, 'i');
this.applyFilter();
}
public applyFilter() {
public applyFilters() {
this.checkboxes = [];
this.entities.filter(item => this.filterEntities(item)).forEach(
this.entities.filter(item => this.filterEntitiesByStatus(item)).forEach(
_ => this.checkboxes.push(<CheckEntity>{entity: _, checked: false})
);
this.checkboxes = this.checkboxes.filter(item => this.filterEntities(item.entity));
}
public filterEntities(entity: Entity): boolean {
@ -285,13 +282,6 @@ export class EntitiesComponent implements OnInit {
return textFlag;
}
public applyStatusFilter() {
this.checkboxes = [];
this.entities.filter(item => this.filterEntitiesByStatus(item)).forEach(
_ => this.checkboxes.push(<CheckEntity>{entity: _, checked: false})
);
}
public filterEntitiesByStatus(entity: Entity): boolean {
let status = this.filterForm.get("status").value;
return status == "all" || (status == "disabled" && !entity.isEnabled) || (status == "enabled" && entity.isEnabled);

View File

@ -78,10 +78,11 @@ export class PagesComponent implements OnInit {
type: ['all', Validators.required]
});
this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => {
this.filterBySearch(value);
this.searchText = new RegExp(value, 'i');
this.applyFilters();
}));
this.subscriptions.push(this.filterForm.get('type').valueChanges.subscribe(value => {
this.applyTypeFilter();
this.applyFilters();
}));
this.subscriptions.push(this.route.queryParams.subscribe(params => {
this.pagesType = '';
@ -228,8 +229,7 @@ export class PagesComponent implements OnInit {
let i = this.pages.findIndex(_ => _._id == id);
this.pages.splice(i, 1);
}
this.applyTypeFilter();
this.applyFilter();
this.applyFilters();
}
public confirmDeletePage(id: string) {
@ -387,29 +387,16 @@ export class PagesComponent implements OnInit {
} else {
this.pages[this.index] = page;
}
this.applyTypeFilter();
this.applyFilter();
this.applyFilters();
this.applyCheck(false);
}
public filterBySearch(text: string) {
this.searchText = new RegExp(text, 'i');
this.applyFilter();
}
public applyFilter() {
this.checkboxes = [];
this.pages.filter(item => this.filterPages(item)).forEach(
_ => this.checkboxes.push(<CheckPage>{page: _, checked: false})
);
}
public applyTypeFilter() {
public applyFilters() {
this.checkboxes = [];
this.pages.filter(item => this.filterByType(item)).forEach(
_ => this.checkboxes.push(<CheckPage>{page: _, checked: false})
);
this.checkboxes = this.checkboxes.filter(item => this.filterPages(item.page));
}
public filterByType(page: Page): boolean {

View File

@ -49,10 +49,11 @@ export class PortalsComponent implements OnInit {
type: ['all', Validators.required]
});
this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => {
this.filterBySearch(value);
this.searchText = new RegExp(value, 'i');
this.applyFilters();
}));
this.subscriptions.push(this.filterForm.get('type').valueChanges.subscribe(value => {
this.applyTypeFilter();
this.applyFilters();
}));
HelperFunctions.scroll();
@ -118,8 +119,7 @@ export class PortalsComponent implements OnInit {
let i = this.portals.findIndex(_ => _._id == id);
this.portals.splice(i, 1);
}
this.applyTypeFilter();
this.applyFilter();
this.applyFilters();
}
public confirmDeletePortal(id: string) {
@ -268,36 +268,23 @@ export class PortalsComponent implements OnInit {
}
public portalSavedSuccessfully(portal: Portal) {
this.portals.push(portal)
this.applyTypeFilter();
this.applyFilter();
this.portals.push(portal);
this.applyFilters();
this.applyCheck(false);
}
public portalUpdatedSuccessfully(portal: Portal) {
this.portals[this.index] = portal;
this.applyTypeFilter();
this.applyFilter();
this.applyFilters();
this.applyCheck(false);
}
public filterBySearch(text: string) {
this.searchText = new RegExp(text, 'i');
this.applyFilter();
}
public applyFilter() {
this.checkboxes = [];
this.portals.filter(item => this.filterPortals(item)).forEach(
_ => this.checkboxes.push(<CheckPortal>{portal: _, checked: false})
);
}
public applyTypeFilter() {
public applyFilters() {
this.checkboxes = [];
this.portals.filter(item => this.filterByType(item)).forEach(
_ => this.checkboxes.push(<CheckPortal>{portal: _, checked: false})
);
this.checkboxes = this.checkboxes.filter(item => this.filterPortals(item.portal));
}
public filterByType(portal: Portal): boolean {