From d76ef1419ee4eb1203ef38de8d49aa8510da5b9e Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Mon, 28 Nov 2016 13:44:01 -0500 Subject: [PATCH] Added GetChoices to the templates list to properly display the template type --- awx/ui/client/src/lists/Templates.js | 3 +- .../list/templates-list.controller.js | 32 +++++++++++++++++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/awx/ui/client/src/lists/Templates.js b/awx/ui/client/src/lists/Templates.js index 7979c46f8e..6a9aea0658 100644 --- a/awx/ui/client/src/lists/Templates.js +++ b/awx/ui/client/src/lists/Templates.js @@ -30,8 +30,7 @@ export default }, type: { label: i18n._('Type'), - searchType: 'select', - searchOptions: [], // will be set by Options call to job templates resource + ngBind: 'template.type_label', columnClass: 'col-lg-2 col-md-2 col-sm-4 hidden-xs' }, description: { 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 7c81887c40..1cdb4d83eb 100644 --- a/awx/ui/client/src/templates/list/templates-list.controller.js +++ b/awx/ui/client/src/templates/list/templates-list.controller.js @@ -7,12 +7,12 @@ export default ['$scope', '$rootScope', '$location', '$stateParams', 'Rest', 'Alert', 'TemplateList', 'Prompt', 'ClearScope', 'ProcessErrors', 'GetBasePath', 'InitiatePlaybookRun', 'Wait', '$state', '$filter', 'Dataset', 'rbacUiControlService', 'TemplatesService', - 'QuerySet', + 'QuerySet', 'GetChoices', function( $scope, $rootScope, $location, $stateParams, Rest, Alert, TemplateList, Prompt, ClearScope, ProcessErrors, GetBasePath, InitiatePlaybookRun, Wait, $state, $filter, Dataset, rbacUiControlService, TemplatesService, - qs + qs, GetChoices ) { ClearScope(); @@ -38,6 +38,34 @@ export default ['$scope', '$rootScope', '$location', '$stateParams', 'Rest', 'Al $scope[list.name] = $scope[`${list.iterator}_dataset`].results; $rootScope.flashMessage = null; + + 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]; + + // 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; + }); + } + }); + }); + + GetChoices({ + scope: $scope, + url: GetBasePath('unified_job_templates'), + field: 'type', + variable: 'type_choices', + callback: 'choicesReady' + }); } $scope.$on(`ws-jobs`, function () {