Project

General

Profile

1 50504 myrto.kouk
import { Component, Input, OnInit } from '@angular/core';
2
import { Rule, RuleSet } from '../../../domain/typeScriptClasses';
3
import { FormControl } from '@angular/forms';
4
5
@Component ({
6
  selector: 'compatibility-validate-step2',
7
  templateUrl: 'compatibility-validate-step2.component.html'
8
})
9
10
export class CompatibilityValidateStep2Component implements OnInit {
11
12
  currentContentRules: Rule[] = [];
13
  currentUsageRules: Rule[] = [];
14
15
16
  @Input() ruleSets: RuleSet[];
17
18
  constructor() {}
19
20
  ngOnInit() {
21
    if ( this.ruleSets.length ) {
22
      this.getCurrentRuleSets(0);
23
    }
24
  }
25
26
  getCurrentRuleSets(index: number){
27
    let id = this.ruleSets[index].id;
28
    let current: RuleSet[] = this.ruleSets.filter(
29
      set => {
30
        if (set.id = id) {
31
          return set;
32
        }
33
      }
34
    );
35
    this.currentContentRules = current[index].contentRules;
36
    this.currentUsageRules = current[index].usageRules;
37
  }
38
39
  toggleChooseContentRule(e: any, id: number) {
40
    if(e.target.checked) {
41
      console.log(this.currentContentRules[id].name);
42
    }
43
  }
44
45
  toggleChooseUsageRule(id: number) {
46
    console.log(this.currentUsageRules[id].name);
47
  }
48
}