From 9e3b5abc37623711aab6bad99f1bd73cd3cb7f2e Mon Sep 17 00:00:00 2001 From: jaredevantabor Date: Wed, 14 Dec 2016 17:05:15 -0800 Subject: [PATCH] fixing post-processing for projects list --- awx/ui/client/src/controllers/Projects.js | 38 +++++++++++++++++-- awx/ui/client/src/lists/Projects.js | 1 + .../list/templates-list.controller.js | 1 - 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/awx/ui/client/src/controllers/Projects.js b/awx/ui/client/src/controllers/Projects.js index 17076a2a73..1eb8fbb2df 100644 --- a/awx/ui/client/src/controllers/Projects.js +++ b/awx/ui/client/src/controllers/Projects.js @@ -37,11 +37,43 @@ export function ProjectsList($scope, $rootScope, $location, $log, $stateParams, _.forEach($scope[list.name], buildTooltips); $rootScope.flashMessage = null; } - - $scope.$watch(`${list.name}`, function() { - _.forEach($scope[list.name], buildTooltips); + + $scope.$on(`${list.iterator}_options`, function(event, data){ + $scope.options = data.data.actions.GET; + optionsRequestDataProcessing(); }); + $scope.$watchCollection(`${$scope.list.name}`, function() { + optionsRequestDataProcessing(); + } + ); + + // iterate over the list and add fields like type label, after the + // OPTIONS request returns, or the list is sorted/paginated/searched + function optionsRequestDataProcessing(){ + $scope[list.name].forEach(function(item, item_idx) { + var itm = $scope[list.name][item_idx]; + + // Set the item type label + if (list.fields.scm_type && $scope.options && + $scope.options.hasOwnProperty('scm_type')) { + $scope.options.scm_type.choices.every(function(choice) { + if (choice[0] === item.scm_type) { + itm.type_label = choice[1]; + return false; + } + return true; + }); + } + + _.forEach($scope[list.name], buildTooltips); + + }); + } + // $scope.$watch(`${list.name}`, function() { + // _.forEach($scope[list.name], buildTooltips); + // }); + function buildTooltips(project) { project.statusIcon = GetProjectIcon(project.status); project.statusTip = GetProjectToolTip(project.status); diff --git a/awx/ui/client/src/lists/Projects.js b/awx/ui/client/src/lists/Projects.js index 83cb2eb7e7..5115b0d662 100644 --- a/awx/ui/client/src/lists/Projects.js +++ b/awx/ui/client/src/lists/Projects.js @@ -46,6 +46,7 @@ export default }, scm_type: { label: i18n._('Type'), + ngBind: 'project.type_label', excludeModal: true, columnClass: 'col-lg-3 col-md-2 col-sm-3 hidden-xs' }, diff --git a/awx/ui/client/src/templates/list/templates-list.controller.js b/awx/ui/client/src/templates/list/templates-list.controller.js index 51b353a51a..5bcd659a38 100644 --- a/awx/ui/client/src/templates/list/templates-list.controller.js +++ b/awx/ui/client/src/templates/list/templates-list.controller.js @@ -43,7 +43,6 @@ export default ['$scope', '$rootScope', '$location', '$stateParams', 'Rest', } $scope.$on(`${list.iterator}_options`, function(event, data){ - debugger; $scope.options = data.data.actions.GET; optionsRequestDataProcessing(); });