From 0326a542bfae2126e8fa087c266bee5253f05991 Mon Sep 17 00:00:00 2001 From: thuva4 Date: Fri, 9 Mar 2018 22:42:05 +0530 Subject: Add multple customs to scenario User can add multiple customs by giving a comma or space sperated string JIRA: RELENG-344 Change-Id: I8e4b37fc476f39e10321755f1e67fe3605178406 Signed-off-by: thuva4 --- .../components/scenarios/modals/customModal.html | 16 ++------------- .../components/scenarios/modals/projectModal.html | 2 +- .../scenarios/scenario/scenarioController.js | 24 ++-------------------- .../ui/components/scenarios/scenariosController.js | 15 +++++++++----- 4 files changed, 15 insertions(+), 42 deletions(-) (limited to 'testapi/opnfv_testapi/ui') diff --git a/testapi/opnfv_testapi/ui/components/scenarios/modals/customModal.html b/testapi/opnfv_testapi/ui/components/scenarios/modals/customModal.html index 90e4544..0cd2663 100644 --- a/testapi/opnfv_testapi/ui/components/scenarios/modals/customModal.html +++ b/testapi/opnfv_testapi/ui/components/scenarios/modals/customModal.html @@ -8,18 +8,7 @@
- - - - - - - + - - +
-
- -

-
-
@@ -27,9 +16,8 @@

diff --git a/testapi/opnfv_testapi/ui/components/scenarios/modals/projectModal.html b/testapi/opnfv_testapi/ui/components/scenarios/modals/projectModal.html index 0a14be9..171cc33 100644 --- a/testapi/opnfv_testapi/ui/components/scenarios/modals/projectModal.html +++ b/testapi/opnfv_testapi/ui/components/scenarios/modals/projectModal.html @@ -38,7 +38,7 @@ - + {{custom}} diff --git a/testapi/opnfv_testapi/ui/components/scenarios/scenario/scenarioController.js b/testapi/opnfv_testapi/ui/components/scenarios/scenario/scenarioController.js index 36e54f5..51f4242 100644 --- a/testapi/opnfv_testapi/ui/components/scenarios/scenario/scenarioController.js +++ b/testapi/opnfv_testapi/ui/components/scenarios/scenario/scenarioController.js @@ -434,35 +434,15 @@ 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'); diff --git a/testapi/opnfv_testapi/ui/components/scenarios/scenariosController.js b/testapi/opnfv_testapi/ui/components/scenarios/scenariosController.js index dff9f26..98e4089 100644 --- a/testapi/opnfv_testapi/ui/components/scenarios/scenariosController.js +++ b/testapi/opnfv_testapi/ui/components/scenarios/scenariosController.js @@ -127,7 +127,6 @@ } function createScenario(scenario) { - console.log(scenario) ctrl.scenarioRequest = $http.post(ctrl.url, scenario).success(function (data){ ctrl.showCreateSuccess = true; @@ -270,7 +269,6 @@ } function openVersionModal(){ - console.log("Hello"); $uibModal.open({ templateUrl: 'testapi-ui/components/scenarios/modals/versionModal.html', controller: 'versionModalCtrl as versionModalCtrl', @@ -383,8 +381,10 @@ $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(){ @@ -418,6 +418,7 @@ ctrl.cancel = cancel; ctrl.data = angular.copy(data); ctrl.open = open; + ctrl.customs = [] /** @@ -425,7 +426,11 @@ * 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'); } -- cgit 1.2.3-korg