diff --git a/src/app/organization/organizationCollectionsGroupsController.js b/src/app/organization/organizationCollectionsGroupsController.js deleted file mode 100644 index 170dd2f349..0000000000 --- a/src/app/organization/organizationCollectionsGroupsController.js +++ /dev/null @@ -1,11 +0,0 @@ -angular - .module('bit.organization') - - .controller('organizationCollectionsGroupsController', function ($scope, $state, $uibModalInstance, collection, $analytics) { - $analytics.eventTrack('organizationCollectionsGroupsController', { category: 'Modal' }); - $scope.collection = collection; - - $scope.close = function () { - $uibModalInstance.dismiss('cancel'); - }; - }); diff --git a/src/app/organization/organizationGroupsController.js b/src/app/organization/organizationGroupsController.js index 8573058cca..f8a54229d0 100644 --- a/src/app/organization/organizationGroupsController.js +++ b/src/app/organization/organizationGroupsController.js @@ -44,7 +44,19 @@ }; $scope.users = function (group) { - + var modal = $uibModal.open({ + animation: true, + templateUrl: 'app/organization/views/organizationGroupsUsers.html', + controller: 'organizationGroupsUsersController', + size: 'lg', + resolve: { + group: function () { return group; } + } + }); + + modal.result.then(function () { + // nothing to do + }); }; $scope.delete = function (group) { diff --git a/src/app/organization/organizationGroupsUsersController.js b/src/app/organization/organizationGroupsUsersController.js new file mode 100644 index 0000000000..f9ba86ca01 --- /dev/null +++ b/src/app/organization/organizationGroupsUsersController.js @@ -0,0 +1,56 @@ +angular + .module('bit.organization') + + .controller('organizationGroupsUsersController', function ($scope, $state, $uibModalInstance, apiService, + $analytics, group, toastr) { + $analytics.eventTrack('organizationGroupUsersController', { category: 'Modal' }); + $scope.loading = true; + $scope.group = group; + $scope.users = []; + + $uibModalInstance.opened.then(function () { + return apiService.groups.listUsers({ + orgId: $state.params.orgId, + id: group.id + }).$promise; + }).then(function (userList) { + var users = []; + if (userList && userList.Data.length) { + for (var i = 0; i < userList.Data.length; i++) { + users.push({ + organizationUserId: userList.Data[i].OrganizationUserId, + name: userList.Data[i].Name, + email: userList.Data[i].Email, + type: userList.Data[i].Type, + status: userList.Data[i].Status, + accessAll: userList.Data[i].AccessAll + }); + } + } + + $scope.users = users; + $scope.loading = false; + }); + + $scope.remove = function (user) { + if (!confirm('Are you sure you want to remove this user (' + user.email + ') from this ' + + 'group (' + group.name + ')?')) { + return; + } + + //apiService.collectionUsers.del({ orgId: $state.params.orgId, id: user.id }, null, function () { + // toastr.success(user.email + ' has been removed.', 'User Removed'); + // $analytics.eventTrack('Removed User From Collection'); + // var index = $scope.users.indexOf(user); + // if (index > -1) { + // $scope.users.splice(index, 1); + // } + //}, function () { + // toastr.error('Unable to remove user.', 'Error'); + //}); + }; + + $scope.close = function () { + $uibModalInstance.dismiss('cancel'); + }; + }); diff --git a/src/app/organization/organizationPeopleController.js b/src/app/organization/organizationPeopleController.js index 4a5bea7e7a..6a80a1cd0d 100644 --- a/src/app/organization/organizationPeopleController.js +++ b/src/app/organization/organizationPeopleController.js @@ -86,6 +86,21 @@ }); }; + $scope.groups = function (user) { + var modal = $uibModal.open({ + animation: true, + templateUrl: 'app/organization/views/organizationPeopleGroups.html', + controller: 'organizationPeopleGroupsController', + resolve: { + orgUser: function () { return user; } + } + }); + + modal.result.then(function () { + + }); + }; + function loadList() { apiService.organizationUsers.list({ orgId: $state.params.orgId }, function (list) { var users = []; diff --git a/src/app/organization/organizationPeopleGroupsController.js b/src/app/organization/organizationPeopleGroupsController.js new file mode 100644 index 0000000000..07cba512b0 --- /dev/null +++ b/src/app/organization/organizationPeopleGroupsController.js @@ -0,0 +1,87 @@ +angular + .module('bit.organization') + + .controller('organizationPeopleGroupsController', function ($scope, $state, $uibModalInstance, apiService, + orgUser, $analytics) { + $analytics.eventTrack('organizationPeopleGroupsController', { category: 'Modal' }); + + $scope.loading = true; + $scope.groups = []; + $scope.selectedGroups = {}; + $scope.orgUser = orgUser; + + $uibModalInstance.opened.then(function () { + return apiService.groups.listOrganization({ orgId: $state.params.orgId }).$promise; + }).then(function (groupsList) { + var groups = []; + for (var i = 0; i < groupsList.Data.length; i++) { + groups.push({ + id: groupsList.Data[i].Id, + name: groupsList.Data[i].Name + }); + } + $scope.groups = groups; + + return apiService.organizationUsers.listGroups({ orgId: $state.params.orgId, id: orgUser.id }).$promise; + }).then(function (groupIds) { + var selectedGroups = {}; + if (groupIds) { + for (var i = 0; i < groupIds.length; i++) { + selectedGroups[groupIds[i]] = true; + } + } + $scope.selectedGroups = selectedGroups; + $scope.loading = false; + }, function (error) { + + }); + + $scope.toggleGroupSelectionAll = function ($event) { + var groups = {}; + if ($event.target.checked) { + for (var i = 0; i < $scope.groups.length; i++) { + groups[$scope.groups[i].id] = true; + } + } + + $scope.selectedGroups = groups; + }; + + $scope.toggleGroupSelection = function (id) { + if (id in $scope.selectedGroups) { + delete $scope.selectedGroups[id]; + } + else { + $scope.selectedGroups[id] = true; + } + }; + + $scope.groupSelected = function (group) { + return group.id in $scope.selectedGroups; + }; + + $scope.allSelected = function () { + return Object.keys($scope.selectedGroups).length === $scope.groups.length; + }; + + $scope.submitPromise = null; + $scope.submit = function (model) { + var groups = []; + for (var groupId in $scope.selectedGroups) { + if ($scope.selectedGroups.hasOwnProperty(groupId)) { + groups.push(groupId); + } + } + + $scope.submitPromise = apiService.organizationUsers.putGroups({ orgId: $state.params.orgId, id: orgUser.id }, { + groupIds: groups, + }, function () { + $analytics.eventTrack('Edited User Groups'); + $uibModalInstance.close(); + }).$promise; + }; + + $scope.close = function () { + $uibModalInstance.dismiss('cancel'); + }; + }); diff --git a/src/app/organization/views/organizationCollections.html b/src/app/organization/views/organizationCollections.html index 7957d3bf1b..9e785aeb1b 100644 --- a/src/app/organization/views/organizationCollections.html +++ b/src/app/organization/views/organizationCollections.html @@ -48,11 +48,6 @@ Users -
+ No users for this group. You can associate a new user to this group by + selecting a specific user's "Groups" on the "People" page. +
+
+
+
+
+
+ |
+
+ |
+
+ {{user.email}}
+ {{user.name}}
+ |
+ + {{user.type | enumName: 'OrgUserType'}} + | ++ + {{user.status | enumName: 'OrgUserStatus'}} + + | +