1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

fixed user and team edit/add indicator and auto-pagination

This commit is contained in:
John Mitchell 2016-01-25 12:01:32 -05:00
parent 3985e248bf
commit 18fffdcf18
3 changed files with 43 additions and 7 deletions

View File

@ -14,7 +14,7 @@
export function TeamsList($scope, $rootScope, $location, $log, $stateParams,
Rest, Alert, TeamList, GenerateList, Prompt, SearchInit, PaginateInit,
ReturnToCaller, ClearScope, ProcessErrors, SetTeamListeners, GetBasePath,
SelectionInit, Wait, Stream, $state) {
SelectionInit, Wait, Stream, $state, Refresh) {
ClearScope();
@ -25,7 +25,22 @@ export function TeamsList($scope, $rootScope, $location, $log, $stateParams,
mode = (paths[0] === 'teams') ? 'edit' : 'select',
url;
generator.inject(list, { mode: mode, scope: $scope });
var injectForm = function() {
generator.inject(list, { mode: mode, scope: $scope });
};
injectForm();
$scope.$on("RefreshTeamsList", function() {
injectForm();
Refresh({
scope: $scope,
set: 'teams',
iterator: 'team',
url: GetBasePath('teams') + "?order_by=name&page_size=" + $scope.team_page_size
});
});
$scope.selected = [];
url = GetBasePath('base') + $location.path() + '/';
@ -111,7 +126,7 @@ TeamsList.$inject = ['$scope', '$rootScope', '$location', '$log',
'$stateParams', 'Rest', 'Alert', 'TeamList', 'generateList', 'Prompt',
'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope',
'ProcessErrors', 'SetTeamListeners', 'GetBasePath', 'SelectionInit', 'Wait',
'Stream', '$state'
'Stream', '$state', 'Refresh'
];
@ -154,6 +169,7 @@ export function TeamsAdd($scope, $rootScope, $compile, $location, $log,
.success(function (data) {
Wait('stop');
$rootScope.flashMessage = "New team successfully created!";
$rootScope.$broadcast("EditIndicatorChange", "users", data.id);
$location.path('/teams/' + data.id);
})
.error(function (data, status) {
@ -195,6 +211,8 @@ export function TeamsEdit($scope, $rootScope, $compile, $location, $log,
$scope.permission_label = {};
$scope.permission_search_select = [];
$scope.$emit("RefreshTeamsList");
// return a promise from the options request with the permission type choices (including adhoc) as a param
var permissionsChoice = fieldChoices({
scope: $scope,

View File

@ -14,7 +14,7 @@
export function UsersList($scope, $rootScope, $location, $log, $stateParams,
Rest, Alert, UserList, GenerateList, Prompt, SearchInit, PaginateInit,
ReturnToCaller, ClearScope, ProcessErrors, GetBasePath, SelectionInit,
Wait, Stream, $state) {
Wait, Stream, $state, Refresh) {
ClearScope();
@ -26,7 +26,21 @@ export function UsersList($scope, $rootScope, $location, $log, $stateParams,
url = (base === 'organizations') ? GetBasePath('organizations') + $stateParams.organization_id + '/users/' :
GetBasePath('teams') + $stateParams.team_id + '/users/';
generator.inject(UserList, { mode: mode, scope: $scope });
var injectForm = function() {
generator.inject(UserList, { mode: mode, scope: $scope });
};
injectForm();
$scope.$on("RefreshUsersList", function() {
injectForm();
Refresh({
scope: $scope,
set: 'users',
iterator: 'user',
url: GetBasePath('users') + "?order_by=username&page_size=" + $scope.user_page_size
});
});
$scope.selected = [];
@ -101,7 +115,8 @@ export function UsersList($scope, $rootScope, $location, $log, $stateParams,
UsersList.$inject = ['$scope', '$rootScope', '$location', '$log',
'$stateParams', 'Rest', 'Alert', 'UserList', 'generateList', 'Prompt',
'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope',
'ProcessErrors', 'GetBasePath', 'SelectionInit', 'Wait', 'Stream', '$state'
'ProcessErrors', 'GetBasePath', 'SelectionInit', 'Wait', 'Stream', '$state',
'Refresh'
];
@ -173,6 +188,7 @@ export function UsersAdd($scope, $rootScope, $compile, $location, $log,
var base = $location.path().replace(/^\//, '').split('/')[0];
if (base === 'users') {
$rootScope.flashMessage = 'New user successfully created!';
$rootScope.$broadcast("EditIndicatorChange", "users", data.id);
$location.path('/users/' + data.id);
}
else {
@ -226,6 +242,8 @@ export function UsersEdit($scope, $rootScope, $compile, $location, $log,
$scope.permission_label = {};
$scope.permission_search_select = [];
$scope.$emit("RefreshUsersList");
// return a promise from the options request with the permission type choices (including adhoc) as a param
var permissionsChoice = fieldChoices({
scope: $scope,

View File

@ -25,7 +25,7 @@ export default ['$http', function($http) {
// divide by the page size to get what
// page the data should be on
var count = data.data.count;
return Math.ceil(count/pageSize);
return Math.ceil(count/parseInt(pageSize));
});
});
}