diff options
author | ShaabanEltanany <shaaban.eltanany.ext@orange.com> | 2020-10-26 13:46:14 +0200 |
---|---|---|
committer | ShaabanEltanany <shaaban.eltanany.ext@orange.com> | 2020-10-26 15:27:30 +0200 |
commit | 4dd2f9d159e12e888e4e6dd9dda245e296e38b98 (patch) | |
tree | fc9b541d51fc131092b1ba8ebc27cbc2ee93af24 /cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.ts | |
parent | 1741f11216bc1325673373996f806bdc4ec81b42 (diff) |
adding inputs and outputs to entry definition (Designer)
Issue-ID: CCSDK-2943
Signed-off-by: ShaabanEltanany <shaaban.eltanany.ext@orange.com>
Change-Id: Iffd5c80ecf3fa35b21ab14b8c70308e0d3ee2a50
Diffstat (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.ts')
-rw-r--r-- | cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.ts | 67 |
1 files changed, 51 insertions, 16 deletions
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.ts index ee4b19930..752f0502d 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.ts @@ -1,6 +1,8 @@ import {Component, OnInit} from '@angular/core'; import {InputActionAttribute, OutputActionAttribute} from './models/InputActionAttribute'; import {DesignerStore} from '../designer.store'; +import {DesignerDashboardState} from '../model/designer.dashboard.state'; +import {Action} from './models/Action'; @Component({ selector: 'app-action-attributes', @@ -18,12 +20,46 @@ export class ActionAttributesComponent implements OnInit { isOutputOtherType: boolean; outputOtherType = ''; inputOtherType = ''; + actionName = ''; + designerState: DesignerDashboardState; constructor(private designerStore: DesignerStore) { } ngOnInit() { + this.designerStore.state$.subscribe(designerState => { + this.designerState = designerState; + if (this.designerState && this.designerState.actionName) { + this.actionName = this.designerState.actionName; + const action = this.designerState.template.workflows[this.actionName] as Action; + this.inputs = []; + if (action.inputs) { + const namesOfInput = Object.keys(action.inputs); + this.inputs = this.extractFields(namesOfInput, action.inputs); + } + this.outputs = []; + if (action.outputs) { + const namesOfOutput = Object.keys(action.outputs); + this.outputs = this.extractFields(namesOfOutput, action.outputs); + } + } + }); + } + + + private extractFields(namesOfOutput: string[], container: {}) { + const fields = []; + for (const nameOutput of namesOfOutput) { + const fieldAttribute = new OutputActionAttribute(); + fieldAttribute.name = nameOutput; + fieldAttribute.description = container[nameOutput].description; + fieldAttribute.required = container[nameOutput].required; + fieldAttribute.type = container[nameOutput].type; + const insertedOutputActionAttribute = Object.assign({}, fieldAttribute); + fields.push(insertedOutputActionAttribute); + } + return fields; } addInput(input: InputActionAttribute) { @@ -63,14 +99,11 @@ export class ActionAttributesComponent implements OnInit { } submitAttributes() { - console.log(this.inputActionAttribute); - console.log(this.outputActionAttribute); this.addInput(this.inputActionAttribute); this.addOutput(this.outputActionAttribute); this.clearFormInputs(); - console.log(this.storeInputs(this.inputs)); - this.designerStore.setInputsToSpecificWorkflow(this.storeInputs(this.inputs)); - console.log(this.storeOutputs(this.outputs)); + this.designerStore.setInputsAndOutputsToSpecificWorkflow(this.storeInputs(this.inputs) + , this.storeOutputs(this.outputs), this.actionName); } private clearFormInputs() { @@ -87,9 +120,10 @@ export class ActionAttributesComponent implements OnInit { inputs += this.appendAttributes(input); }); - const returnedInputMap = new Map<string, string>(); - returnedInputMap.set('inputs', inputs); - return returnedInputMap; + if (inputs.endsWith(',')) { + inputs = inputs.substr(0, inputs.length - 1); + } + return JSON.parse('{' + inputs + '}'); } private storeOutputs(OutputActionAttributes: OutputActionAttribute[]) { @@ -97,16 +131,17 @@ export class ActionAttributesComponent implements OnInit { OutputActionAttributes.forEach(output => { outputs += this.appendAttributes(output); }); - const returnedOutputMap = new Map<string, string>(); - returnedOutputMap.set('outputs', outputs); - return returnedOutputMap; + if (outputs.endsWith(',')) { + outputs = outputs.substr(0, outputs.length - 1); + } + return JSON.parse('{' + outputs + '}'); } private appendAttributes(output: OutputActionAttribute) { - return '"' + output.name + '":{\n' + - ' \'required\': ' + output.required + ',\n' + - ' \'type\': "' + output.type + '",\n' + - ' \'description\': "' + output.description + '"\n' + - ' }' + '\n'; + return '"' + output.name + '" : {\n' + + ' "required" : ' + output.required + ',\n' + + ' "type" : "' + output.type + '",\n' + + ' "description" : "' + output.description + '"\n' + + ' },'; } } |