From 8c55eaec99dde23c9e8ee66f377d47276edf04d5 Mon Sep 17 00:00:00 2001 From: jaredevantabor Date: Wed, 14 Dec 2016 17:38:09 -0800 Subject: [PATCH] post processing for credentials list --- awx/ui/client/src/controllers/Credentials.js | 30 ++++++++++++++++++++ awx/ui/client/src/controllers/Jobs.js | 27 +----------------- awx/ui/client/src/lists/Credentials.js | 1 + 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/awx/ui/client/src/controllers/Credentials.js b/awx/ui/client/src/controllers/Credentials.js index 1681205992..8ccc5afd78 100644 --- a/awx/ui/client/src/controllers/Credentials.js +++ b/awx/ui/client/src/controllers/Credentials.js @@ -36,6 +36,36 @@ export function CredentialsList($scope, $rootScope, $location, $log, $scope.selected = []; } + $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 + debugger; + if (list.fields.kind && $scope.options && + $scope.options.hasOwnProperty('kind')) { + $scope.options.kind.choices.every(function(choice) { + if (choice[0] === item.kind) { + itm.kind_label = choice[1]; + return false; + } + return true; + }); + } + }); + } + $scope.addCredential = function() { $state.go('credentials.add'); }; diff --git a/awx/ui/client/src/controllers/Jobs.js b/awx/ui/client/src/controllers/Jobs.js index 3ea53d3191..cbf588200c 100644 --- a/awx/ui/client/src/controllers/Jobs.js +++ b/awx/ui/client/src/controllers/Jobs.js @@ -28,33 +28,8 @@ export function JobsListController($state, $rootScope, $log, $scope, $compile, $ $scope[list.name] = $scope[`${list.iterator}_dataset`].results; $scope.showJobType = true; - - // _.forEach($scope[list.name], buildTooltips); - // if ($scope.removeChoicesReady) { - // $scope.removeChoicesReady(); - // } - // $scope.removeChoicesReady = $scope.$on('choicesReady', function() { - // $scope[list.name].forEach(function(item, item_idx) { - // var itm = $scope[list.name][item_idx]; - // if(item.summary_fields && item.summary_fields.source_workflow_job && - // item.summary_fields.source_workflow_job.id){ - // item.workflow_result_link = `/#/workflows/${item.summary_fields.source_workflow_job.id}`; - // } - // // Set the item type label - // if (list.fields.type) { - // $scope.type_choices.every(function(choice) { - // if (choice.value === item.type) { - // itm.type_label = choice.label; - // return false; - // } - // return true; - // }); - // } - // }); - // }); - - } + $scope.$on(`${list.iterator}_options`, function(event, data){ $scope.options = data.data.actions.GET; optionsRequestDataProcessing(); diff --git a/awx/ui/client/src/lists/Credentials.js b/awx/ui/client/src/lists/Credentials.js index d099f2826e..c6e8d6bbae 100644 --- a/awx/ui/client/src/lists/Credentials.js +++ b/awx/ui/client/src/lists/Credentials.js @@ -37,6 +37,7 @@ export default }, kind: { label: i18n._('Type'), + ngBind: 'credential.kind_label', excludeModal: true, nosort: true, columnClass: 'col-md-2 hidden-sm hidden-xs'