From 978dbcf0a196acbafad72fe1e2478ec0e384f02f Mon Sep 17 00:00:00 2001 From: "Christopher Lott (cl778h)" Date: Wed, 23 Aug 2017 18:27:19 -0400 Subject: Deliver centralized role management feature Repair multiple defects also. Revise deployment to use docker-compose. Remove all zip archives. Issue: PORTAL-21, PORTAL-25, PORTAL-28, PORTAL-52, PORTAL-69, PORTAL-74, PORTAL-76, PORTAL-80, PORTAL-82 Change-Id: Ie72fec7d35ba78beb162bba6ed27b2caee340c61 Signed-off-by: Christopher Lott (cl778h) --- .../app/views/role/popup_modal_rolefunction.html | 95 ++++++--- .../client/app/views/role/role-controller.js | 212 ++++++++++++--------- .../views/role/role-function-list-controller.js | 165 ++++++++-------- .../client/app/views/role/role-list-controller.js | 72 ++----- .../client/app/views/role/role.html | 37 +++- .../client/app/views/role/role.less | 25 ++- .../app/views/role/role_childrole_popup.html | 19 +- .../client/app/views/role/role_function_list.html | 11 +- .../app/views/role/role_functions_popup.html | 38 ++-- .../client/app/views/role/role_list.html | 27 ++- .../app/views/role/rolefunctionpopupController.js | 156 +++++++-------- .../app/views/role/rolepopupmodelController.js | 33 ++-- 12 files changed, 516 insertions(+), 374 deletions(-) (limited to 'ecomp-portal-FE-common/client/app/views/role') diff --git a/ecomp-portal-FE-common/client/app/views/role/popup_modal_rolefunction.html b/ecomp-portal-FE-common/client/app/views/role/popup_modal_rolefunction.html index c5673da8..ad05f9d5 100644 --- a/ecomp-portal-FE-common/client/app/views/role/popup_modal_rolefunction.html +++ b/ecomp-portal-FE-common/client/app/views/role/popup_modal_rolefunction.html @@ -17,39 +17,85 @@ limitations under the License. ================================================================================ --> + + -
-
-
+
+
+ -
-
- *Name:
- -
Name is Required -
-
-
-
-
- *Code: +
+
- -
Code is Required -
- +
+ +
+
+
+
*Name:
+ -
+
+ Name is Required +
+
+
+
+
*Code:
+ + +
+ Code is Required +
+
+ + +
+ + +
+ diff --git a/ecomp-portal-FE-common/client/app/views/role/role-controller.js b/ecomp-portal-FE-common/client/app/views/role/role-controller.js index 2bd522a4..22b28e93 100644 --- a/ecomp-portal-FE-common/client/app/views/role/role-controller.js +++ b/ecomp-portal-FE-common/client/app/views/role/role-controller.js @@ -18,70 +18,80 @@ * ================================================================================ */ -app.controller('roleController', function ($scope, $http, confirmBoxService, ngDialog, RoleService, conf, $stateParams){ + +app.controller('roleController', function ($scope, $http, confirmBoxService, ngDialog, RoleService, conf, $stateParams,$modal,utilsService){ //$scope.role=${role}; $( "#dialogRoleFunction" ).hide(); $( "#dialogChildRole" ).hide(); - - //$scope.ociavailableRoleFunctions=${availableRoleFunctions}; + $scope.routeRoleId = $stateParams.roleId; + + // $scope.ociavailableRoleFunctions=${availableRoleFunctions}; $scope.fetchRoles = function() { - - RoleService.getRole($stateParams.roleId).then(function(data){ - - var j = data; - $scope.data = JSON.parse(j.data); - - $scope.role =JSON.parse($scope.data.role); - - $scope.ociavailableRoleFunctions =JSON.parse($scope.data.availableRoleFunctions); - $scope.availableRoleFunctions=[]; - - if($scope.ociavailableRoleFunctions) - $.each($scope.ociavailableRoleFunctions, function(i, a){ - var availableRoleFunction = a; - availableRoleFunction.selected = false; - $.each($scope.role.roleFunctions, function(j, b){ - if(a.code === b.code) { - availableRoleFunction.selected = true; - } - }); - $scope.availableRoleFunctions.push(availableRoleFunction); - }); - + $scope.isLoadingRoleFunctions = true; + utilsService.showLoadingLayer(); // show the loading layer + RoleService.getRole($stateParams.roleId).then(function(data){ + if(data==null || data ==''){ + var msg={ + content:'Something is wrong. Please contact the administrator for more information' + }; + confirmBoxService.reloadPageConfirm(msg); + }else{ + var j = data; + $scope.data = JSON.parse(j.data); + $scope.role =JSON.parse($scope.data.role); + $scope.routeRoleId = $stateParams.roleId; + $scope.ociavailableRoleFunctions =JSON.parse($scope.data.availableRoleFunctions); + $scope.isGlobalRoleChecked=($scope.role.name.indexOf('global_')==-1)?false:true; - $scope.ociavailableRoles=JSON.parse($scope.data.availableRoles); - $scope.availableRoles=[]; - - if($scope.ociavailableRoles) - $.each($scope.ociavailableRoles, function(i, a){ - var availableRole = a; - availableRole.selected = false; - if($scope.role.childRoles){ - $.each($scope.role.childRoles, function(j, b){ - if(a.id === b.id) { - availableRole.selected = true; - } - }); - }; - $scope.availableRoles.push(availableRole); - }); - - - },function(error){ - console.log("RoleService.getRole failed", error); - //reloadPageOnce(); - }); + $scope.availableRoleFunctions=[]; + + if($scope.ociavailableRoleFunctions) + $.each($scope.ociavailableRoleFunctions, function(i, a){ + var availableRoleFunction = a; + availableRoleFunction.selected = false; + $.each($scope.role.roleFunctions, function(j, b){ + if(a.code === b.code) { + availableRoleFunction.selected = true; + } + }); + $scope.availableRoleFunctions.push(availableRoleFunction); + }); + $scope.ociavailableRoles=JSON.parse($scope.data.availableRoles); + $scope.availableRoles=[]; + + if($scope.ociavailableRoles) + $.each($scope.ociavailableRoles, function(i, a){ + var availableRole = a; + availableRole.selected = false; + if($scope.role.childRoles){ + $.each($scope.role.childRoles, function(j, b){ + if(a.id === b.id) { + availableRole.selected = true; + } + }); + }; + $scope.availableRoles.push(availableRole); + }); + } + },function(error){ + console.log("RoleService.getRole failed", error); + }).finally(function(){ + utilsService.hideLoadingLayer(); + $scope.isLoadingRoleFunctions = false; + }); } $scope.fetchRoles(); + $scope.isGlobalRoleChecked; + $scope.saveRole = function() { var exists = false,x; for(x in $scope.availableRoles){ if($scope.availableRoles[x].name==$scope.role.name){ exists = true; - //$modalInstance.close({availableRoleFunctions:message.availableRoleFunctions}); + // $modalInstance.close({availableRoleFunctions:message.availableRoleFunctions}); } } if (exists) { @@ -89,17 +99,30 @@ app.controller('roleController', function ($scope, $http, confirmBoxService, ngD } else { var uuu = conf.api.saveRole + "?role_id="+$stateParams.roleId; + if($scope.isGlobalRoleChecked ){ + $scope.role.name = ($scope.role.name.indexOf('global_')==-1)?('global_'+$scope.role.name):($scope.role.name); + + }else{ + $scope.role.name=$scope.role.name.replace('global_',''); + } var postData = { role: $scope.role, childRoles: $scope.role.childRoles, roleFunctions : $scope.role.roleFunctions }; - $http.post(uuu, JSON.stringify(postData)).then(function(res) { - // console.log('roleController::saveRole: ' + JSON.stringify(res)); - if (res && res.data && res.data.role) + $http.post(uuu, JSON.stringify(postData,$stateParams.roleId)).then(function(res) { + // console.log('roleController::saveRole: ' + + // JSON.stringify(res)); + if (res && res.data && res.data.role){ confirmBoxService.showInformation("Update Successful."); - else + $scope.routeRoleId = res.role; + $scope.isSaveClicked=true; + $scope.role=''; + } + + else{ confirmBoxService.showInformation('Failed to create role: ' + res.data.error) + } }, function(res){ console.log('post failed', res.data); @@ -110,42 +133,42 @@ app.controller('roleController', function ($scope, $http, confirmBoxService, ngD }; $scope.addNewRoleFunctionModalPopup = function() { - var modalInstance = ngDialog.open({ - templateUrl: 'app/views/role/role_functions_popup.html', - controller: 'rolepopupController', - - resolve: { - roleId: function () { - return $stateParams.roleId; - }, - role: function () { - return $scope.role; + var modalInstance = $modal.open({ + templateUrl: 'app/views/role/role_functions_popup.html', + controller: 'rolepopupController', + sizeClass: 'modal-medium', + resolve: { + roleId: function () { + return $stateParams.roleId; }, - availableRoles: function () { - return $scope.ociavailableRoles; - }, - availableRoleFunctions: function () { - return $scope.ociavailableRoleFunctions; - }, - } - }); - modalInstance.closePromise.then(response => { - if($stateParams.roleId === '0'){ - return $scope.role; - }else{ - $scope.fetchRoles(); - } - // $scope.role=response.role; - }); + role: function () { + return $scope.role; + }, + availableRoles: function () { + return $scope.ociavailableRoles; + }, + availableRoleFunctions: function () { + return $scope.ociavailableRoleFunctions; + } + } + }); + + modalInstance.result.finally(function () { + if($stateParams.roleId === '0'){ + return $scope.role; + }else{ + $scope.fetchRoles(); + } + }); }; $scope.addNewChildRoleModalPopup = function() { - var modalInstance = ngDialog.open({ - templateUrl: 'app/views/role/role_childrole_popup.html', - controller: 'rolepopupController', - - resolve: { - roleId: function () { + var modalInstance = $modal.open({ + templateUrl: 'app/views/role/role_childrole_popup.html', + controller: 'rolepopupController', + sizeClass: 'modal-medium', + resolve: { + roleId: function () { return $stateParams.roleId; }, role: function () { @@ -156,16 +179,17 @@ app.controller('roleController', function ($scope, $http, confirmBoxService, ngD }, availableRoleFunctions: function () { return $scope.ociavailableRoleFunctions; - }, - } - }).closePromise.then(function(response){ - if($stateParams.roleId === '0'){ - return $scope.role; - }else{ - $scope.fetchRoles(); - } - //$scope.role=response.role; + } + } }); + + modalInstance.result.finally(function () { + if($stateParams.roleId === '0'){ + return $scope.role; + }else{ + $scope.fetchRoles(); + } + }); }; $scope.removeRoleFunction = function(roleFunction) { diff --git a/ecomp-portal-FE-common/client/app/views/role/role-function-list-controller.js b/ecomp-portal-FE-common/client/app/views/role/role-function-list-controller.js index e7195996..5e7c62cc 100644 --- a/ecomp-portal-FE-common/client/app/views/role/role-function-list-controller.js +++ b/ecomp-portal-FE-common/client/app/views/role/role-function-list-controller.js @@ -17,20 +17,21 @@ * limitations under the License. * ================================================================================ */ -app.controller('roleFunctionListController', function ($scope,RoleService,$http,$state,conf,confirmBoxService, ngDialog){ +app.controller('roleFunctionListController', function ($scope,RoleService,$http,$state,conf,confirmBoxService, ngDialog,$modal){ $( "#dialog" ).hide(); - + $scope.isLoadingRoleFunctions = true; RoleService.getRoleFunctionList().then(function(data){ var j = data; $scope.data = JSON.parse(j.data); $scope.availableRoleFunctions =JSON.parse($scope.data.availableRoleFunctions); - //$scope.resetMenu(); },function(error){ console.log("failed"); //reloadPageOnce(); + }) .finally(function(){ + $scope.isLoadingRoleFunctions = false; }); $scope.editRoleFunction = null; @@ -46,32 +47,35 @@ app.controller('roleFunctionListController', function ($scope,RoleService,$http, $scope.editRoleFunction = availableRoleFunction; $scope.availableRoleFunctionsTemp=$scope.availableRoleFunctions; //$scope.availableRoleFunctions={}; - var modalInstance = ngDialog.open({ - templateUrl: 'app/views/role/popup_modal_rolefunction.html', - controller: 'rolefunctionpopupController', - resolve: { - message: function () { - var message = { - availableRoleFunction: $scope.editRoleFunction, - availableRoleFunctions: $scope.availableRoleFunctionsTemp - }; - return message; - }, - isEditing: function () { - return true; - } - } - }); - modalInstance.closePromise.then(response =>{ - if(response.value!=null){ - if(response.value.result){ - $scope.availableRoleFunctions=response.value.availableRoleFunctions; - } - } - /*else - $scope.availableRoleFunctions=$scope.availableRoleFunctionsTemp; - */ - }); + + var modalInstance = $modal.open({ + templateUrl: 'app/views/role/popup_modal_rolefunction.html', + controller: 'rolefunctionpopupController', + sizeClass: 'modal-small', + resolve: { + message: function () { + var message = { + availableRoleFunction: $scope.editRoleFunction, + availableRoleFunctions: $scope.availableRoleFunctionsTemp + }; + return message; + }, + isEditing: function () { + return true; + } + } + }); + + modalInstance.result.then(function (response) { + if(response.value!=null){ + if(response.value.result){ + $scope.availableRoleFunctions=response.value.availableRoleFunctions; + } + } + else + $scope.availableRoleFunctions=$scope.availableRoleFunctionsTemp; + + }); }; $scope.addNewRoleFunctionModalPopup = function(availableRoleFunction) { @@ -79,34 +83,36 @@ app.controller('roleFunctionListController', function ($scope,RoleService,$http, $scope.editRoleFunction = null; $scope.availableRoleFunctionsTemp=$scope.availableRoleFunctions; //$scope.availableRoleFunctions={}; - var modalInstance = ngDialog.open({ - templateUrl: 'app/views/role/popup_modal_rolefunction.html', - controller: 'rolefunctionpopupController', - resolve: { - message: function () { - var message = { - availableRoleFunction: $scope.editRoleFunction, - availableRoleFunctions: $scope.availableRoleFunctionsTemp - }; - return message; - }, - isEditing: function () { - return false; - } - } - }); - modalInstance.closePromise.then(response => { - if(response.value!=null){ - if(response.value.result){ - $scope.availableRoleFunctions=response.value.availableRoleFunctions; - } - } - /* if(response.availableRoleFunctions != undefined) - $scope.availableRoleFunctions=response.availableRoleFunctions; - else - $scope.availableRoleFunctions=$scope.availableRoleFunctionsTemp; - */ - }); + var modalInstance = $modal.open({ + templateUrl: 'app/views/role/popup_modal_rolefunction.html', + controller: 'rolefunctionpopupController', + sizeClass: 'modal-small', + resolve: { + message: function () { + var message = { + availableRoleFunction: $scope.editRoleFunction, + availableRoleFunctions: $scope.availableRoleFunctionsTemp + }; + return message; + }, + isEditing: function () { + return false; + } + } + }); + + modalInstance.result.then(function (response) { + if(response.value!=null){ + if(response.value.result){ + $scope.availableRoleFunctions=response.value.availableRoleFunctions; + } + } + if(response.availableRoleFunctions != undefined) + $scope.availableRoleFunctions=response.availableRoleFunctions; + else + $scope.availableRoleFunctions=$scope.availableRoleFunctionsTemp; + + }); }; $scope.addNewRoleFunctionPopup = function() { @@ -134,27 +140,28 @@ app.controller('roleFunctionListController', function ($scope,RoleService,$http, $scope.removeRole = function(availableRoleFunction) { confirmBoxService.confirm("You are about to delete the role function "+availableRoleFunction.name+". Do you want to continue?").then( - function(confirmed){ - if(confirmed){ - $scope.availableRoleFunctionsTemp=$scope.availableRoleFunctions; - //$scope.availableRoleFunctions={}; - var uuu = conf.api.removeRoleFunction; - var postData={availableRoleFunction: availableRoleFunction}; - $http.post(uuu,postData).then(function(response) { - var data = response.data; - if(data.availableRoleFunctions == undefined) - confirmBoxService.showInformation("Error while deleting: "+ data); - else - $scope.availableRoleFunctions=data.availableRoleFunctions; - }, - function() { - $scope.availableRoleFunctions=$scope.availableRoleFunctionsTemp; - confirmBoxService.showInformation("Error while deleting: "+ data.responseText); - } - ); - } - }); - - }; + function(confirmed){ + if(confirmed){ + $scope.availableRoleFunctionsTemp=$scope.availableRoleFunctions; + //$scope.availableRoleFunctions={}; + var uuu = conf.api.removeRoleFunction; + var postData=availableRoleFunction; + $http.post(uuu,postData).then(function(response) { + var data = response.data; + if(data == undefined) + confirmBoxService.showInformation("Error while deleting: "+ data); + else + $scope.availableRoleFunctionsTemp.splice($scope.availableRoleFunctionsTemp.indexOf(availableRoleFunction), 1); + $scope.availableRoleFunctions=$scope.availableRoleFunctionsTemp; + }, + function() { + $scope.availableRoleFunctions=$scope.availableRoleFunctionsTemp; + confirmBoxService.showInformation("Error while deleting: "+ data.responseText); + } + ); + } + }); + + }; }); diff --git a/ecomp-portal-FE-common/client/app/views/role/role-list-controller.js b/ecomp-portal-FE-common/client/app/views/role/role-list-controller.js index 2e1acf37..582706c5 100644 --- a/ecomp-portal-FE-common/client/app/views/role/role-list-controller.js +++ b/ecomp-portal-FE-common/client/app/views/role/role-list-controller.js @@ -17,7 +17,7 @@ * limitations under the License. * ================================================================================ */ -app.controller('roleListController', function ($scope,RoleService,confirmBoxService,conf,$state,$http){ +app.controller('roleListController', function ($scope,RoleService,confirmBoxService,conf,$state,$http,$log){ $scope.showSpinner = true; RoleService.getRoles().then(function(data){ @@ -26,20 +26,16 @@ app.controller('roleListController', function ($scope,RoleService,confirmBoxServ $scope.data = JSON.parse(j.data); $scope.availableRoles =JSON.parse($scope.data.availableRoles); $scope.showSpinner = false; - //$scope.resetMenu(); },function(error){ - console.log("failed"); - //reloadPageOnce(); + $log.debug('failed'); }); - $scope.goToUrl = function(roleIdVal) { + $scope.goToUrl = function(roleIdVal) { $state.go("root.role", {"roleId":roleIdVal}); - } - //console.log($scope.availableRoles); + } $scope.toggleRole = function(selected,availableRole) { - //alert('toggleRole: '+selected); var toggleType = null; if(selected) { toggleType = "activate"; @@ -48,57 +44,34 @@ app.controller('roleListController', function ($scope,RoleService,confirmBoxServ } confirmBoxService.confirm("You are about to "+toggleType+" the role "+availableRole.name+". Do you want to continue?").then( - function(confirmed){ + function(confirmed){ - if(confirmed) { - var uuu = conf.api.toggleRole; + if(confirmed) { + var uuu = conf.api.toggleRole; var postData={role:availableRole}; $http.post(uuu, postData).then(function(response) { var data = response.data; if (typeof data === 'object') { - console.log(data); + $log.debug('data:'+data); $scope.availableRoles=data.availableRoles; - console.log($scope.availableRoles); + $log.debug('role::availableRoles:'+$scope.availableRoles); } else { // } }, function(response) { - console.log(response.data); + debug.log('response:'+response); availableRole.active=!availableRole.active; confirmBoxService.showInformation("Error while saving."); }); - /* - $.ajax({ - type : 'POST', - url : uuu, - dataType: 'json', - contentType: 'application/json', - data: JSON.stringify(postData), - success : function(data){ - console.log(data); - $scope.$apply(function(){$scope.availableRoles=data.availableRoles;}); - console.log($scope.availableRoles); - }, - error : function(data){ - console.log(data); - availableRole.active=!availableRole.active; - confirmBoxService.showInformation("Error while saving."); - } - }); - */ } - else { - availableRole.active=!availableRole.active; - } - + + }) .catch(function(err) { + $log.error('roleListController::confirmBoxService.confirm error:', err); + availableRole.active=!availableRole.active; }); - //, - //function(){ - // availableRole.active=!availableRole.active; - //}) }; @@ -109,20 +82,7 @@ app.controller('roleListController', function ($scope,RoleService,confirmBoxServ function(confirmed){ var uuu = conf.api.removeRole; var postData={role:role}; - /* $.ajax({ - type : 'POST', - url : uuu, - dataType: 'json', - contentType: 'application/json', - data: JSON.stringify(postData), - success : function(data){ - $scope.$apply(function(){$scope.availableRoles=data.availableRoles;}); - }, - error : function(data){ - console.log(data); - confirmBoxService.showInformation("Error while deleting: "+ data.responseText); - } - }); */ + $http.post(uuu, postData).then(function(response) { @@ -134,7 +94,7 @@ app.controller('roleListController', function ($scope,RoleService,confirmBoxServ } }, function(response) { - console.log(response.data); + $log.debug('response:'+response.data); confirmBoxService.showInformation("Error while deleting: "+ data.responseText); }); diff --git a/ecomp-portal-FE-common/client/app/views/role/role.html b/ecomp-portal-FE-common/client/app/views/role/role.html index 2356058d..9febc978 100644 --- a/ecomp-portal-FE-common/client/app/views/role/role.html +++ b/ecomp-portal-FE-common/client/app/views/role/role.html @@ -17,6 +17,25 @@ limitations under the License. ================================================================================ --> +
@@ -26,10 +45,18 @@

Please edit the role details below: 


+ +
+ +
- +
@@ -40,12 +67,14 @@

+
+ @@ -57,7 +86,7 @@ @@ -82,7 +111,7 @@ - @@ -90,7 +119,7 @@
-
+
+
- +
diff --git a/ecomp-portal-FE-common/client/app/views/role/role.less b/ecomp-portal-FE-common/client/app/views/role/role.less index 71d240dc..b6e92c9e 100644 --- a/ecomp-portal-FE-common/client/app/views/role/role.less +++ b/ecomp-portal-FE-common/client/app/views/role/role.less @@ -47,4 +47,27 @@ .scroll-bar { border-radius: 0px !important; -} \ No newline at end of file +} + +.admins-table-create-new-admin { + marin-bottom: 50px; +} + +.admins-table-space { + text-align: justify; + text-align-last: auto; +} + +.admins-table-tbody { + max-height: 980px; +} + +.admins-table-btn-txt { + font-size:20px; +} + +.admins-table-btn-create { + margin-bottom: 50px; +} + + diff --git a/ecomp-portal-FE-common/client/app/views/role/role_childrole_popup.html b/ecomp-portal-FE-common/client/app/views/role/role_childrole_popup.html index e96fb062..cf9502a1 100644 --- a/ecomp-portal-FE-common/client/app/views/role/role_childrole_popup.html +++ b/ecomp-portal-FE-common/client/app/views/role/role_childrole_popup.html @@ -19,7 +19,14 @@ -->
-
Select Role Functions
+
+

Select Role Functions

+
+ +
+
+
@@ -44,9 +51,13 @@
-
- -
+
+
+
\ No newline at end of file diff --git a/ecomp-portal-FE-common/client/app/views/role/role_list.html b/ecomp-portal-FE-common/client/app/views/role/role_list.html index 74de7c23..4248b46a 100644 --- a/ecomp-portal-FE-common/client/app/views/role/role_list.html +++ b/ecomp-portal-FE-common/client/app/views/role/role_list.html @@ -17,16 +17,25 @@ limitations under the License. ================================================================================ --> +

Roles

-
- +
+
+
+
+ *-----Indicates Global Roles
+ @@ -38,20 +47,28 @@ - + + - +
+ * + {{rowData.name}} +
+ +
+ + diff --git a/ecomp-portal-FE-common/client/app/views/role/rolefunctionpopupController.js b/ecomp-portal-FE-common/client/app/views/role/rolefunctionpopupController.js index db5bb1b6..41241500 100644 --- a/ecomp-portal-FE-common/client/app/views/role/rolefunctionpopupController.js +++ b/ecomp-portal-FE-common/client/app/views/role/rolefunctionpopupController.js @@ -17,79 +17,85 @@ * limitations under the License. * ================================================================================ */ -app.controller('rolefunctionpopupController', function ($scope, confirmBoxService, message, $http,RoleService, conf, isEditing){ - if(message.availableRoleFunction==null) { - $scope.label='Add Role Function'; - var tempText = ""; - } - else{ - $scope.label='Edit Role Function' - $scope.disableCd=true; - var tempText = new String(message.availableRoleFunction.name); - $scope.editRoleFunction = angular.copy(message.availableRoleFunction); - } - - $scope.tempText = tempText; - $scope.isEditing = isEditing; - - $scope.saveRoleFunction = function(availableRoleFunction) { - var uuu = conf.api.saveRoleFunction; - var postData={availableRoleFunction: availableRoleFunction}; +app.controller('rolefunctionpopupController',function($scope, confirmBoxService, message, $http,RoleService, conf, isEditing) { + if (message.availableRoleFunction == null) { + $scope.label = 'Add Role Function'; + var tempText = ""; + } else { + $scope.label = 'Edit Role Function' + $scope.disableCd = true; + var tempText = new String(message.availableRoleFunction.name); + $scope.editRoleFunction = angular.copy(message.availableRoleFunction); + } - if(availableRoleFunction==null){ - confirmBoxService.showInformation("Please enter valid role function details."); - } - var exists = false,x; - for(x in message.availableRoleFunctions){ - console.log(message.availableRoleFunctions[x].name); - if(message.availableRoleFunctions[x].name==availableRoleFunction.name){ - confirmBoxService.showInformation("Role Function already exists."); - exists = true; - availableRoleFunction.name = $scope.tempText; - break; - } - if(!isEditing){ - if (message.availableRoleFunctions[x].code == availableRoleFunction.code) { - confirmBoxService.showInformation("Code already exists. Please create a role function with a different code to proceed."); - exists = true; - availableRoleFunction.name = $scope.tempText; - break; - } - } - } - - if(!exists && availableRoleFunction.name.trim() != '' && availableRoleFunction.code.trim() != ''){ - $http.post(uuu, JSON.stringify(postData)).then(function(res){ - console.log("data"); -// console.log(res.data); -// $scope.availableRoleFunctionsTemp = res.data.availableRoleFunctions; - RoleService.getRoleFunctionList().then(function(data){ - - var j = data; - $scope.data = JSON.parse(j.data); - $scope.availableRoleFunctions =JSON.parse($scope.data.availableRoleFunctions); - - //$scope.resetMenu(); - $scope.closeThisDialog({result: true, availableRoleFunctions: $scope.availableRoleFunctions }); - },function(error){ - console.log("failed"); - //reloadPageOnce(); - $scope.closeThisDialog(true); - }); - - - }); - - - - - } - }; - - - - $scope.close = function() { - this.closeThisDialog(true); - }; -} -); + $scope.tempText = tempText; + $scope.isEditing = isEditing; + + $scope.saveRoleFunction = function(availableRoleFunction) { + confirmBoxService.confirm( + "You are about to Create the role function "+ availableRoleFunction.name+ ". Do you want to continue?") + .then(function(confirmed) { + if (confirmed) { + + var uuu = conf.api.saveRoleFunction; + var postData = availableRoleFunction; + + if (availableRoleFunction == null) { + confirmBoxService.showInformation("Please enter valid role function details."); + } + var exists = false, x; + for (x in message.availableRoleFunctions) { + console.log(message.availableRoleFunctions[x].name); + if (message.availableRoleFunctions[x].name == availableRoleFunction.name) { + confirmBoxService.showInformation("Role Function already exists."); + exists = true; + availableRoleFunction.name = $scope.tempText; + break; + } + if (!isEditing) { + if (message.availableRoleFunctions[x].code == availableRoleFunction.code) { + confirmBoxService.showInformation("Code already exists. Please create a role function with a different code to proceed."); + exists = true; + availableRoleFunction.name = $scope.tempText; + break; + } + } + } + + if (!exists&& availableRoleFunction.name.trim() != ''&& availableRoleFunction.code.trim() != '') { + $http.post(uuu,JSON.stringify(postData)).then(function(res) { + $scope.availableRoleFunctionsTemp = res.data.availableRoleFunctions; + RoleService.getRoleFunctionList().then( + function(data) { + + var j = data; + $scope.data = JSON.parse(j.data); + $scope.availableRoleFunctions = JSON.parse($scope.data.availableRoleFunctions); + + // $scope.resetMenu(); + /*$scope.closeThisDialog({ + result : true, + availableRoleFunctions : $scope.availableRoleFunctions + });*/ + $scope.$dismiss({result : true,availableRoleFunctions : $scope.availableRoleFunctions}); + }, + function(error) { + console.log("failed"); + // reloadPageOnce(); + //$scope.closeThisDialog(true); + $scope.$dismiss('cancel'); + }); + + }); + + } + }; + + $scope.close = function() { + this.closeThisDialog(true); + }; + } + + ); + } + }); \ No newline at end of file diff --git a/ecomp-portal-FE-common/client/app/views/role/rolepopupmodelController.js b/ecomp-portal-FE-common/client/app/views/role/rolepopupmodelController.js index 1176e50a..67bf3b2e 100644 --- a/ecomp-portal-FE-common/client/app/views/role/rolepopupmodelController.js +++ b/ecomp-portal-FE-common/client/app/views/role/rolepopupmodelController.js @@ -88,9 +88,6 @@ app.controller('rolepopupController', function ($scope, role, roleId, confirmBo } - else { - availableRoleFunction.selected=!availableRoleFunction.selected; - } /* $.ajax({ type : 'POST', @@ -106,7 +103,11 @@ app.controller('rolepopupController', function ($scope, role, roleId, confirmBo } }); */ - }); + }).catch(function(err) { + availableRoleFunction.selected=!availableRoleFunction.selected; + $log.error('roleListController::confirmBoxService.confirm error:', err); + + }); } else { //add role function @@ -127,10 +128,7 @@ app.controller('rolepopupController', function ($scope, role, roleId, confirmBo function(data) { confirmBoxService.showInformation("Error while saving."); }); - } else { - availableRoleFunction.selected=!availableRoleFunction.selected; - } - /* + } /* $.ajax({ type : 'POST', url : uuu, @@ -150,7 +148,10 @@ app.controller('rolepopupController', function ($scope, role, roleId, confirmBo function(){ availableRoleFunction.selected=!availableRoleFunction.selected; })*/ - }); + }).catch(function(err) { + availableRoleFunction.selected=!availableRoleFunction.selected; + $log.error('roleListController::confirmBoxService.confirm error:', err); + }); } @@ -180,10 +181,11 @@ app.controller('rolepopupController', function ($scope, role, roleId, confirmBo function(data) { confirmBoxService.showInformation("Error while saving."); }); - } else { - availableRole.selected=false; } - }); + }).catch(function(err) { + availableRole.selected=!availableRole.selected; + $log.error('roleListController::confirmBoxService.confirm error:', err); + }); /* $.ajax({ type : 'POST', url : uuu, @@ -219,8 +221,6 @@ app.controller('rolepopupController', function ($scope, role, roleId, confirmBo function(data) { confirmBoxService.showInformation("Error while saving."); }); - } else { - availableRole.selected=false; } /* $.ajax({ type : 'POST', @@ -236,7 +236,10 @@ app.controller('rolepopupController', function ($scope, role, roleId, confirmBo } });*/ - }); + }).catch(function(err) { + availableRole.selected=!availableRole.selected; + $log.error('roleListController::confirmBoxService.confirm error:', err); + }); } -- cgit 1.2.3-korg