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:

pages.component.ts
4 4
import {FormArray, FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
5 5
import {CheckPage, Page} from '../../utils/entities/adminTool/page';
6 6
import {Portal} from '../../utils/entities/adminTool/portal';
7
import {Entity} from '../../utils/entities/adminTool/entity';
7
import {CheckEntity, Entity} from '../../utils/entities/adminTool/entity';
8 8
import {EnvProperties} from '../../utils/properties/env-properties';
9 9
import {Session} from '../../login/utils/helper.class';
10 10
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
......
51 51
  public updateErrorMessage: string = '';
52 52
  public modalErrorMessage: string = '';
53 53
  public isPortalAdministrator = null;
54
  public filterForm: FormControl;
55
  public typeOptions = [{label: 'Search', value: 'search'}, {label: 'Link', value: 'link'}, {
54
  public filterForm: FormGroup;
55
  public typeOptions = [{label: 'Search', value: 'search'},   {
56 56
    label: 'Share',
57 57
    value: 'share'
58 58
  }, {label: 'Landing', value: 'landing'}, {label: 'HTML', value: 'html'}, {
59 59
    label: 'Link',
60 60
    value: 'link'
61
  }, {label: 'Other', value: 'other'}]
61
  }, {label: 'Other', value: 'other'}];
62 62
  public entitiesCtrl: FormArray;
63 63
  @ViewChild('PageInput') pageInput: ElementRef<HTMLInputElement>;
64 64
  public entitiesSearchCtrl: FormControl;
......
74 74
  }
75 75

  
76 76
  ngOnInit() {
77
    this.filterForm = this._fb.control('');
78
    this.subscriptions.push(this.filterForm.valueChanges.subscribe(value => {
77
    this.filterForm =  this._fb.group({
78
      keyword: [''],
79
      type: ['all', Validators.required]});
80
    this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => {
79 81
      this.filterBySearch(value);
80 82
    }));
83
    this.subscriptions.push(this.filterForm.get('type').valueChanges.subscribe(value => {
84
      this.applyTypeFilter();
85
    }));
81 86
    this.entitiesSearchCtrl = this._fb.control('');
82 87
    this.myForm = this._fb.group({
83 88
      route: ['', Validators.required],
......
99 104

  
100 105
      this.pagesType = '';
101 106
      if (params['type']) {
102
        this.pagesType = params['type'];
107
        // this.pagesType = params['type'];
108
        this.filterForm.get('type').setValue(params['type']);
103 109
      }
104

  
110
      this.selectedCommunityPid = params['communityId'];
105 111
      this.keyword = '';
106 112
      this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
107
        this.selectedCommunityPid = params['communityId'];
108 113
        this.applyCommunityFilter(this.selectedCommunityPid);
109 114
        this.isPortalAdministrator = Session.isPortalAdministrator(user) && !this.selectedCommunityPid;
110 115
      }));
......
116 121
        this.allEntities = entities;
117 122
        this.showLoading = false;
118 123
      },
119
      error => this.handleError('System error retrieving community entities', error)));
124
      error => this.handleError('System error retrieving pages', error)));
120 125

  
121 126

  
122 127
  }
......
437 442
      _ => this.checkboxes.push(<CheckPage>{page: _, checked: false})
438 443
    );
439 444
  }
445
  public applyTypeFilter() {
446
    this.checkboxes = [];
447
    this.pages.filter(item => this.filterByType(item)).forEach(
448
      _ => this.checkboxes.push(<CheckPage>{page: _, checked: false})
449
    );
450
  }
440 451

  
452
  public filterByType(page: Page): boolean {
453
    let type = this.filterForm.get("type").value;
454
    return  type == "all" || (type  == page.type);
455
  }
441 456
  public filterPages(page: Page): boolean {
442 457
    let textFlag = this.searchText.toString() == '' || (page.route + ' ' + page.name + ' ' + page.portalType).match(this.searchText) != null;
443 458
    return textFlag;

Also available in: Unified diff