From 205963a7cef1abfe9fee3acd0d5463799776e25e Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Tue, 21 Jun 2016 12:30:02 -0700 Subject: [PATCH] Adding labels for notifications on related tabs for notification type column --- .../shared/notification-list-init.factory.js | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/awx/ui/client/src/notifications/shared/notification-list-init.factory.js b/awx/ui/client/src/notifications/shared/notification-list-init.factory.js index 2de46870c0..fa072c701c 100644 --- a/awx/ui/client/src/notifications/shared/notification-list-init.factory.js +++ b/awx/ui/client/src/notifications/shared/notification-list-init.factory.js @@ -14,8 +14,8 @@ * */ -export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', - function(Wait, GetBasePath, ProcessErrors, Rest) { +export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', 'GetChoices', + function(Wait, GetBasePath, ProcessErrors, Rest, GetChoices) { return function(params) { var scope = params.scope, url = params.url, @@ -27,6 +27,14 @@ export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', scope.relatednotificationsRemove = scope.$on('relatednotifications', function () { var columns = ['/notification_templates_success/', '/notification_templates_error/']; + GetChoices({ + scope: scope, + url: GetBasePath('notifications'), + field: 'notification_type', + variable: 'notification_type_options', + callback: 'choicesReadyNotifierList' + }); + _.map(columns, function(column){ var notifier_url = url + id + column; Rest.setUrl(notifier_url); @@ -52,6 +60,21 @@ export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest', }); }); + if (scope.removeChoicesHere) { + scope.removeChoicesHere(); + } + scope.removeChoicesHere = scope.$on('choicesReadyNotifierList', function () { + if (scope.notifications) { + scope.notifications.forEach(function(notification, i) { + scope.notification_type_options.forEach(function(type) { + if (type.value === notification.notification_type) { + scope.notifications[i].notification_type = type.label; + } + }); + }); + } + }); + }); }; }];