From c74749c508d867f3967bcbc550bd6e5096e0c070 Mon Sep 17 00:00:00 2001 From: Leigh Date: Fri, 3 Jun 2016 10:43:01 -0400 Subject: [PATCH] fix organization card pagination & display count, resolves #1576 & #1466 (#2150) --- .../list/organizations-list.controller.js | 108 +++++++++--------- .../list/organizations-list.partial.html | 7 +- .../src/organizations/orgcards.block.less | 16 +++ 3 files changed, 74 insertions(+), 57 deletions(-) diff --git a/awx/ui/client/src/organizations/list/organizations-list.controller.js b/awx/ui/client/src/organizations/list/organizations-list.controller.js index 4d90a227e0..65eb1062e9 100644 --- a/awx/ui/client/src/organizations/list/organizations-list.controller.js +++ b/awx/ui/client/src/organizations/list/organizations-list.controller.js @@ -5,46 +5,22 @@ *************************************************/ export default ['$stateParams', '$scope', '$rootScope', '$location', - '$log', '$compile', 'Rest', 'PaginateWidget', 'PaginateInit', + '$log', '$compile', 'Rest', 'PaginateInit', 'SearchInit', 'OrganizationList', 'Alert', 'Prompt', 'ClearScope', 'ProcessErrors', 'GetBasePath', 'Wait', - '$state', + '$state', 'generateList', function($stateParams, $scope, $rootScope, $location, - $log, $compile, Rest, PaginateWidget, PaginateInit, + $log, $compile, Rest, PaginateInit, SearchInit, OrganizationList, Alert, Prompt, ClearScope, ProcessErrors, GetBasePath, Wait, - $state) { + $state, generateList) { ClearScope(); var defaultUrl = GetBasePath('organizations'), list = OrganizationList, - pageSize = $scope.orgCount; - - PaginateInit({ - scope: $scope, - list: list, - url: defaultUrl, - pageSize: pageSize, - }); - SearchInit({ - scope: $scope, - list: list, - url: defaultUrl, - }); - - $scope.list = list; - - $scope.search(list.iterator); - - $scope.PaginateWidget = PaginateWidget({ - iterator: list.iterator, - set: 'organizations' - }); - - var paginationContainer = $('#pagination-container'); - paginationContainer.html($scope.PaginateWidget); - $compile(paginationContainer.contents())($scope); + pageSize = 24, + view = generateList; var parseCardData = function(cards) { return cards.map(function(card) { @@ -96,23 +72,6 @@ export default ['$stateParams', '$scope', '$rootScope', '$location', }); }; - var getOrganization = function(id) { - Rest.setUrl(defaultUrl); - Rest.get() - .success(function(data) { - data.results.activeCard = id; - $scope.orgCount = data.count; - $scope.orgCards = parseCardData(data.results); - Wait("stop"); - }) - .error(function(data, status) { - ProcessErrors($scope, data, status, null, { - hdr: 'Error!', - msg: 'Call to ' + defaultUrl + ' failed. DELETE returned status: ' + status - }); - }); - }; - $scope.$on("ReloadOrgListView", function() { if ($state.$current.self.name === "organizations") { delete $scope.activeCard; @@ -125,15 +84,11 @@ export default ['$stateParams', '$scope', '$rootScope', '$location', } }); - $scope.$on("ReloadOrganzationCards", function(e, id) { - $scope.activeCard = id; - getOrganization(id); + + $scope.$watchCollection('organizations', function(value){ + $scope.orgCards = parseCardData(value); }); - getOrganization(); - - $rootScope.flashMessage = null; - if ($scope.removePostRefresh) { $scope.removePostRefresh(); } @@ -183,5 +138,50 @@ export default ['$stateParams', '$scope', '$rootScope', '$location', actionText: 'DELETE' }); }; + var init = function(){ + // Pagination depends on html appended by list generator + view.inject(list, { + id: 'organizations-list', + scope: $scope, + mode: 'edit' + }); + // grab the pagination elements, move, destroy list generator elements + $('#organization-pagination').appendTo('#OrgCards'); + $('tag-search').appendTo('.OrgCards-search'); + $('#organizations-list').remove(); + + PaginateInit({ + scope: $scope, + list: list, + url: defaultUrl, + pageSize: pageSize, + }); + SearchInit({ + scope: $scope, + list: list, + url: defaultUrl, + set: 'organizations' + }); + + $scope.list = list; + $rootScope.flashMessage = null; + + $scope.search(list.iterator); + var getOrgCount = function() { + Rest.setUrl(defaultUrl); + Rest.get() + .success(function(data) { + $scope.orgCount = data.count; + }) + .error(function(data, status) { + ProcessErrors($scope, data, status, null, { + hdr: 'Error!', + msg: 'Call to ' + defaultUrl + ' failed. DELETE returned status: ' + status + }); + }); + }; + getOrgCount(); + }; + init(); } ]; diff --git a/awx/ui/client/src/organizations/list/organizations-list.partial.html b/awx/ui/client/src/organizations/list/organizations-list.partial.html index abcbf34906..91a17430ef 100644 --- a/awx/ui/client/src/organizations/list/organizations-list.partial.html +++ b/awx/ui/client/src/organizations/list/organizations-list.partial.html @@ -18,7 +18,9 @@ -
+ +
@@ -57,7 +59,6 @@
-
-
+
diff --git a/awx/ui/client/src/organizations/orgcards.block.less b/awx/ui/client/src/organizations/orgcards.block.less index 1ad3524e49..03dbe13bfa 100644 --- a/awx/ui/client/src/organizations/orgcards.block.less +++ b/awx/ui/client/src/organizations/orgcards.block.less @@ -4,6 +4,22 @@ .OrgCards { display: flex; flex-wrap: wrap; + width: 100%; +} + +.OrgCards-search tag-search{ + margin-top: 10px; + width: 100%; + height: 35px; +} +.OrgCards-search .TagSearch{ + min-height: 35px; + height: 35px; + margin-top: 10px; + margin-bottom: 0px; +} +.OrgCards .List-pagination{ + width: 100%; } .OrgCards-card {