Add multple customs to scenario 29/53429/1
authorthuva4 <tharma.thuva@gmail.com>
Fri, 9 Mar 2018 17:12:05 +0000 (22:42 +0530)
committerthuva4 <tharma.thuva@gmail.com>
Fri, 9 Mar 2018 17:12:05 +0000 (22:42 +0530)
User can add multiple customs by giving a
comma or space sperated string

JIRA: RELENG-344

Change-Id: I8e4b37fc476f39e10321755f1e67fe3605178406
Signed-off-by: thuva4 <tharma.thuva@gmail.com>
testapi/opnfv_testapi/tests/UI/e2e/scenarioControllerSpec.js
testapi/opnfv_testapi/ui/components/scenarios/modals/customModal.html
testapi/opnfv_testapi/ui/components/scenarios/modals/projectModal.html
testapi/opnfv_testapi/ui/components/scenarios/scenario/scenarioController.js
testapi/opnfv_testapi/ui/components/scenarios/scenariosController.js

index 14f3089..7777721 100644 (file)
@@ -1040,10 +1040,7 @@ describe('testing the scenarios page for user', function () {
         buttonAdd.click()
         var custom = element(by.model('customModalCtrl.custom'));
         browser.wait(EC.visibilityOf(custom), 5000);
-        custom.sendKeys('testC');
-        var buttonAddCustom = element(by.xpath('//*[@id="ng-app"]/body/div[3]/div/div/div/div[1]/div/fieldset/div/div/div/table/tfoot/tr/td[2]/input'))
-        buttonAddCustom.click();
-        custom.sendKeys('testB');
+        custom.sendKeys('testC,testD,');
         var buttonOk = element(by.xpath('//*[@id="ng-app"]/body/div[3]/div/div/div/div[2]/button[1]'))
         buttonOk.click()
         expect(element(by.cssContainingText(".alert","Customs are successfully updated."))
index 90e4544..0cd2663 100644 (file)
@@ -8,18 +8,7 @@
                                 <div class="update-project">
                                         <label for="cpid" class="control-label col-sm-4">Custom: </label>
                                     <table cellpadding="0" cellspacing="0">
-                                        <tbody ng-repeat="custom in customModalCtrl.customs">
-                                            <tr>
-                                                <td>
-                                                    <div class="col-sm-12">
-                                                        <input type="text" class="form-control" value="{{custom}}" disabled/>
-                                                        <p class="help-block"></p>
-                                                    </div>
-                                                </td>
-                                                <td><input type="button" class="btn btn-danger" ng-click="customModalCtrl.remove($index)" value="Remove" /></td>
-                                            </tr>
-                                        </tbody>
-                                        <tfoot>
+                                        <tbody>
                                             <tr>
                                                 <td>
                                                     <div class="col-sm-12">
@@ -27,9 +16,8 @@
                                                         <p class="help-block"></p>
                                                     </div>
                                                 </td>
-                                                <td><input type="button" class="btn btn-primary" ng-click="customModalCtrl.add()" value="Add" /></td>
                                             </tr>
-                                        </tfoot>
+                                        </tbody>
                                     </table>
                                 </div>
                         </div>
index 0a14be9..171cc33 100644 (file)
@@ -38,7 +38,7 @@
                     </tr>
                     </thead>
                     <tbody>
-                    <tr ng-repeat-start="(index, custom) in projectModalCtrl.project.customs" style="padding:9px">
+                    <tr ng-repeat-start="custom in projectModalCtrl.project.customs" style="padding:9px">
                         <td>{{custom}}</td>
                     </tr>
                     <tr ng-repeat-end=>
index 36e54f5..51f4242 100644 (file)
         ctrl.confirm = confirm;
         ctrl.cancel = cancel;
         ctrl.data = angular.copy(data);
-        ctrl.open = open;
-        ctrl.add = add;
-        ctrl.remove = remove;
 
         ctrl.customs = [];
 
-        function add() {
-            var custom = ctrl.custom;
-            if(custom!="" && custom!=undefined ){
-                ctrl.customs.push(custom);
-                ctrl.custom = "";
-            }
-        };
-
-        function remove(index) {
-            // var name = ctrl.customs[index].Name;
-            ctrl.customs.splice(index, 1);
-
-        }
-
-        /**
-         * Initiate confirmation and call the success handler with the
-         * inputs.
-         */
         function confirm() {
             var custom = ctrl.custom;
             if(custom!="" && custom!=undefined ){
-                ctrl.customs.push(custom);
+                ctrl.customs = custom.split(/[ ,]+/).filter(Boolean);
             }
+            console.log(ctrl.customs)
             ctrl.data.successHandler(ctrl.customs,ctrl.data.project,ctrl.data.version,ctrl.data.installer);
             $uibModalInstance.dismiss('cancel');
 
index dff9f26..98e4089 100644 (file)
         }
 
         function createScenario(scenario) {
-            console.log(scenario)
             ctrl.scenarioRequest =
                 $http.post(ctrl.url, scenario).success(function (data){
                     ctrl.showCreateSuccess = true;
         }
 
         function openVersionModal(){
-            console.log("Hello");
             $uibModal.open({
                 templateUrl: 'testapi-ui/components/scenarios/modals/versionModal.html',
                 controller: 'versionModalCtrl as versionModalCtrl',
             $uibModalInstance.dismiss('cancel');
         }
 
-        function handleModalCustom(custom){
-            ctrl.project.customs.push(custom);
+        function handleModalCustom(customs){
+            for (var custom in customs){
+                ctrl.project.customs.push(customs[custom]);
+            }
         }
 
         function openCustomModal(){
         ctrl.cancel = cancel;
         ctrl.data = angular.copy(data);
         ctrl.open = open;
+        ctrl.customs = []
 
 
         /**
          * inputs.
          */
         function confirm() {
-            ctrl.data.successHandler(ctrl.custom);
+            var custom = ctrl.custom;
+            if(custom!="" && custom!=undefined ){
+                ctrl.customs = custom.split(/[ ,]+/).filter(Boolean);
+            }
+            ctrl.data.successHandler(ctrl.customs);
             $uibModalInstance.dismiss('cancel');
 
         }