support set parameter for workflow
[sdc/sdc-workflow-designer.git] / sdc-workflow-designer-ui / src / app / components / parameter / parameter.component.ts
1 /**\r
2  * Copyright (c) 2017 ZTE Corporation.\r
3  * All rights reserved. This program and the accompanying materials\r
4  * are made available under the terms of the Eclipse Public License v1.0\r
5  * and the Apache License 2.0 which both accompany this distribution,\r
6  * and are available at http://www.eclipse.org/legal/epl-v10.html\r
7  * and http://www.apache.org/licenses/LICENSE-2.0\r
8  *\r
9  * Contributors:\r
10  *     ZTE - initial API and implementation and/or initial documentation\r
11  */\r
12 \r
13 import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';\r
14 \r
15 import { ValueSource } from '../../model/value-source.enum';\r
16 import { Parameter } from '../../model/workflow/parameter';\r
17 import { DataAccessService } from "../../services/data-access/data-access.service";\r
18 \r
19 /**\r
20  * this component contains in property component if the corresponding node has parameter properties\r
21  * eg. task node have input and output params, start event node has input param\r
22  */\r
23 @Component({\r
24     selector: 'b4t-parameter',\r
25     templateUrl: 'parameter.component.html',\r
26 })\r
27 export class ParameterComponent implements OnInit {\r
28     @Input() public param: Parameter;\r
29     @Input() public valueSource: ValueSource[];\r
30     @Input() public canEditName: boolean;\r
31     @Input() public showLabel = true;\r
32     @Input() public canDelete: boolean;\r
33     @Output() public paramChange = new EventEmitter<Parameter>();\r
34     @Output() delete: EventEmitter<Parameter> = new EventEmitter<Parameter>();\r
35 \r
36     public sourceEnum = ValueSource;\r
37     public valueGroupClass;\r
38     public valueClass;\r
39     public showValueSource: boolean = true;\r
40 \r
41     constructor(private dataAccessService: DataAccessService) { }\r
42 \r
43     public ngOnInit(): void {\r
44         if (1 === this.valueSource.length) {\r
45             this.showValueSource = false;\r
46         }\r
47         this.valueClass = {\r
48             'col-md-9': this.showValueSource,\r
49             'col-md-12': !this.showValueSource\r
50         };\r
51 \r
52         this.valueGroupClass = {\r
53             'col-md-7': this.canDelete,\r
54             'col-md-9': !this.canDelete\r
55         };\r
56     }\r
57 \r
58     public deleteParam(): void {\r
59         this.delete.emit();\r
60     }\r
61 \r
62     public modelChange(value: any) {\r
63         this.param.value = value;\r
64         this.paramChange.emit(this.param)\r
65     }\r
66 \r
67 }\r