1 import {Component, OnInit} from '@angular/core';
2 import {InputActionAttribute, OutputActionAttribute} from './models/InputActionAttribute';
5 selector: 'app-action-attributes',
6 templateUrl: './action-attributes.component.html',
7 styleUrls: ['./action-attributes.component.css']
9 export class ActionAttributesComponent implements OnInit {
13 actionAttributesSideBar: boolean;
14 inputActionAttribute = new InputActionAttribute();
15 outputActionAttribute = new OutputActionAttribute();
16 isInputOtherType: boolean;
17 isOutputOtherType: boolean;
28 addInput(input: InputActionAttribute) {
29 if (input && input.type && input.name) {
30 const insertedInputActionAttribute = Object.assign({}, input);
31 this.inputs.push(insertedInputActionAttribute);
35 addOutput(output: OutputActionAttribute) {
36 if (output && output.type && output.name) {
37 const insertedOutputActionAttribute = Object.assign({}, output);
38 this.outputs.push(insertedOutputActionAttribute);
42 setInputType(type: string) {
43 this.inputActionAttribute.type = type;
44 this.isInputOtherType = this.checkIfTypeIsOther(type);
47 setInputRequired(isRequired) {
48 this.inputActionAttribute.required = isRequired;
51 setOutputRequired(isRequired) {
52 this.outputActionAttribute.required = isRequired;
55 setOutputType(type: string) {
56 this.outputActionAttribute.type = type;
57 this.isOutputOtherType = this.checkIfTypeIsOther(type);
60 checkIfTypeIsOther(type) {
61 return type.includes('Other');
65 console.log(this.inputActionAttribute);
66 console.log(this.outputActionAttribute);
67 this.addInput(this.inputActionAttribute);
68 this.addOutput(this.outputActionAttribute);
69 this.clearFormInputs();
72 private clearFormInputs() {
73 this.inputActionAttribute = new InputActionAttribute();
74 this.outputActionAttribute = new OutputActionAttribute();
75 this.outputOtherType = '';
76 this.inputOtherType = '';