Project

General

Profile

« Previous | Next » 

Revision 60202

[Library | Trunk]

Dashboard - Admin tool pages:
- add tabs components
- add rout module (without guards)
- put tabs and page-content in pages, classes, entities pages

Stakeholder:
initial try to add filters for country and organization fields (doesn't work properly)

View differences:

portals.component.ts
1 1
import {Component, ViewChild, OnInit, ElementRef} from '@angular/core';
2 2
import {ActivatedRoute, Router} from '@angular/router';
3 3
import {HelpContentService} from '../../services/help-content.service';
4
import {FormBuilder, FormControl, FormGroup} from '@angular/forms';
4
import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
5 5
import {EnvProperties} from '../../utils/properties/env-properties';
6 6

  
7 7
import {Session} from '../../login/utils/helper.class';
......
11 11
import {CheckPortal, Portal} from "../../utils/entities/adminTool/portal";
12 12
import {PortalUtils} from "./portalHelper";
13 13
import {properties} from "../../../../environments/environment";
14
import {CheckPage, Page} from "../../utils/entities/adminTool/page";
14 15

  
15 16
@Component({
16 17
  selector: 'portals',
......
27 28
  public communities: Portal[] = [];
28 29

  
29 30
  public portalFG: FormGroup;
30
  public formControl: FormControl;
31
  public filterForm: FormGroup;
31 32
  private subscriptions: any[] = [];
32 33

  
33 34
  private searchText: RegExp = new RegExp('');
......
48 49
      piwik:'',
49 50
      type: ''
50 51
    });
51
    this.formControl = this._fb.control('');
52
    this.subscriptions.push(this.formControl.valueChanges.subscribe(value => {
52
    this.filterForm =  this._fb.group({
53
      keyword: [''],
54
      type: ['all', Validators.required]});
55
    this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => {
53 56
      this.filterBySearch(value);
54 57
    }));
58
    this.subscriptions.push(this.filterForm.get('type').valueChanges.subscribe(value => {
59
      this.applyTypeFilter();
60
    }));
55 61

  
56 62
    HelperFunctions.scroll();
57 63
    this.properties = properties;
......
95 101
          }
96 102
          this.showLoading = false;
97 103
        },
98
        error => this.handleError('System error retrieving communities', error)));
104
        error => this.handleError('System error retrieving portals', error)));
99 105
    }
100 106
  }
101 107

  
......
273 279
      _ => this.checkboxes.push(<CheckPortal>{community: _, checked: false})
274 280
    );
275 281
  }
282
  public applyTypeFilter() {
283
    this.checkboxes = [];
284
    this.communities.filter(item => this.filterByType(item)).forEach(
285
      _ => this.checkboxes.push(<CheckPortal>{community: _, checked: false})
286
    );
287
  }
276 288

  
289
  public filterByType(community: Portal): boolean {
290
    let type = this.filterForm.get("type").value;
291
    return  type == "all" || (type  == community.type);
292
  }
277 293
  public filterCommunities(community: Portal): boolean {
278 294
    const textFlag = this.searchText.toString() === '' || (community.name || community.type).match(this.searchText) != null;
279 295
    return textFlag;

Also available in: Unified diff