diff --git a/awx/ui/client/src/search/getSearchHtml.service.js b/awx/ui/client/src/search/getSearchHtml.service.js
index 2e941ce381..82484abfc9 100644
--- a/awx/ui/client/src/search/getSearchHtml.service.js
+++ b/awx/ui/client/src/search/getSearchHtml.service.js
@@ -1,13 +1,15 @@
-export default [function() {
+export default ['GetBasePath', function(GetBasePath) {
// given the list, return the fields that need searching
this.getList = function(list) {
+ var f = _.clone(list.fields);
return JSON.stringify(Object
- .keys(list.fields)
+ .keys(f)
.filter(function(i) {
- return (list.fields[i]
+ return (f[i]
.searchable !== false);
}).map(function(i) {
- return {[i]: list.fields[i]};
+ delete f[i].awToolTip;
+ return {[i]: f[i]};
}).reduce(function (acc, i) {
var key = Object.keys(i);
acc[key] = i[key];
@@ -17,14 +19,19 @@ export default [function() {
// given the list config object, return the basepath
this.getEndpoint = function(list) {
- return list.basePath || list.name;
+ var endPoint = (list.basePath || list.name);
+ if (endPoint === 'inventories') {
+ endPoint = 'inventory';
+ }
+ return GetBasePath(endPoint);
};
// inject the directive with the list and endpoint
- this.inject = function(list, endpoint) {
+ this.inject = function(list, endpoint, set, iterator) {
return "
";
+ "' set='" + set +
+ "' iterator='" + iterator + "'>";
};
return this;
diff --git a/awx/ui/client/src/search/tagSearch.controller.js b/awx/ui/client/src/search/tagSearch.controller.js
index a265873a5e..8edcfdce12 100644
--- a/awx/ui/client/src/search/tagSearch.controller.js
+++ b/awx/ui/client/src/search/tagSearch.controller.js
@@ -3,13 +3,6 @@ export default ['$scope', 'Refresh', 'tagSearchService',
// JSONify passed field elements that can be searched
$scope.list = JSON.parse($scope.list);
- // Hotfix: GetBasePath to work with inventories
- $scope.$watch("endpoint", function(val) {
- if (val === 'inventories') {
- $scope.endpoint = 'inventory';
- }
- });
-
// Grab options for the left-dropdown of the searchbar
tagSearchService.getSearchTypes($scope.list, $scope.endpoint)
.then(function(searchTypes) {
@@ -39,10 +32,10 @@ export default ['$scope', 'Refresh', 'tagSearchService',
};
$scope.updateSearch = function(tags) {
- var iterator = $scope.$parent.list.iterator;
+ var iterator = $scope.iterator;
var pageSize = $scope
.$parent[iterator + "_page_size"];
- var set = $scope.$parent.list.name;
+ var set = $scope.set;
var listScope = $scope.$parent;
var url = tagSearchService
.updateFilteredUrl($scope.endpoint, tags, pageSize);
diff --git a/awx/ui/client/src/search/tagSearch.directive.js b/awx/ui/client/src/search/tagSearch.directive.js
index d1515ea03c..1f5e562b30 100644
--- a/awx/ui/client/src/search/tagSearch.directive.js
+++ b/awx/ui/client/src/search/tagSearch.directive.js
@@ -9,6 +9,7 @@ export default
scope: {
list: '@',
endpoint: '@',
+ set: '@',
iterator: '@'
},
controller: tagSearchController,
diff --git a/awx/ui/client/src/search/tagSearch.service.js b/awx/ui/client/src/search/tagSearch.service.js
index 347e2df0f0..93348d89c3 100644
--- a/awx/ui/client/src/search/tagSearch.service.js
+++ b/awx/ui/client/src/search/tagSearch.service.js
@@ -78,7 +78,7 @@ export default ['Rest', '$q', 'GetBasePath', function(Rest, $q, GetBasePath) {
if (needsRequest.length) {
// make the options request to reutrn the typeOptions
- Rest.setUrl(GetBasePath(basePath));
+ Rest.setUrl(basePath);
Rest.options()
.success(function (data) {
var options = data.actions.GET;
@@ -108,7 +108,7 @@ export default ['Rest', '$q', 'GetBasePath', function(Rest, $q, GetBasePath) {
// returns the url with filter params
this.updateFilteredUrl = function(basePath, tags, pageSize) {
- return GetBasePath(basePath) + "?" +
+ return basePath + "?" +
(tags || []).map(function (t) {
return t.url;
}).join("&") + "&page_size=" + pageSize;
diff --git a/awx/ui/client/src/shared/form-generator.js b/awx/ui/client/src/shared/form-generator.js
index 0f3ea7445a..f5d0d83316 100644
--- a/awx/ui/client/src/shared/form-generator.js
+++ b/awx/ui/client/src/shared/form-generator.js
@@ -142,10 +142,10 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
.factory('GenerateForm', ['$rootScope', '$location', '$compile', 'generateList',
'SearchWidget', 'PaginateWidget', 'Attr', 'Icon', 'Column',
'NavigationLink', 'HelpCollapse', 'DropDown', 'Empty', 'SelectIcon',
- 'Store', 'ActionButton',
+ 'Store', 'ActionButton', 'getSearchHtml', '$state',
function ($rootScope, $location, $compile, GenerateList, SearchWidget,
PaginateWidget, Attr, Icon, Column, NavigationLink, HelpCollapse,
- DropDown, Empty, SelectIcon, Store, ActionButton) {
+ DropDown, Empty, SelectIcon, Store, ActionButton, getSearchHtml, $state) {
return {
setForm: function (form) { this.form = form; },
@@ -1692,28 +1692,38 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
html += "
Hint: " + collection.instructions + "\n";
html += "
\n";
}
+ var rootID = $location.$$path.split("/")[2];
+ var endpoint = "/api/v1/" + collection.basePath
+ .replace(":id", rootID);
+ var tagSearch = getSearchHtml
+ .inject(getSearchHtml.getList(collection),
+ endpoint, itm, collection.iterator);
- //html += "
\n";
- html += "
\n";
+ var actionButtons = "";
+ Object.keys(collection.actions || {})
+ .forEach(act => {
+ actionButtons += ActionButton(collection
+ .actions[act]);
+ });
- html += SearchWidget({
- iterator: collection.iterator,
- template: collection,
- mini: true,
- ngShow: collection.iterator + "Loading == true || " + collection.iterator + "_active_search == true || (" + collection.iterator + "Loading == false && " + collection.iterator + "_active_search == false && " + collection.iterator + "_total_rows > 0)"
- });
-
- html += "
\n";
- html += "
\n";
-
- for (act in collection.actions) {
- action = collection.actions[act];
- html += ActionButton(action);
- }
-
- html += "
\n";
- html += "
\n";
- html += "
\n";
+ html += `
+
+
0
+ )\">
+ ${tagSearch}
+
+
+
+ `;
// Message for when a search returns no results. This should only get shown after a search is executed with no results.
html += "
\n";
diff --git a/awx/ui/client/src/shared/list-generator/list-generator.factory.js b/awx/ui/client/src/shared/list-generator/list-generator.factory.js
index d507fb8782..2c15e72679 100644
--- a/awx/ui/client/src/shared/list-generator/list-generator.factory.js
+++ b/awx/ui/client/src/shared/list-generator/list-generator.factory.js
@@ -362,10 +362,19 @@ export default ['$location', '$compile', '$rootScope', 'SearchWidget', 'Paginate
html += (list.emptyListText) ? list.emptyListText : "PLEASE ADD ITEMS TO THIS LIST";
html += "
";
if (options.showSearch=== undefined || options.showSearch === true) {
- html += getSearchHtml
+ var tagSearch = getSearchHtml
.inject(getSearchHtml.getList(list),
- getSearchHtml.getEndpoint(list));
-
+ getSearchHtml.getEndpoint(list),
+ list.name,
+ list.iterator);
+ html += `
+
+ ${tagSearch}
+
+ `;
// Message for when a search returns no results. This should only get shown after a search is executed with no results.
html += "
\n";
html += "
No records matched your search.
\n";