From dd0340f909cd0842c57963c6af56fdae40e26db6 Mon Sep 17 00:00:00 2001 From: Leigh Johnson Date: Wed, 20 Apr 2016 16:28:38 -0400 Subject: [PATCH 1/2] allows us to set OPTIONS request endpoints per list field, adds additional logging to catch list configs with missing basePath param. Resolves #1626 remove debug line --- .../src/notifications/notifications.list.js | 4 ++-- awx/ui/client/src/search/tagSearch.service.js | 20 +++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/awx/ui/client/src/notifications/notifications.list.js b/awx/ui/client/src/notifications/notifications.list.js index cb249fd73b..b2943d8efc 100644 --- a/awx/ui/client/src/notifications/notifications.list.js +++ b/awx/ui/client/src/notifications/notifications.list.js @@ -11,13 +11,13 @@ export default function(){ iterator: 'notification', index: false, hover: false, - + basePath: 'notifications', fields: { name: { key: true, label: 'Name', columnClass: 'col-md-3 col-sm-9 col-xs-9', - linkTo: '/#/notifications/{{notifier.id}}' + linkTo: '/#/notifications/{{notifier.id}}', }, notification_type: { label: 'Type', diff --git a/awx/ui/client/src/search/tagSearch.service.js b/awx/ui/client/src/search/tagSearch.service.js index 6a4f2d0dc4..0e7f5974f3 100644 --- a/awx/ui/client/src/search/tagSearch.service.js +++ b/awx/ui/client/src/search/tagSearch.service.js @@ -1,4 +1,4 @@ -export default ['Rest', '$q', 'GetBasePath', 'Wait', 'ProcessErrors', function(Rest, $q, GetBasePath, Wait, ProcessErrors) { +export default ['Rest', '$q', 'GetBasePath', 'Wait', 'ProcessErrors', '$log', function(Rest, $q, GetBasePath, Wait, ProcessErrors, $log) { var that = this; // parse the field config object to return // one of the searchTypes (for the left dropdown) @@ -79,11 +79,12 @@ export default ['Rest', '$q', 'GetBasePath', 'Wait', 'ProcessErrors', function(R if (needsRequest.length) { // make the options request to reutrn the typeOptions - Rest.setUrl(basePath); + Rest.setUrl(needsRequest[0].basePath ? needsRequest[0].basePath : basePath); Rest.options() .success(function (data) { - var options = data.actions.GET; - needsRequest = needsRequest + try { + var options = data.actions.GET; + needsRequest = needsRequest .map(function (option) { option.typeOptions = options[option .value] @@ -94,8 +95,15 @@ export default ['Rest', '$q', 'GetBasePath', 'Wait', 'ProcessErrors', function(R label: i[1] }; }); - return option; - }); + return option; + }); + } + catch(err){ + if (basePath === ''){ + $log.error('Cannot retrieve OPTIONS because the basePath parameter is not set on the list with the following fieldset: \n', list); + } + else { $log.error(err); } + } Wait("stop"); defer.resolve(joinOptions()); }) From 08f97822908f711866d7ebcdeea9b26dd515f3b3 Mon Sep 17 00:00:00 2001 From: Leigh Johnson Date: Thu, 21 Apr 2016 10:15:10 -0400 Subject: [PATCH 2/2] catch undefined basePath config #1626 --- awx/ui/client/src/search/tagSearch.service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui/client/src/search/tagSearch.service.js b/awx/ui/client/src/search/tagSearch.service.js index 0e7f5974f3..7b53d28c8c 100644 --- a/awx/ui/client/src/search/tagSearch.service.js +++ b/awx/ui/client/src/search/tagSearch.service.js @@ -99,7 +99,7 @@ export default ['Rest', '$q', 'GetBasePath', 'Wait', 'ProcessErrors', '$log', fu }); } catch(err){ - if (basePath === ''){ + if (!basePath){ $log.error('Cannot retrieve OPTIONS because the basePath parameter is not set on the list with the following fieldset: \n', list); } else { $log.error(err); }