adding entry schema for list type 57/115257/1
authorEltanany Shaaban <shaaban.eltanany.ext@orange.com>
Sun, 22 Nov 2020 10:57:00 +0000 (12:57 +0200)
committerEltanany Shaaban <shaaban.eltanany.ext@orange.com>
Sun, 22 Nov 2020 10:57:00 +0000 (12:57 +0200)
Issue-ID: CCSDK-2975
Signed-off-by: Eltanany Shaaban <shaaban.eltanany.ext@orange.com>
Change-Id: Ic2b7c8955ac7621f6064bb0d63ee9796433edb24

cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.html
cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/action-attributes/action-attributes.component.ts

index 013fa8a..23adaef 100644 (file)
                             <div class="col-sm-9">
                                 <div class="list-group list-group-horizontal">
                                     <button type="button" class="list-group-item list-group-item-action"
-                                            (click)="setInputType('String')">
+                                            (click)="setInputType('string')">
                                         String
                                     </button>
                                     <button type="button" class="list-group-item list-group-item-action"
-                                            (click)="setInputType('Integer')">Integer
+                                            (click)="setInputType('integer')">Integer
                                     </button>
                                     <button type="button" class="list-group-item list-group-item-action"
-                                            (click)="setInputType('Boolean')">Boolean
+                                            (click)="setInputType('boolean')">Boolean
                                     </button>
                                     <button type="button" class="list-group-item list-group-item-action"
-                                            (click)="setInputType('List')">List
+                                            (click)="setInputType('list')">List
                                     </button>
                                     <button type="button" class="list-group-item list-group-item-action"
                                             (click)="setInputType('Other')">Other
                             <div class="col-sm-9">
                                 <div class="list-group list-group-horizontal">
                                     <button type="button" class="list-group-item list-group-item-action"
-                                            (click)="setOutputType('String')">String
+                                            (click)="setOutputType('string')">String
                                     </button>
                                     <button type="button" class="list-group-item list-group-item-action"
-                                            (click)="setOutputType('Integer')">
+                                            (click)="setOutputType('integer')">
                                         Integer
                                     </button>
                                     <button type="button" class="list-group-item list-group-item-action"
-                                            (click)="setOutputType('Boolean')">
+                                            (click)="setOutputType('boolean')">
                                         Boolean
                                     </button>
                                     <button type="button" class="list-group-item list-group-item-action"
-                                            (click)="setOutputType('List')">
+                                            (click)="setOutputType('list')">
                                         List
                                     </button>
                                     <button type="button" class="list-group-item list-group-item-action"
index 668aff9..95b53fb 100644 (file)
@@ -114,6 +114,7 @@ export class ActionAttributesComponent implements OnInit {
     }
 
     addInput(input: InputActionAttribute) {
+        console.log(input);
         if (input && input.type && input.name) {
             const insertedInputActionAttribute = Object.assign({}, input);
             this.newInputs.push(insertedInputActionAttribute);
@@ -224,11 +225,21 @@ export class ActionAttributesComponent implements OnInit {
     }
 
     private appendAttributes(inputActionAttribute: InputActionAttribute) {
-        return '"' + inputActionAttribute.name + '" : {\n' +
+        const entrySchema: string = this.getEntrySchema(inputActionAttribute);
+        const input = '"' + inputActionAttribute.name + '" : {\n' +
             '            "required" : ' + inputActionAttribute.required + ',\n' +
             '            "type" : "' + inputActionAttribute.type + '",\n' +
-            '            "description" : "' + inputActionAttribute.description + '"\n' +
-            '          },';
+            '            "description" : "' + inputActionAttribute.description + '"';
+        return input + entrySchema;
+    }
+
+    private getEntrySchema(inputActionAttribute: InputActionAttribute) {
+        return inputActionAttribute.type.includes('list') ?
+            ',\n\t' + '"entry_schema" : {\n' +
+            '              "type" : "string"\n' +
+            '            }\n},'
+            :
+            '\n },';
     }
 
     setInputAndOutputs(targetName) {
@@ -436,15 +447,17 @@ export class ActionAttributesComponent implements OnInit {
     }
 
 
-    private appendOutputAttributes(output: OutputActionAttribute) {
-        return '"' + output.name + '" : {\n' +
-            '            "required" : ' + output.required + ',\n' +
-            '            "type" : "' + output.type + '",\n' +
-            '            "description" : "' + output.description + '",\n' +
+    private appendOutputAttributes(outputActionAttribute: OutputActionAttribute) {
+        const entrySchema: string = this.getEntrySchema(outputActionAttribute);
+        const output = '"' + outputActionAttribute.name + '" : {\n' +
+            '            "required" : ' + outputActionAttribute.required + ',\n' +
+            '            "type" : "' + outputActionAttribute.type + '",\n' +
+            '            "description" : "' + outputActionAttribute.description + '",\n' +
             '            "value\" :' + '{\n' +
-            '             "get_attribute" : ' + output.value + '\n' +
-            '            }\n' +
-            '          },';
+            '             "get_attribute" : ' + outputActionAttribute.value + '\n' +
+            '            }\n';
+
+        return output + entrySchema;
 
     }
 
@@ -485,4 +498,8 @@ export class ActionAttributesComponent implements OnInit {
             this.designerState.template.workflows[this.actionName][attributeType] = {};
         }
     }
+
+    private checkIfTypeIsList(type: string) {
+        return type.includes('list');
+    }
 }