From 29d40e9c4110c64551d63a26c5fc0d71a5ef85ab Mon Sep 17 00:00:00 2001 From: Ahmedeldeeb50 Date: Thu, 12 Nov 2020 15:56:27 +0200 Subject: Display input & outputs in View&edit functions. Handle multiple Steps when displaying function from workflow. Issue-ID: CCSDK-2900 Signed-off-by: Ahmedeldeeb50 Change-Id: I0b511be33c6c3ab875789297044cf06afb0b7267 --- .../functions-attribute.component.ts | 54 ++++++++++++++-------- 1 file changed, 34 insertions(+), 20 deletions(-) (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/functions-attribute/functions-attribute.component.ts') diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/functions-attribute/functions-attribute.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/functions-attribute/functions-attribute.component.ts index 362986d96..347f304c8 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/functions-attribute/functions-attribute.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/functions-attribute/functions-attribute.component.ts @@ -44,29 +44,33 @@ export class FunctionsAttributeComponent implements OnInit, OnDestroy { } ngOnInit() { - this.designerStore.state$ - .pipe( - distinctUntilChanged((a: any, b: any) => JSON.stringify(a) === JSON.stringify(b)), - takeUntil(this.ngUnsubscribe)) - .subscribe(designerDashboardState => { - this.designerDashboardState = designerDashboardState; - this.designerState = designerDashboardState; - this.actionName = this.designerState.actionName; - const action = this.designerState.template.workflows[this.actionName] as Action; - + this.designerStore.state$.subscribe(designerDashboardState => { + this.designerState = designerDashboardState; + this.actionName = this.designerState.actionName; + const action = this.designerState.template.workflows[this.actionName] as Action; + this.currentFuncion = new NodeProcess(); + try { console.log(action); if (action) { + // this.designerState.functionName const child = Object.keys(action.steps)[0]; - this.functionName = action.steps[child].target; + this.functionName = this.designerState.functionName; + console.log(this.designerState.template.node_templates); + console.log(this.designerState); console.log(this.designerState.template.node_templates[this.functionName]); // this.currentFuncion = this.designerState.template.node_templates[this.functionName]; // reset inouts&outputs + this.requiredInputs = new Map(); + this.requiredOutputs = new Map(); + this.OptionalInputs = new Map(); + this.optionalOutputs = new Map(); this.toNodeProcess(this.designerState.template.node_templates[this.functionName], this.functionName); const type = this.designerState.template.node_templates[this.functionName].type; this.getNodeType(type); this.onInitMapping(); } - }); + } catch (e) { } + }); this.packageCreationStore.state$ .subscribe(cbaPackage => { @@ -111,24 +115,23 @@ export class FunctionsAttributeComponent implements OnInit, OnDestroy { } toNodeProcess(nodeTemplate, functionName) { - this.requiredInputs = new Map(); - this.requiredOutputs = new Map(); - this.OptionalInputs = new Map(); - this.optionalOutputs = new Map(); console.log(nodeTemplate); this.currentFuncion['instance-name'] = functionName; // tslint:disable-next-line: no-string-literal this.currentFuncion['type'] = nodeTemplate['type']; if (nodeTemplate.interfaces && Object.keys(nodeTemplate.interfaces).length > 0) { const nodeName = Object.keys(nodeTemplate.interfaces)[0]; + // console.log(Object.keys(nodeTemplate.interfaces)); // tslint:disable-next-line: no-string-literal const inputs = nodeTemplate.interfaces[nodeName]['operations']['process']['inputs']; // tslint:disable-next-line: no-string-literal const outputs = nodeTemplate.interfaces[nodeName]['operations']['process']['outputs']; + // console.log(inputs); + if (inputs) { for (const [key, value] of Object.entries(inputs)) { - console.log(key + '-' + value); + console.log(key + ' - ' + value); this.currentFuncion.inputs[key] = value; } } @@ -145,8 +148,10 @@ export class FunctionsAttributeComponent implements OnInit, OnDestroy { this.ngUnsubscribe.complete(); } - saveFunctionData() { + addTemplates() { } + saveFunctionData() { + this.nodeTemplates = new NodeTemplate(''); // tslint:disable-next-line: variable-name const node_templates = {}; const finalFunctionData = this.currentFuncion; @@ -159,7 +164,12 @@ export class FunctionsAttributeComponent implements OnInit, OnDestroy { console.log(value); console.log(finalFunctionData.inputs['artifact-prefix-names']); - if (Array.isArray(finalFunctionData.inputs['artifact-prefix-names'])) { + if (finalFunctionData.inputs['artifact-prefix-names'] === undefined) { + finalFunctionData.inputs['artifact-prefix-names'] = [key]; + } else if ( + Array.isArray(finalFunctionData.inputs['artifact-prefix-names']) && + !finalFunctionData.inputs['artifact-prefix-names'].includes(key) + ) { finalFunctionData.inputs['artifact-prefix-names'].push(key); } @@ -217,7 +227,6 @@ export class FunctionsAttributeComponent implements OnInit, OnDestroy { } - addTemplates() { } setArtifact(predefined: boolean) { if (predefined) { this.currentFuncion.inputs['artifact-prefix-names'] = []; @@ -291,6 +300,11 @@ export class FunctionsAttributeComponent implements OnInit, OnDestroy { for (const [key, value] of Object.entries(fields)) { if (key === 'artifact-prefix-names') { this.artifactPrefix = true; + // in edit&view mode need to check first if this input||output already exists + } else if (key in this.currentFuncion.inputs) { + this.requiredInputs.set(key, Object.assign({}, value)); + } else if (key in this.currentFuncion.outputs) { + this.requiredOutputs.set(key, Object.assign({}, value)); } else if (value['required']) { console.log('This field is required = ' + key); if (type === 'inputs') { -- cgit 1.2.3-korg