From 912af09831f57c7f5be47ec698bcc316fe1e5645 Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Wed, 14 Dec 2016 15:35:04 -0500 Subject: [PATCH] Fixed organization add user/admin save button functionality --- .../linkout/addUsers/addUsers.controller.js | 23 +++++++++++++++---- .../organizations-admins.controller.js | 2 +- .../organizations-users.controller.js | 2 +- .../linkout/organizations-linkout.route.js | 3 +++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/awx/ui/client/src/organizations/linkout/addUsers/addUsers.controller.js b/awx/ui/client/src/organizations/linkout/addUsers/addUsers.controller.js index b42d143b00..b45797a70b 100644 --- a/awx/ui/client/src/organizations/linkout/addUsers/addUsers.controller.js +++ b/awx/ui/client/src/organizations/linkout/addUsers/addUsers.controller.js @@ -12,9 +12,9 @@ */ export default ['$scope', '$rootScope', 'ProcessErrors', 'GetBasePath', -'SelectionInit', 'templateUrl', '$state', 'Rest', '$q', 'Wait', +'SelectionInit', 'templateUrl', '$state', 'Rest', '$q', 'Wait', '$window', function($scope, $rootScope, ProcessErrors, GetBasePath, - SelectionInit, templateUrl, $state, Rest, $q, Wait) { + SelectionInit, templateUrl, $state, Rest, $q, Wait, $window) { $scope.$on("linkLists", function() { if ($state.current.name.split(".")[1] === "users") { @@ -32,8 +32,15 @@ function($scope, $rootScope, ProcessErrors, GetBasePath, $scope.add_users = $scope.$parent.add_user_dataset.results; $scope.selectedItems = []; - $scope.$on('selectedOrDeselected', ()=>{ - throw {name: 'NotYetImplemented'}; + $scope.$on('selectedOrDeselected', function(e, value) { + let item = value.value; + + if (item.isSelected) { + $scope.selectedItems.push(item.id); + } + else { + $scope.selectedItems = _.remove($scope.selectedItems, { id: item.id }); + } }); } @@ -42,7 +49,7 @@ function($scope, $rootScope, ProcessErrors, GetBasePath, var url, listToClose, payloads = $scope.selectedItems.map(function(val) { - return {id: val.id}; + return {id: val}; }); url = $scope.$parent.orgRelatedUrls[$scope.addUsersType]; @@ -69,5 +76,11 @@ function($scope, $rootScope, ProcessErrors, GetBasePath, }); }); }; + + $scope.linkoutUser = function(userId) { + // Open the edit user form in a new tab so as not to navigate the user + // away from the modal + $window.open('/#/users/' + userId,'_blank'); + }; }); }]; diff --git a/awx/ui/client/src/organizations/linkout/controllers/organizations-admins.controller.js b/awx/ui/client/src/organizations/linkout/controllers/organizations-admins.controller.js index dc8c5b0c12..df3075305e 100644 --- a/awx/ui/client/src/organizations/linkout/controllers/organizations-admins.controller.js +++ b/awx/ui/client/src/organizations/linkout/controllers/organizations-admins.controller.js @@ -37,7 +37,7 @@ export default ['$stateParams', '$scope', 'UserList', 'Rest', '$state', } $scope.addUsers = function() { - $compile("")($scope); + $compile("")($scope); }; $scope.editUser = function(id) { diff --git a/awx/ui/client/src/organizations/linkout/controllers/organizations-users.controller.js b/awx/ui/client/src/organizations/linkout/controllers/organizations-users.controller.js index 8baede4f2e..2f3e0f7872 100644 --- a/awx/ui/client/src/organizations/linkout/controllers/organizations-users.controller.js +++ b/awx/ui/client/src/organizations/linkout/controllers/organizations-users.controller.js @@ -37,7 +37,7 @@ export default ['$stateParams', '$scope', 'OrgUserList', 'AddUserList','Rest', ' } $scope.addUsers = function() { - $compile("")($scope); + $compile("")($scope); }; $scope.editUser = function(id) { diff --git a/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js b/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js index 3f65c144ab..d8efd0c813 100644 --- a/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js +++ b/awx/ui/client/src/organizations/linkout/organizations-linkout.route.js @@ -99,6 +99,7 @@ export default [{ list.iterator = 'add_user'; list.name = 'add_users'; list.multiSelect = true; + list.fields.username.ngClick = 'linkoutUser(add_user.id)'; delete list.actions; delete list.fieldActions; return list; @@ -386,6 +387,7 @@ export default [{ } }; list.searchSize = "col-lg-12 col-md-12 col-sm-12 col-xs-12"; + list.listTitle = 'Admins'; return list; }], AddAdminList: ['UserList', function(UserList) { @@ -394,6 +396,7 @@ export default [{ list.iterator = 'add_user'; list.name = 'add_users'; list.multiSelect = true; + list.fields.username.ngClick = 'linkoutUser(add_user.id)'; delete list.actions; delete list.fieldActions; return list;