diff --git a/awx/ui/client/src/job-templates/edit/job-templates-edit.controller.js b/awx/ui/client/src/job-templates/edit/job-templates-edit.controller.js index dc02f439b8..f5ea8c7a41 100644 --- a/awx/ui/client/src/job-templates/edit/job-templates-edit.controller.js +++ b/awx/ui/client/src/job-templates/edit/job-templates-edit.controller.js @@ -448,31 +448,40 @@ export default } }); }; + if($state.params.id !== "null"){ + Rest.setUrl(defaultUrl + $state.params.id + + "/labels"); + Rest.get() + .success(function(data) { + if (data.next) { + getNext(data, data.results, seeMoreResolve); + } else { + seeMoreResolve.resolve(data.results); + } - Rest.setUrl(defaultUrl + $state.params.id + - "/labels"); - Rest.get() - .success(function(data) { - if (data.next) { - getNext(data, data.results, seeMoreResolve); - } else { - seeMoreResolve.resolve(data.results); - } - - seeMoreResolve.promise.then(function (labels) { - $scope.$emit("choicesReady"); - var opts = labels - .map(i => ({id: i.id + "", - test: i.name})); - CreateSelect2({ - element:'#job_templates_labels', - multiple: true, - addNew: true, - opts: opts + seeMoreResolve.promise.then(function (labels) { + $scope.$emit("choicesReady"); + var opts = labels + .map(i => ({id: i.id + "", + test: i.name})); + CreateSelect2({ + element:'#job_templates_labels', + multiple: true, + addNew: true, + opts: opts + }); + Wait("stop"); }); - Wait("stop"); + }).error(function(){ + // job template id is null in this case + $scope.$emit("choicesReady"); }); - }); + } + else { + // job template doesn't exist + $scope.$emit("choicesReady"); + } + }) .error(function (data, status) { ProcessErrors($scope, data, status, form, { diff --git a/awx/ui/client/src/search/tagSearch.controller.js b/awx/ui/client/src/search/tagSearch.controller.js index 2a1b8e3311..e50a25670e 100644 --- a/awx/ui/client/src/search/tagSearch.controller.js +++ b/awx/ui/client/src/search/tagSearch.controller.js @@ -1,17 +1,19 @@ -export default ['$scope', 'Refresh', 'tagSearchService', - function($scope, Refresh, tagSearchService) { +export default ['$scope', 'Refresh', 'tagSearchService', '$stateParams', + function($scope, Refresh, tagSearchService, $stateParams) { // JSONify passed field elements that can be searched $scope.list = angular.fromJson($scope.list); // Access config lines from list spec $scope.listConfig = $scope.$parent.list; // Grab options for the left-dropdown of the searchbar - tagSearchService.getSearchTypes($scope.list, $scope.endpoint) - .then(function(searchTypes) { - $scope.searchTypes = searchTypes; + if($stateParams.id !== "null"){ + tagSearchService.getSearchTypes($scope.list, $scope.endpoint) + .then(function(searchTypes) { + $scope.searchTypes = searchTypes; - // currently selected option of the left-dropdown - $scope.currentSearchType = $scope.searchTypes[0]; - }); + // currently selected option of the left-dropdown + $scope.currentSearchType = $scope.searchTypes[0]; + }); + } // shows/hide the search type dropdown $scope.toggleTypeDropdown = function() { diff --git a/awx/ui/client/src/search/tagSearch.service.js b/awx/ui/client/src/search/tagSearch.service.js index b340b5d8c3..fdd808d3ad 100644 --- a/awx/ui/client/src/search/tagSearch.service.js +++ b/awx/ui/client/src/search/tagSearch.service.js @@ -84,41 +84,45 @@ export default ['Rest', '$q', 'GetBasePath', 'Wait', 'ProcessErrors', '$log', fu if (needsRequest.length) { // make the options request to reutrn the typeOptions - Rest.setUrl(needsRequest[0].basePath ? GetBasePath(needsRequest[0].basePath) : basePath); - Rest.options() - .success(function (data) { - try { - var options = data.actions.GET; - needsRequest = needsRequest - .map(function (option) { - option.typeOptions = options[option - .value] - .choices - .map(function(i) { - return { - value: i[0], - label: i[1] - }; - }); - 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); + var url = needsRequest[0].basePath ? GetBasePath(needsRequest[0].basePath) : basePath; + if(url.indexOf('null') === 0 ){ + Rest.setUrl(url); + Rest.options() + .success(function (data) { + try { + var options = data.actions.GET; + needsRequest = needsRequest + .map(function (option) { + option.typeOptions = options[option + .value] + .choices + .map(function(i) { + return { + value: i[0], + label: i[1] + }; + }); + return option; + }); } - else { $log.error(err); } - } - Wait("stop"); - defer.resolve(joinOptions()); - }) - .error(function (data, status) { - Wait("stop"); - defer.reject("options request failed"); - ProcessErrors(null, data, status, null, { - hdr: 'Error!', - msg: 'Getting type options failed'}); - }); + 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()); + }) + .error(function (data, status) { + Wait("stop"); + defer.reject("options request failed"); + ProcessErrors(null, data, status, null, { + hdr: 'Error!', + msg: 'Getting type options failed'}); + }); + } + } else { Wait("stop"); defer.resolve(joinOptions());