Project

General

Profile

« Previous | Next » 

Revision 60315

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

View differences:

modules/uoa-services-library/trunk/ng-openaire-library/src/app/dashboard/divId/divIds.component.ts
51 51
      keyword: [''],
52 52
      type: ['all', Validators.required]});
53 53
    this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => {
54
      this.filterBySearch(value);
54
      this.searchText = new RegExp(value, 'i');
55
      this.applyFilters();
55 56
    }));
56 57
    this.subscriptions.push(this.filterForm.get('type').valueChanges.subscribe(value => {
57
      this.applyTypeFilter();
58
      this.applyFilters();
58 59
    }));
59 60
    this.getDivIds();
60 61
    this.subscriptions.push(this.route.queryParams.subscribe(params => {
......
128 129
      let i = this.divIds.findIndex(_ => _._id == id);
129 130
      this.divIds.splice(i, 1);
130 131
    }
131
    this.applyTypeFilter();
132
    this.applyFilter();
132
    this.applyFilters();
133 133
  }
134 134

  
135 135
  public confirmDeleteDivId(id: string) {
......
264 264

  
265 265
  public divIdSavedSuccessfully(divId: DivId) {
266 266
    this.divIds.push(divId);
267
    this.applyTypeFilter();
268
    this.applyFilter();
267
    this.applyFilters();
269 268
    this.applyCheck(false);
270 269
  }
271 270

  
272 271
  public divIdUpdatedSuccessfully(divId: DivId) {
273 272
    this.divIds[this.index] = divId;
274
    this.applyTypeFilter();
275
    this.applyFilter();
273
    this.applyFilters();
276 274
    this.applyCheck(false);
277 275
  }
278 276

  
279
  public filterBySearch(text: string) {
280
    this.searchText = new RegExp(text, 'i');
281
    this.applyFilter();
282
  }
283

  
284
  public applyFilter() {
277
  public applyFilters() {
285 278
    this.checkboxes = [];
286
    this.divIds.filter(item => this.filterDivIds(item)).forEach(
287
      _ => this.checkboxes.push(<CheckDivId>{divId: _, checked: false})
288
    );
289
  }
290
  public applyTypeFilter() {
291
    this.checkboxes = [];
292 279
    this.divIds.filter(item => this.filterByType(item)).forEach(
293
      _ => this.checkboxes.push(<CheckDivId>{divId: _, checked: false})
280
      item => this.checkboxes.push(<CheckDivId>{divId: item, checked: false})
294 281
    );
282
    this.checkboxes = this.checkboxes.filter(item => this.filterDivIds(item.divId));
295 283
  }
296 284

  
297 285
  public filterByType(divId: DivId): boolean {
modules/uoa-services-library/trunk/ng-openaire-library/src/app/dashboard/portal/portals.component.ts
49 49
      type: ['all', Validators.required]
50 50
    });
51 51
    this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => {
52
      this.filterBySearch(value);
52
      this.searchText = new RegExp(value, 'i');
53
      this.applyFilters();
53 54
    }));
54 55
    this.subscriptions.push(this.filterForm.get('type').valueChanges.subscribe(value => {
55
      this.applyTypeFilter();
56
      this.applyFilters();
56 57
    }));
57 58
    
58 59
    HelperFunctions.scroll();
......
118 119
      let i = this.portals.findIndex(_ => _._id == id);
119 120
      this.portals.splice(i, 1);
120 121
    }
121
    this.applyTypeFilter();
122
    this.applyFilter();
122
    this.applyFilters();
123 123
  }
124 124
  
125 125
  public confirmDeletePortal(id: string) {
......
268 268
  }
269 269
  
270 270
  public portalSavedSuccessfully(portal: Portal) {
271
    this.portals.push(portal)
272
    this.applyTypeFilter();
273
    this.applyFilter();
271
    this.portals.push(portal);
272
    this.applyFilters();
274 273
    this.applyCheck(false);
275 274
  }
276 275
  
277 276
  public portalUpdatedSuccessfully(portal: Portal) {
278 277
    this.portals[this.index] = portal;
279
    this.applyTypeFilter();
280
    this.applyFilter();
278
    this.applyFilters();
281 279
    this.applyCheck(false);
282 280
  }
283 281
  
284
  public filterBySearch(text: string) {
285
    this.searchText = new RegExp(text, 'i');
286
    this.applyFilter();
287
  }
288
  
289
  public applyFilter() {
282
  public applyFilters() {
290 283
    this.checkboxes = [];
291
    this.portals.filter(item => this.filterPortals(item)).forEach(
292
      _ => this.checkboxes.push(<CheckPortal>{portal: _, checked: false})
293
    );
294
  }
295
  
296
  public applyTypeFilter() {
297
    this.checkboxes = [];
298 284
    this.portals.filter(item => this.filterByType(item)).forEach(
299 285
      _ => this.checkboxes.push(<CheckPortal>{portal: _, checked: false})
300 286
    );
287
    this.checkboxes = this.checkboxes.filter(item => this.filterPortals(item.portal));
301 288
  }
302 289
  
303 290
  public filterByType(portal: Portal): boolean {
modules/uoa-services-library/trunk/ng-openaire-library/src/app/dashboard/entity/entities.component.ts
62 62
      status: ['all', Validators.required]
63 63
    });
64 64
    this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => {
65
      this.filterBySearch(value);
65
      this.searchText = new RegExp(value, 'i');
66
      this.applyFilters();
66 67
    }));
67 68
    this.subscriptions.push(this.filterForm.get('status').valueChanges.subscribe(value => {
68
      this.applyStatusFilter();
69
      this.applyFilters();
69 70
    }));
70 71
    this.userManagementService.getUserInfo().subscribe(user => {
71 72
      this.portal = (this.route.snapshot.data.portal) ? this.route.snapshot.data.portal : this.route.snapshot.params[this.route.snapshot.data.param];
......
145 146
      let i = this.entities.findIndex(_ => _._id == id);
146 147
      this.entities.splice(i, 1);
147 148
    }
148
    this.applyFilter();
149
    this.applyFilters();
149 150
  }
150 151
  
151 152
  public confirmDeleteEntity(id: string) {
......
258 259
  
259 260
  public entitySavedSuccessfully(entity: Entity) {
260 261
    this.entities.push(entity);
261
    this.applyFilter();
262
    this.applyFilters();
262 263
    this.applyCheck(false);
263 264
  }
264 265
  
265 266
  public entityUpdatedSuccessfully(entity: Entity) {
266 267
    this.entities[this.index] = entity;
267
    this.applyFilter();
268
    this.applyFilters();
268 269
    this.applyCheck(false);
269 270
  }
270 271
  
271
  public filterBySearch(text: string) {
272
    this.searchText = new RegExp(text, 'i');
273
    this.applyFilter();
274
  }
275
  
276
  public applyFilter() {
272
  public applyFilters() {
277 273
    this.checkboxes = [];
278
    this.entities.filter(item => this.filterEntities(item)).forEach(
274
    this.entities.filter(item => this.filterEntitiesByStatus(item)).forEach(
279 275
      _ => this.checkboxes.push(<CheckEntity>{entity: _, checked: false})
280 276
    );
277
    this.checkboxes = this.checkboxes.filter(item => this.filterEntities(item.entity));
281 278
  }
282 279
  
283 280
  public filterEntities(entity: Entity): boolean {
......
285 282
    return textFlag;
286 283
  }
287 284
  
288
  public applyStatusFilter() {
289
    this.checkboxes = [];
290
    this.entities.filter(item => this.filterEntitiesByStatus(item)).forEach(
291
      _ => this.checkboxes.push(<CheckEntity>{entity: _, checked: false})
292
    );
293
  }
294
  
295 285
  public filterEntitiesByStatus(entity: Entity): boolean {
296 286
    let status = this.filterForm.get("status").value;
297 287
    return status == "all" || (status == "disabled" && !entity.isEnabled) || (status == "enabled" && entity.isEnabled);
modules/uoa-services-library/trunk/ng-openaire-library/src/app/dashboard/page/pages.component.ts
78 78
      type: ['all', Validators.required]
79 79
    });
80 80
    this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => {
81
      this.filterBySearch(value);
81
      this.searchText = new RegExp(value, 'i');
82
      this.applyFilters();
82 83
    }));
83 84
    this.subscriptions.push(this.filterForm.get('type').valueChanges.subscribe(value => {
84
      this.applyTypeFilter();
85
      this.applyFilters();
85 86
    }));
86 87
    this.subscriptions.push(this.route.queryParams.subscribe(params => {
87 88
      this.pagesType = '';
......
228 229
      let i = this.pages.findIndex(_ => _._id == id);
229 230
      this.pages.splice(i, 1);
230 231
    }
231
    this.applyTypeFilter();
232
    this.applyFilter();
232
    this.applyFilters();
233 233
  }
234 234
  
235 235
  public confirmDeletePage(id: string) {
......
387 387
    } else {
388 388
      this.pages[this.index] = page;
389 389
    }
390
    this.applyTypeFilter();
391
    this.applyFilter();
390
    this.applyFilters();
392 391
    this.applyCheck(false);
393 392
  }
394 393
  
395
  
396
  public filterBySearch(text: string) {
397
    this.searchText = new RegExp(text, 'i');
398
    this.applyFilter();
399
  }
400
  
401
  public applyFilter() {
394
  public applyFilters() {
402 395
    this.checkboxes = [];
403
    this.pages.filter(item => this.filterPages(item)).forEach(
404
      _ => this.checkboxes.push(<CheckPage>{page: _, checked: false})
405
    );
406
  }
407
  
408
  public applyTypeFilter() {
409
    this.checkboxes = [];
410 396
    this.pages.filter(item => this.filterByType(item)).forEach(
411 397
      _ => this.checkboxes.push(<CheckPage>{page: _, checked: false})
412 398
    );
399
    this.checkboxes = this.checkboxes.filter(item => this.filterPages(item.page));
413 400
  }
414 401
  
415 402
  public filterByType(page: Page): boolean {

Also available in: Unified diff