summaryrefslogtreecommitdiffstats
path: root/usecaseui-portal/src/app/views/intent-management/input-intent-condition/input-intent-condition.component.ts
blob: 22d3bfed51a0e271ae16639461aa674a0830add1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { Util } from '../../../shared/utils/utils';

@Component({
  selector: 'app-input-intent-condition',
  templateUrl: './input-intent-condition.component.html',
  styleUrls: ['../intent-management.component.less']
})
export class InputIntentConditionComponent implements OnInit {

  constructor(
    private Util: Util
  ) { }

  @Input() showModel: boolean;
  @Output() modalOpreation = new EventEmitter();
  @Input() editConditionTableData;

  defaultParams:Object={
    conditionId:'',
    conditionName:'',
    operator:'EQUALTO',
    conditionValue:'',
    conditionList:null
  };
  conditionType: string;
  operatorList: any[] = [];

  ngOnChanges() {
    // this.defaultParams=this.editConditionTableData
    // if(this.editConditionTableData['conditionList'] === null){
    //   this.conditionType='value'
    // }else{
    //   this.conditionType='list'
    //   this.secondParams=this.editConditionTableData['conditionList']
    // }
    if (this.showModel) {
      if (JSON.stringify(this.editConditionTableData)!=='{}') {
        this.defaultParams=this.editConditionTableData
      }
      console.log(this.editConditionTableData)
    }
	}
  ngOnInit() {
    this.conditionType = 'value'
    this.operatorList = [
      { label:'EQUALTO', value:'EQUALTO'},
      { label:'LARGETHAN', value:'LARGETHAN'},
      { label:'LESSTHAN', value:'LESSTHAN'}
    ]
  }
  handleCancel(): void {
    this.modalOpreation.emit({ "cancel": true });
    this.clearConditionData()
  }
  handleOk(): void {
    if(JSON.stringify(this.editConditionTableData)==='{}'){
      this.defaultParams['conditionId']=this.Util.getUuid()
    }
    console.log(this.defaultParams)
    this.modalOpreation.emit({ "cancel": false, "param": this.defaultParams });
    this.clearConditionData()
  }
  handleChange(event){
    this.defaultParams['operator']=event
  }
  clearConditionData(){
    this.conditionType = 'value'
    this.defaultParams={
      conditionId:'',
      conditionName:'',
      operator:'EQUALTO',
      conditionValue:'',
      conditionList:null
    };
  }

}