diff --git a/src/app/addmembers/add.html b/src/app/addmembers/add.html
index cf7091a..dca2213 100644
--- a/src/app/addmembers/add.html
+++ b/src/app/addmembers/add.html
@@ -10,7 +10,7 @@
-
+
diff --git a/src/app/billing_accounts/billingaccounts.list.html b/src/app/billing_accounts/billingaccounts.list.html
index 1411f45..3e4c97d 100644
--- a/src/app/billing_accounts/billingaccounts.list.html
+++ b/src/app/billing_accounts/billingaccounts.list.html
@@ -64,7 +64,7 @@
-
diff --git a/src/app/clients/clients.list.html b/src/app/clients/clients.list.html
index f668f79..d918bb9 100644
--- a/src/app/clients/clients.list.html
+++ b/src/app/clients/clients.list.html
@@ -59,7 +59,7 @@
-
diff --git a/src/app/groupmembers/groupmembers.list.controller.js b/src/app/groupmembers/groupmembers.list.controller.js
index a67379a..e916d33 100644
--- a/src/app/groupmembers/groupmembers.list.controller.js
+++ b/src/app/groupmembers/groupmembers.list.controller.js
@@ -3,14 +3,17 @@
var module = angular.module('supportAdminApp');
module.controller('permissionmanagement.GroupMembersListController', [
- '$scope', '$rootScope', 'GroupMemberService', 'IdResolverService', '$stateParams', '$state', '$q', 'Alert',
- function ($scope, $rootScope, GroupMemberService, IdResolverService, $stateParams, $state, $q, $alert) {
+ '$scope', '$rootScope', 'GroupMemberService', 'IdResolverService', 'UserService', 'GroupService', '$stateParams', '$state', '$q', 'Alert', '$timeout', 'moment', '$animate',
+ function ($scope, $rootScope, GroupMemberService, IdResolverService, UserService, GroupService, $stateParams, $state, $q, $alert, $timeout, moment, $animate) {
// keep member types for easy iterating
$scope.memberTypes = ['group', 'user'];
// true if list is loading
- $scope.isLoading = false;
+ $scope.isLoading = {};
+ $scope.memberTypes.forEach(function(memberType) {
+ $scope.isLoading[memberType] = false;
+ });
// true if something is we are removing a bulk of entries
$scope.processing = false;
@@ -41,6 +44,27 @@ module.controller('permissionmanagement.GroupMembersListController', [
$scope.groups = {};
var loadGroup = IdResolverService.getGroupResolverFunction($scope.groups);
+ // all memberships to implement client side filters
+ var allMemberships = {};
+ $scope.memberTypes.forEach(function(memberType) {
+ allMemberships[memberType] = [];
+ });
+
+ // filter criteria
+ $scope.filterCriteria = {};
+ $scope.memberTypes.forEach(function(memberType) {
+ $scope.filterCriteria[memberType] = {
+ memberId: '',
+ memberName: '',
+ createdBy: '',
+ modifiedBy: '',
+ createdAtFrom: '',
+ createdAtTo: '',
+ modifiedAtFrom: '',
+ modifiedAtTo: ''
+ };
+ });
+
/**
* Return membership records which are selected in the table by checkboxes
*
@@ -61,11 +85,14 @@ module.controller('permissionmanagement.GroupMembersListController', [
*/
$scope.fetch = function(groupId) {
$alert.clear();
- $scope.isLoading = true;
+ $scope.memberTypes.forEach(function(memberType) {
+ $scope.isLoading[memberType] = true;
+ });
GroupMemberService.fetch(groupId).then(function(data) {
$scope.memberTypes.forEach(function(memberType) {
$scope.memberships[memberType] = data.content.filter(function(membership) { return membership.membershipType === memberType });
+ allMemberships[memberType] = _.clone($scope.memberships[memberType]);
$scope.memberships[memberType].forEach(function(membership) {
loadUser(membership.createdBy);
loadUser(membership.modifiedBy);
@@ -78,11 +105,24 @@ module.controller('permissionmanagement.GroupMembersListController', [
loadGroup(membership.memberId);
}
});
+
+ // if have some members we will init footable plugin
+ if ($scope.memberships[memberType].length) {
+ // make sure changes to scope are applied
+ // and redraw footable table with current member list
+ $timeout(function() {
+ $('.footable.table-type-' + memberType).footable();
+ $scope.isLoading[memberType] = false;
+ });
+ } else {
+ $scope.isLoading[memberType] = false;
+ }
});
}).catch(function (error) {
$alert.error(error.error, $rootScope);
- }).finally(function() {
- $scope.isLoading = false;
+ $scope.memberTypes.forEach(function(memberType) {
+ $scope.isLoading[memberType] = false;
+ });
});
};
@@ -116,6 +156,9 @@ module.controller('permissionmanagement.GroupMembersListController', [
$scope.memberships[membership.membershipType] = $scope.memberships[membership.membershipType].filter(function(record) {
return record.id !== membership.id;
});
+ allMemberships[membership.membershipType] = allMemberships[membership.membershipType].filter(function(record) {
+ return record.id !== membership.id;
+ });
}).catch(function(error) {
membership.isRemoving = false;
$alert.error('Cannot remove member with id `' + membership.memberId + '`. ' + error.error, $rootScope);
@@ -144,10 +187,323 @@ module.controller('permissionmanagement.GroupMembersListController', [
});
}
+ /**
+ * Open datetimepicker
+ *
+ * @param {Object} e event object
+ * @param {String} inputName name of the input
+ * @param {String} memberType member type
+ */
+ $scope.openCalendar = function (e, inputName, memberType) {
+ if (!$scope[inputName + 'Open']) {
+ $scope[inputName + 'Open'] = {};
+ }
+
+ if ($scope[inputName + 'Open'][memberType]) {
+ return;
+ }
+
+ $scope[inputName + 'Open'][memberType] = true;
+
+ if (e && e.preventDefault) {
+ e.preventDefault();
+ }
+
+ if (e && e.stopPropagation) {
+ e.stopPropagation();
+ }
+ };
+
+ /**
+ * Helper function which redraws table with new member list
+ * and properly takes care about updating footable plugin
+ *
+ * The essential problem this function is solving is that after we
+ * update $scope.members, rows from the table are not being deleted immediately
+ * because we are using animations for rows.
+ * That's why if we try to force update footable plugin it still find old rows which are in
+ * process of animation and still in DOM tree.
+ * As a workaround in this function we disable animations for rows before updating them,
+ * thus footable plugin can see changes immediately after scope is updated.
+ *
+ * @param {String} memberType type of membership we are redrawing
+ * @param {Array} memberships new array of memberships which has to displayed
+ *
+ * @return {Promise} resolved after table was completely updated
+ */
+ function redrawTableWithMemberships(memberType, memberships) {
+ var $footable = $('.footable.table-type-' + memberType);
+
+ // disable animations for rows, so old rows will be removed immediately
+ // from the DOM tree and footable can see changes
+ $footable.find('tr').each(function(index, el) {
+ $animate.enabled(el, false);
+ });
+
+ // update memberships list in scope
+ $scope.memberships[memberType] = memberships;
+
+ // make sure that changes are applied to the scope
+ return $timeout(function() {
+ // force footable plugin to redraw
+ $footable.trigger('footable_redraw');
+ // enable animation for table rows again
+ $footable.find('tr').each(function(index, el) {
+ $animate.enabled(el, true);
+ });
+ });
+ }
+
+ // promise to get list of groups
+ // this list is used to resolve groups ids by its group names
+ var groupIdsByNamePromise = null;
+
+ /**
+ * Find group id by its name
+ *
+ * This is helper function which return value in special shape
+ * along with group ids array it return label defined by 'valueType'
+ *
+ * This function just retrieves all the groups and after resolves names by
+ * searching in group list client side.
+ *
+ * @param {String} groupName group name
+ * @param {String} valueType label of the returned value
+ * @return {Promise} resolved to object {value: