mirror of
https://github.com/ansible/awx.git
synced 2026-05-14 04:47:44 -02:30
Search.js now supports up to 3 search filters on a page. First search widget can be regular or an object selector, which is used on the activity stream widget. Activity stream now has 2 filter widgets allowing a search to combine object and responsible user in a single query.
This commit is contained in:
@@ -196,11 +196,10 @@ function HomeHosts ($location, $routeParams, HomeHostList, GenerateList, Process
|
|||||||
|
|
||||||
// Process search params
|
// Process search params
|
||||||
if ($routeParams['name']) {
|
if ($routeParams['name']) {
|
||||||
scope[list.iterator + 'InputDisable'] = false;
|
scope[HomeHostList.iterator + 'InputDisable'] = false;
|
||||||
scope[list.iterator + 'SearchValue'] = $routeParams['name'];
|
scope[HomeHostListiterator + 'SearchValue'] = $routeParams['name'];
|
||||||
scope[list.iterator + 'SearchField'] = 'name';
|
scope[HomeHostList.iterator + 'SearchField'] = 'name';
|
||||||
scope[list.iterator + 'SearchFieldLabel'] = list.fields['name'].label;
|
scope[lHomeHostList.iterator + 'SearchFieldLabel'] = list.fields['name'].label;
|
||||||
scope[list.iterator + 'SearchSelectValue'] = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($routeParams['has_active_failures']) {
|
if ($routeParams['has_active_failures']) {
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ angular.module('ActivityDetailDefinition', [])
|
|||||||
type: 'text',
|
type: 'text',
|
||||||
readonly: true
|
readonly: true
|
||||||
},
|
},
|
||||||
|
id: {
|
||||||
|
label: 'Event ID',
|
||||||
|
type: 'text',
|
||||||
|
readonly: true
|
||||||
|
},
|
||||||
operation: {
|
operation: {
|
||||||
label: 'Operation',
|
label: 'Operation',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
|
|||||||
@@ -33,11 +33,16 @@ angular.module('RefreshHelper', ['RestServices', 'Utilities'])
|
|||||||
scope[iterator + 'PageCount'] = Math.ceil((data.count / scope[iterator + 'PageSize']));
|
scope[iterator + 'PageCount'] = Math.ceil((data.count / scope[iterator + 'PageSize']));
|
||||||
scope[iterator + 'SearchSpin'] = false;
|
scope[iterator + 'SearchSpin'] = false;
|
||||||
scope[iterator + 'Loading'] = false;
|
scope[iterator + 'Loading'] = false;
|
||||||
|
for (var i=1; i <= 3; i++) {
|
||||||
|
var modifier = (i == 1) ? '' : i;
|
||||||
|
scope[iterator + 'HoldInput' + modifier] = false;
|
||||||
|
}
|
||||||
scope[set] = data['results'];
|
scope[set] = data['results'];
|
||||||
scope.$emit('PostRefresh');
|
scope.$emit('PostRefresh');
|
||||||
})
|
})
|
||||||
.error ( function(data, status, headers, config) {
|
.error ( function(data, status, headers, config) {
|
||||||
scope[iterator + 'SearchSpin'] = false;
|
scope[iterator + 'SearchSpin'] = false;
|
||||||
|
scope[iterator + 'HoldInput'] = false;
|
||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null,
|
||||||
{ hdr: 'Error!', msg: 'Failed to retrieve ' + set + '. GET returned status: ' + status });
|
{ hdr: 'Error!', msg: 'Failed to retrieve ' + set + '. GET returned status: ' + status });
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -16,7 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
||||||
.factory('SearchInit', ['Alert', 'Rest', 'Refresh', '$location', function(Alert, Rest, Refresh, $location) {
|
.factory('SearchInit', ['Alert', 'Rest', 'Refresh', '$location', 'GetBasePath', 'Empty', '$timeout',
|
||||||
|
function(Alert, Rest, Refresh, $location, GetBasePath, Empty, $timeout) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
|
|
||||||
var scope = params.scope;
|
var scope = params.scope;
|
||||||
@@ -25,227 +26,355 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
|||||||
var list = params.list;
|
var list = params.list;
|
||||||
var iterator = (params.iterator) ? params.iterator : list.iterator;
|
var iterator = (params.iterator) ? params.iterator : list.iterator;
|
||||||
var sort_order;
|
var sort_order;
|
||||||
|
|
||||||
|
if (scope.searchTimer) {
|
||||||
|
$timeout.cancel(scope.searchTimer);
|
||||||
|
}
|
||||||
|
|
||||||
function setDefaults() {
|
function setDefaults(widget) {
|
||||||
// Set default values
|
// Set default values
|
||||||
|
var modifier = (widget == undefined || widget == 1) ? '' : widget;
|
||||||
|
scope[iterator + 'SearchField' + modifier] = '';
|
||||||
|
scope[iterator + 'SearchFieldLabel' + modifier] = '';
|
||||||
for (fld in list.fields) {
|
for (fld in list.fields) {
|
||||||
if (list.fields[fld].key) {
|
if (list.fields[fld].searchWidget == undefined && widget == 1 ||
|
||||||
if (list.fields[fld].sourceModel) {
|
list.fields[fld].searchWidget == widget) {
|
||||||
var fka = list.fields[fld].sourceModel + '__' + list.fields[fld].sourceField;
|
if (list.fields[fld].key) {
|
||||||
sort_order = (list.fields[fld].desc) ? '-' + fka : fka;
|
if (list.fields[fld].sourceModel) {
|
||||||
}
|
var fka = list.fields[fld].sourceModel + '__' + list.fields[fld].sourceField;
|
||||||
else {
|
sort_order = (list.fields[fld].desc) ? '-' + fka : fka;
|
||||||
sort_order = (list.fields[fld].desc) ? '-' + fld : fld;
|
}
|
||||||
}
|
else {
|
||||||
if (list.fields[fld].searchable == undefined || list.fields[fld].searchable == true) {
|
sort_order = (list.fields[fld].desc) ? '-' + fld : fld;
|
||||||
scope[iterator + 'SearchField'] = fld;
|
}
|
||||||
scope[iterator + 'SearchFieldLabel'] = list.fields[fld].label;
|
if (list.fields[fld].searchable == undefined || list.fields[fld].searchable == true) {
|
||||||
}
|
scope[iterator + 'SearchField' + modifier] = fld;
|
||||||
break;
|
scope[iterator + 'SearchFieldLabel' + modifier] = list.fields[fld].label;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!scope[iterator + 'SearchField']) {
|
if (Empty(scope[iterator + 'SearchField' + modifier])) {
|
||||||
// A field marked as key may not be 'searchable'
|
// A field marked as key may not be 'searchable'. Find the first searchable field.
|
||||||
for (fld in list.fields) {
|
for (fld in list.fields) {
|
||||||
if (list.fields[fld].searchable == undefined || list.fields[fld].searchable == true) {
|
if (list.fields[fld].searchWidget == undefined && widget == 1 ||
|
||||||
scope[iterator + 'SearchField'] = fld;
|
list.fields[fld].searchWidget == widget) {
|
||||||
scope[iterator + 'SearchFieldLabel'] = list.fields[fld].label;
|
if (list.fields[fld].searchable == undefined || list.fields[fld].searchable == true) {
|
||||||
break;
|
scope[iterator + 'SearchField' + modifier] = fld;
|
||||||
|
scope[iterator + 'SearchFieldLabel' + modifier] = list.fields[fld].label;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scope[iterator + 'SearchType'] = 'icontains';
|
scope[iterator + 'SearchType' + modifier] = 'icontains';
|
||||||
scope[iterator + 'SearchTypeLabel'] = 'Contains';
|
scope[iterator + 'SearchTypeLabel' + modifier] = 'Contains';
|
||||||
scope[iterator + 'SearchParams'] = '';
|
scope[iterator + 'SearchParams' + modifier] = '';
|
||||||
scope[iterator + 'SearchValue'] = '';
|
scope[iterator + 'SearchValue' + modifier] = '';
|
||||||
scope[iterator + 'SelectShow'] = false; // show/hide the Select
|
scope[iterator + 'SelectShow' + modifier] = false; // show/hide the Select
|
||||||
scope[iterator + 'HideSearchType'] = false;
|
scope[iterator + 'HideSearchType' + modifier] = false;
|
||||||
scope[iterator + 'InputDisable'] = false;
|
scope[iterator + 'InputDisable' + modifier] = false;
|
||||||
scope[iterator + 'ExtraParms'] = '';
|
scope[iterator + 'ExtraParms' + modifier] = '';
|
||||||
|
|
||||||
|
scope[iterator + 'SearchPlaceholder' + modifier] =
|
||||||
|
(list.fields[scope[iterator + 'SearchField' + modifier]] &&
|
||||||
|
list.fields[scope[iterator + 'SearchField' + modifier]].searchPlaceholder) ?
|
||||||
|
list.fields[scope[iterator + 'SearchField' + modifier]].searchPlaceholder : 'Search';
|
||||||
|
|
||||||
|
scope[iterator + 'InputDisable' + modifier] =
|
||||||
|
(list.fields[scope[iterator + 'SearchField' + modifier]] &&
|
||||||
|
list.fields[scope[iterator + 'SearchField' + modifier]].searchObject == 'all') ? true : false;
|
||||||
|
|
||||||
var f = scope[iterator + 'SearchField']
|
var f = scope[iterator + 'SearchField' + modifier];
|
||||||
if (list.fields[f].searchType && ( list.fields[f].searchType == 'boolean'
|
if (list.fields[f]) {
|
||||||
|| list.fields[f].searchType == 'select')) {
|
if ( list.fields[f].searchType && (list.fields[f].searchType == 'boolean'
|
||||||
scope[iterator + 'SelectShow'] = true;
|
|| list.fields[f].searchType == 'select') ) {
|
||||||
scope[iterator + 'SearchSelectOpts'] = list.fields[f].searchOptions;
|
scope[iterator + 'SelectShow' + modifier] = true;
|
||||||
}
|
scope[iterator + 'SearchSelectOpts' + modifier] = list.fields[f].searchOptions;
|
||||||
if (list.fields[f].searchType && list.fields[f].searchType == 'int') {
|
}
|
||||||
scope[iterator + 'HideSearchType'] = true;
|
if (list.fields[f].searchType && list.fields[f].searchType == 'int') {
|
||||||
}
|
scope[iterator + 'HideSearchType' + modifier] = true;
|
||||||
if (list.fields[f].searchType && list.fields[f].searchType == 'gtzero') {
|
}
|
||||||
scope[iterator + "InputHide"] = true;
|
if (list.fields[f].searchType && list.fields[f].searchType == 'gtzero') {
|
||||||
|
scope[iterator + 'InputHide' + modifier] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setDefaults();
|
for (var i=1; i <= 3; i++) {
|
||||||
|
var modifier = (i == 1) ? '' : i;
|
||||||
|
if ( $('#search-widget-container' + modifier) ) {
|
||||||
|
setDefaults(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Functions to handle search widget changes
|
// Functions to handle search widget changes
|
||||||
scope.setSearchField = function(iterator, fld, label) {
|
scope.setSearchField = function(iterator, fld, label, widget) {
|
||||||
scope[iterator + 'SearchFieldLabel'] = label;
|
|
||||||
scope[iterator + 'SearchField'] = fld;
|
var modifier = (widget == undefined || widget == 1) ? '' : widget;
|
||||||
scope[iterator + 'SearchValue'] = '';
|
scope[iterator + 'SearchFieldLabel' + modifier] = label;
|
||||||
scope[iterator + 'SelectShow'] = false;
|
scope[iterator + 'SearchField' + modifier] = fld;
|
||||||
scope[iterator + 'HideSearchType'] = false;
|
scope[iterator + 'SearchValue' + modifier] = '';
|
||||||
scope[iterator + 'InputHide'] = false;
|
scope[iterator + 'SelectShow' + modifier] = false;
|
||||||
scope[iterator + 'InputDisable'] = false;
|
scope[iterator + 'HideSearchType' + modifier] = false;
|
||||||
scope[iterator + 'SearchType'] = 'icontains';
|
scope[iterator + 'InputHide' + modifier] = false;
|
||||||
|
scope[iterator + 'SearchType' + modifier] = 'icontains';
|
||||||
|
scope[iterator + 'SearchPlaceholder' + modifier] = (list.fields[fld].searchPlaceholder) ? list.fields[fld].searchPlaceholder : 'Search';
|
||||||
|
scope[iterator + 'InputDisable' + modifier] = (list.fields[fld].searchObject == 'all') ? true : false;
|
||||||
|
|
||||||
if (list.fields[fld].searchType && list.fields[fld].searchType == 'gtzero') {
|
if (list.fields[fld].searchType && list.fields[fld].searchType == 'gtzero') {
|
||||||
scope[iterator + "InputDisable"] = true;
|
scope[iterator + "InputDisable" + modifier] = true;
|
||||||
}
|
}
|
||||||
else if (list.fields[fld].searchSingleValue){
|
else if (list.fields[fld].searchSingleValue){
|
||||||
// Query a specific attribute for one specific value
|
// Query a specific attribute for one specific value
|
||||||
// searchSingleValue: true
|
// searchSingleValue: true
|
||||||
// searchType: 'boolean|int|etc.'
|
// searchType: 'boolean|int|etc.'
|
||||||
// searchValue: < value to match for boolean use 'true'|'false' >
|
// searchValue: < value to match for boolean use 'true'|'false' >
|
||||||
scope[iterator + 'InputDisable'] = true;
|
scope[iterator + 'InputDisable' + modifier] = true;
|
||||||
scope[iterator + "SearchValue"] = list.fields[fld].searchValue;
|
scope[iterator + "SearchValue" + modifier] = list.fields[fld].searchValue;
|
||||||
// For boolean type, SearchValue must be an object
|
// For boolean type, SearchValue must be an object
|
||||||
if (list.fields[fld].searchType == 'boolean' && list.fields[fld].searchValue == 'true') {
|
if (list.fields[fld].searchType == 'boolean' && list.fields[fld].searchValue == 'true') {
|
||||||
scope[iterator + "SearchSelectValue"] = { value: 1 };
|
scope[iterator + "SearchSelectValue" + modifier] = { value: 1 };
|
||||||
}
|
}
|
||||||
else if (list.fields[fld].searchType == 'boolean' && list.fields[fld].searchValue == 'false') {
|
else if (list.fields[fld].searchType == 'boolean' && list.fields[fld].searchValue == 'false') {
|
||||||
scope[iterator + "SearchSelectValue"] = { value: 0 };
|
scope[iterator + "SearchSelectValue" + modifier] = { value: 0 };
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
scope[iterator + "SearchSelectValue"] = { value: list.fields[fld].searchValue };
|
scope[iterator + "SearchSelectValue" + modifier] = { value: list.fields[fld].searchValue };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (list.fields[fld].searchType == 'in') {
|
else if (list.fields[fld].searchType == 'in') {
|
||||||
scope[iterator + "SearchType"] = 'in';
|
scope[iterator + "SearchType" + modifier] = 'in';
|
||||||
scope[iterator + "SearchValue"] = list.fields[fld].searchValue;
|
scope[iterator + "SearchValue" + modifier] = list.fields[fld].searchValue;
|
||||||
scope[iterator + "InputDisable"] = true;
|
scope[iterator + "InputDisable" + modifier] = true;
|
||||||
}
|
}
|
||||||
else if (list.fields[fld].searchType && (list.fields[fld].searchType == 'boolean'
|
else if (list.fields[fld].searchType && (list.fields[fld].searchType == 'boolean'
|
||||||
|| list.fields[fld].searchType == 'select')) {
|
|| list.fields[fld].searchType == 'select' || list.fields[fld].searchType == 'select_or')) {
|
||||||
scope[iterator + 'SelectShow'] = true;
|
scope[iterator + 'SelectShow' + modifier] = true;
|
||||||
scope[iterator + 'SearchSelectOpts'] = list.fields[fld].searchOptions;
|
scope[iterator + 'SearchSelectOpts' + modifier] = list.fields[fld].searchOptions;
|
||||||
}
|
}
|
||||||
else if (list.fields[fld].searchType && list.fields[fld].searchType == 'int') {
|
else if (list.fields[fld].searchType && list.fields[fld].searchType == 'int') {
|
||||||
scope[iterator + 'HideSearchType'] = true;
|
scope[iterator + 'HideSearchType' + modifier] = true;
|
||||||
}
|
}
|
||||||
else if (list.fields[fld].searchType && list.fields[fld].searchType == 'isnull') {
|
else if (list.fields[fld].searchType && list.fields[fld].searchType == 'isnull') {
|
||||||
scope[iterator + 'SearchType'] = 'isnull';
|
scope[iterator + 'SearchType' + modifier] = 'isnull';
|
||||||
scope[iterator + 'InputDisable'] = true;
|
scope[iterator + 'InputDisable' + modifier] = true;
|
||||||
scope[iterator + 'SearchValue'] = 'true';
|
scope[iterator + 'SearchValue' + modifier] = 'true';
|
||||||
}
|
}
|
||||||
scope.search(iterator);
|
scope.search(iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.resetSearch = function(iterator) {
|
scope.resetSearch = function(iterator, widget) {
|
||||||
// Respdond to click of reset button
|
// Respdond to click of reset button
|
||||||
setDefaults();
|
setDefaults(widget);
|
||||||
// Force removal of search keys from the URL
|
// Force removal of search keys from the URL
|
||||||
window.location = '/#' + $location.path();
|
window.location = '/#' + $location.path();
|
||||||
|
scope.search(iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.setSearchType = function(iterator, type, label) {
|
//scope.setSearchType = function(iterator, type, label) {
|
||||||
scope[iterator + 'SearchTypeLabel'] = label;
|
// scope[iterator + 'SearchTypeLabel'] = label;
|
||||||
scope[iterator + 'SearchType'] = type;
|
// scope[iterator + 'SearchType'] = type;
|
||||||
scope.search(iterator);
|
// scope.search(iterator);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
if (scope.removeDoSearch) {
|
||||||
|
scope.removeDoSearch();
|
||||||
|
}
|
||||||
|
scope.removeDoSearch = scope.$on('doSearch', function(e, iterator, page, load, spin) {
|
||||||
|
//
|
||||||
|
// Execute the search
|
||||||
|
//
|
||||||
|
scope[iterator + 'SearchSpin'] = (spin == undefined || spin == true) ? true : false;
|
||||||
|
scope[iterator + 'Loading'] = (load == undefined || load == true) ? true : false;
|
||||||
|
var url = defaultUrl;
|
||||||
|
|
||||||
|
//finalize and execute the query
|
||||||
|
scope[iterator + 'Page'] = (page) ? parseInt(page) - 1 : 0;
|
||||||
|
if (/\/$/.test(url)) {
|
||||||
|
url += '?' + scope[iterator + 'SearchParams'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
url += '&' + scope[iterator + 'SearchParams'];
|
||||||
|
}
|
||||||
|
url = url.replace(/\&\&/,'&');
|
||||||
|
url += (scope[iterator + 'PageSize']) ? '&page_size=' + scope[iterator + 'PageSize'] : "";
|
||||||
|
if (page) {
|
||||||
|
url += '&page=' + page;
|
||||||
|
}
|
||||||
|
if (scope[iterator + 'ExtraParms']) {
|
||||||
|
url += scope[iterator + 'ExtraParms'];
|
||||||
|
}
|
||||||
|
Refresh({ scope: scope, set: set, iterator: iterator, url: url });
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (scope.removePrepareSearch) {
|
||||||
|
scope.removePrepareSearch();
|
||||||
|
}
|
||||||
|
scope.removePrepareSearch = scope.$on('prepareSearch', function(e, iterator, page, load, spin) {
|
||||||
|
//
|
||||||
|
// Start build the search key/value pairs. This will process the first search widget, if the
|
||||||
|
// selected field is an object type (used on activity stream).
|
||||||
|
//
|
||||||
|
scope[iterator + 'HoldInput'] = true;
|
||||||
|
scope[iterator + 'SearchParams'] = '';
|
||||||
|
if (list.fields[scope[iterator + 'SearchField']].searchObject &&
|
||||||
|
list.fields[scope[iterator + 'SearchField']].searchObject !== 'all') {
|
||||||
|
//This is specifically for activity stream. We need to identify which type of object is being searched
|
||||||
|
//and then provide a list of PK values corresponding to the list of objects the user is interested in.
|
||||||
|
var objs = list.fields[scope[iterator + 'SearchField']].searchObject;
|
||||||
|
var o = (objs == 'inventories') ? 'inventory' : objs.replace(/s$/,'');
|
||||||
|
scope[iterator + 'SearchParams'] = 'or__object1=' + o + '&or__object2=' + o;
|
||||||
|
if (scope[iterator + 'SearchValue']) {
|
||||||
|
var objUrl = GetBasePath('base') + objs + '/?name__icontains=' + scope[iterator + 'SearchValue'];
|
||||||
|
Rest.setUrl(objUrl);
|
||||||
|
Rest.get()
|
||||||
|
.success( function(data, status, headers, config) {
|
||||||
|
var list='';
|
||||||
|
for (var i=0; i < data.results.length; i++) {
|
||||||
|
list += "," + data.results[i].id;
|
||||||
|
}
|
||||||
|
list = list.replace(/^\,/,'');
|
||||||
|
if (!Empty(list)) {
|
||||||
|
scope[iterator + 'SearchParams'] += '&or__object1_id__in=' + list + '&or__object2_id__in=' + list;
|
||||||
|
}
|
||||||
|
//scope[iterator + 'SearchParams'] += (sort_order) ? '&order_by=' + escape(sort_order) : "";
|
||||||
|
scope.$emit('prepareSearch2', iterator, page, load, spin, 2);
|
||||||
|
})
|
||||||
|
.error( function(data, status, headers, config) {
|
||||||
|
ProcessErrors(scope, data, status, null,
|
||||||
|
{ hdr: 'Error!', msg: 'Retrieving list of ' + obj + ' where name contains: ' + scope[iterator + 'SearchValue'] +
|
||||||
|
' GET returned status: ' + status });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
scope.$emit('prepareSearch2', iterator, page, load, spin, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
scope.$emit('prepareSearch2', iterator, page, load, spin, 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (scope.removePrepareSearch2) {
|
||||||
|
scope.removePrepareSearch2();
|
||||||
|
}
|
||||||
|
scope.removePrepareSearch2 = scope.$on('prepareSearch2', function(e, iterator, page, load, spin, startingWidget) {
|
||||||
|
// Continue building the search by examining the remaining search widgets. If we're looking at activity_stream,
|
||||||
|
// there's more than one.
|
||||||
|
for (var i=startingWidget; i <= 3; i++) {
|
||||||
|
var modifier = (i == 1) ? '' : i;
|
||||||
|
scope[iterator + 'HoldInput' + modifier] = true;
|
||||||
|
if ( $('#search-widget-container' + modifier) ) {
|
||||||
|
// if the search widget exists, add its parameters to the query
|
||||||
|
if ( (!scope[iterator + 'SelectShow' + modifier] && !Empty(scope[iterator + 'SearchValue' + modifier])) ||
|
||||||
|
(scope[iterator + 'SelectShow' + modifier] && scope[iterator + 'SearchSelectValue' + modifier]) ||
|
||||||
|
(list.fields[scope[iterator + 'SearchField' + modifier]] &&
|
||||||
|
list.fields[scope[iterator + 'SearchField' + modifier]].searchType == 'gtzero') ) {
|
||||||
|
if (list.fields[scope[iterator + 'SearchField' + modifier]].searchField) {
|
||||||
|
scope[iterator + 'SearchParams'] = list.fields[scope[iterator + 'SearchField' + modifier]].searchField + '__';
|
||||||
|
}
|
||||||
|
else if (list.fields[scope[iterator + 'SearchField' + modifier]].sourceModel) {
|
||||||
|
// handle fields whose source is a related model e.g. inventories.organization
|
||||||
|
scope[iterator + 'SearchParams'] = list.fields[scope[iterator + 'SearchField' + modifier]].sourceModel + '__' +
|
||||||
|
list.fields[scope[iterator + 'SearchField' + modifier]].sourceField + '__';
|
||||||
|
}
|
||||||
|
else if ( (list.fields[scope[iterator + 'SearchField' + modifier]].searchType == 'select') &&
|
||||||
|
(scope[iterator + 'SearchSelectValue' + modifier].value == '' ||
|
||||||
|
scope[iterator + 'SearchSelectValue' + modifier].value == null) ) {
|
||||||
|
scope[iterator + 'SearchParams'] = scope[iterator + 'SearchField' + modifier];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
scope[iterator + 'SearchParams'] = scope[iterator + 'SearchField' + modifier] + '__';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( list.fields[scope[iterator + 'SearchField' + modifier]].searchType &&
|
||||||
|
(list.fields[scope[iterator + 'SearchField' + modifier]].searchType == 'int' ||
|
||||||
|
list.fields[scope[iterator + 'SearchField' + modifier]].searchType == 'boolean' ) ) {
|
||||||
|
scope[iterator + 'SearchParams'] += 'int=';
|
||||||
|
}
|
||||||
|
else if ( list.fields[scope[iterator + 'SearchField' + modifier]].searchType &&
|
||||||
|
list.fields[scope[iterator + 'SearchField' + modifier]].searchType == 'gtzero' ) {
|
||||||
|
scope[iterator + 'SearchParams'] += 'gt=0';
|
||||||
|
}
|
||||||
|
else if ( (list.fields[scope[iterator + 'SearchField' + modifier]].searchType == 'select') &&
|
||||||
|
(scope[iterator + 'SearchSelectValue' + modifier].value == '' ||
|
||||||
|
scope[iterator + 'SearchSelectValue' + modifier].value == null) ) {
|
||||||
|
scope[iterator + 'SearchParams'] += 'iexact=';
|
||||||
|
}
|
||||||
|
else if ( (list.fields[scope[iterator + 'SearchField' + modifier]].searchType &&
|
||||||
|
(list.fields[scope[iterator + 'SearchField' + modifier]].searchType == 'or')) ) {
|
||||||
|
scope[iterator + 'SearchParams'] = ''; //start over
|
||||||
|
var val = scope[iterator + 'SearchValue' + modifier];
|
||||||
|
for (var k=0; k < list.fields[scope[iterator + 'SearchField' + modifier]].searchFields.length; k++) {
|
||||||
|
scope[iterator + 'SearchParams'] += '&or__' +
|
||||||
|
list.fields[scope[iterator + 'SearchField' + modifier]].searchFields[k] +
|
||||||
|
'__icontains=' + escape(val);
|
||||||
|
}
|
||||||
|
scope[iterator + 'SearchParams'].replace(/^\&/,'');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
scope[iterator + 'SearchParams'] += scope[iterator + 'SearchType' + modifier] + '=';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( list.fields[scope[iterator + 'SearchField' + modifier]].searchType &&
|
||||||
|
(list.fields[scope[iterator + 'SearchField' + modifier]].searchType == 'boolean'
|
||||||
|
|| list.fields[scope[iterator + 'SearchField' + modifier]].searchType == 'select') ) {
|
||||||
|
scope[iterator + 'SearchParams'] += scope[iterator + 'SearchSelectValue' + modifier].value;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( (!list.fields[scope[iterator + 'SearchField' + modifier]].searchType) ||
|
||||||
|
(list.fields[scope[iterator + 'SearchField' + modifier]].searchType &&
|
||||||
|
list.fields[scope[iterator + 'SearchField' + modifier]].searchType !== 'or') ) {
|
||||||
|
scope[iterator + 'SearchParams'] += escape(scope[iterator + 'SearchValue' + modifier]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( (iterator == 'inventory' && scope.inventoryFailureFilter) ||
|
||||||
|
(iterator == 'host' && scope.hostFailureFilter) ) {
|
||||||
|
//Things that bypass the search widget. Should go back and add a second widget possibly on
|
||||||
|
//inventory pages and eliminate this
|
||||||
|
scope[iterator + 'SearchParams'] += '&has_active_failures=true';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sort_order) {
|
||||||
|
scope[iterator + 'SearchParams'] += (scope[iterator + 'SearchParams']) ? '&' : '';
|
||||||
|
scope[iterator + 'SearchParams'] += 'order_by=' + escape(sort_order);
|
||||||
|
}
|
||||||
|
|
||||||
|
scope.$emit('doSearch', iterator, page, load, spin);
|
||||||
|
});
|
||||||
|
|
||||||
|
scope.startSearch = function(iterator) {
|
||||||
|
//Called on each keydown event for seachValue field. Using a timer
|
||||||
|
//to prevent executing a search until user is finished typing.
|
||||||
|
if (scope.searchTimer) {
|
||||||
|
$timeout.cancel(scope.searchTimer);
|
||||||
|
}
|
||||||
|
scope.searchTimer = $timeout(
|
||||||
|
function() {
|
||||||
|
scope.$emit('prepareSearch', iterator);
|
||||||
|
}
|
||||||
|
, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.search = function(iterator, page, load, spin) {
|
scope.search = function(iterator, page, load, spin) {
|
||||||
|
// Called to initiate a searh.
|
||||||
// Page is optional. Added to accomodate back function on Job Events detail.
|
// Page is optional. Added to accomodate back function on Job Events detail.
|
||||||
// Spin optional -set to false if spin not desired.
|
// Spin optional -set to false if spin not desired.
|
||||||
// Load optional -set to false if loading message not desired
|
// Load optional -set to false if loading message not desired
|
||||||
|
scope.$emit('prepareSearch', iterator, page, load, spin);
|
||||||
scope[iterator + 'SearchSpin'] = (spin == undefined || spin == true) ? true : false;
|
|
||||||
scope[iterator + 'Loading'] = (load == undefined || load == true) ? true : false;
|
|
||||||
scope[iterator + 'SearchParms'] = '';
|
|
||||||
var url = defaultUrl;
|
|
||||||
|
|
||||||
if ( (scope[iterator + 'SelectShow'] == false && scope[iterator + 'SearchValue'] != '' && scope[iterator + 'SearchValue'] != undefined) ||
|
|
||||||
(scope[iterator + 'SelectShow'] && scope[iterator + 'SearchSelectValue']) ||
|
|
||||||
(list.fields[scope[iterator + 'SearchField']].searchType && list.fields[scope[iterator + 'SearchField']].searchType == 'gtzero') ) {
|
|
||||||
|
|
||||||
if (list.fields[scope[iterator + 'SearchField']].searchField) {
|
|
||||||
scope[iterator + 'SearchParams'] = list.fields[scope[iterator + 'SearchField']].searchField + '__';
|
|
||||||
}
|
|
||||||
else if (list.fields[scope[iterator + 'SearchField']].sourceModel) {
|
|
||||||
// handle fields whose source is a related model e.g. inventories.organization
|
|
||||||
scope[iterator + 'SearchParams'] = list.fields[scope[iterator + 'SearchField']].sourceModel + '__' +
|
|
||||||
list.fields[scope[iterator + 'SearchField']].sourceField + '__';
|
|
||||||
}
|
|
||||||
else if ( (list.fields[scope[iterator + 'SearchField']].searchType == 'select') &&
|
|
||||||
(scope[iterator + 'SearchSelectValue'].value == '' ||
|
|
||||||
scope[iterator + 'SearchSelectValue'].value == null) ) {
|
|
||||||
scope[iterator + 'SearchParams'] = scope[iterator + 'SearchField'];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
scope[iterator + 'SearchParams'] = scope[iterator + 'SearchField'] + '__';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( list.fields[scope[iterator + 'SearchField']].searchType &&
|
|
||||||
(list.fields[scope[iterator + 'SearchField']].searchType == 'int' ||
|
|
||||||
list.fields[scope[iterator + 'SearchField']].searchType == 'boolean' ) ) {
|
|
||||||
scope[iterator + 'SearchParams'] += 'int=';
|
|
||||||
}
|
|
||||||
else if ( list.fields[scope[iterator + 'SearchField']].searchType &&
|
|
||||||
list.fields[scope[iterator + 'SearchField']].searchType == 'gtzero' ) {
|
|
||||||
scope[iterator + 'SearchParams'] += 'gt=0';
|
|
||||||
}
|
|
||||||
else if ( (list.fields[scope[iterator + 'SearchField']].searchType == 'select') &&
|
|
||||||
(scope[iterator + 'SearchSelectValue'].value == '' ||
|
|
||||||
scope[iterator + 'SearchSelectValue'].value == null) ) {
|
|
||||||
scope[iterator + 'SearchParams'] += 'iexact=';
|
|
||||||
}
|
|
||||||
else if ( (list.fields[scope[iterator + 'SearchField']].searchType &&
|
|
||||||
(list.fields[scope[iterator + 'SearchField']].searchType == 'or')) ) {
|
|
||||||
scope[iterator + 'SearchParams'] = ''; //start over
|
|
||||||
for (var k=0; k < list.fields[scope[iterator + 'SearchField']].searchFields.length; k++) {
|
|
||||||
scope[iterator + 'SearchParams'] += '&or__' +
|
|
||||||
list.fields[scope[iterator + 'SearchField']].searchFields[k] +
|
|
||||||
'__icontains=' + escape(scope[iterator + 'SearchValue']);
|
|
||||||
}
|
|
||||||
scope[iterator + 'SearchParams'].replace(/^\&/,'');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
scope[iterator + 'SearchParams'] += scope[iterator + 'SearchType'] + '=';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( list.fields[scope[iterator + 'SearchField']].searchType &&
|
|
||||||
(list.fields[scope[iterator + 'SearchField']].searchType == 'boolean'
|
|
||||||
|| list.fields[scope[iterator + 'SearchField']].searchType == 'select') ) {
|
|
||||||
scope[iterator + 'SearchParams'] += scope[iterator + 'SearchSelectValue'].value;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if ( (list.fields[scope[iterator + 'SearchField']].searchType &&
|
|
||||||
(list.fields[scope[iterator + 'SearchField']].searchType !== 'or')) ) {
|
|
||||||
scope[iterator + 'SearchParams'] += escape(scope[iterator + 'SearchValue']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
scope[iterator + 'SearchParams'] += (sort_order) ? '&order_by=' + escape(sort_order) : '';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
scope[iterator + 'SearchParams'] = (sort_order) ? 'order_by=' + escape(sort_order) : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( (iterator == 'inventory' && scope.inventoryFailureFilter) ||
|
|
||||||
(iterator == 'host' && scope.hostFailureFilter) ) {
|
|
||||||
scope[iterator + 'SearchParams'] += '&has_active_failures=true';
|
|
||||||
}
|
|
||||||
|
|
||||||
scope[iterator + 'Page'] = (page) ? parseInt(page) - 1 : 0;
|
|
||||||
if (/\/$/.test(url)) {
|
|
||||||
url += '?' + scope[iterator + 'SearchParams'];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
url += '&' + scope[iterator + 'SearchParams'];
|
|
||||||
}
|
|
||||||
url = url.replace(/\&\&/,'&');
|
|
||||||
url += (scope[iterator + 'PageSize']) ? '&page_size=' + scope[iterator + 'PageSize'] : "";
|
|
||||||
if (page) {
|
|
||||||
url += '&page=' + page;
|
|
||||||
}
|
|
||||||
if (scope[iterator + 'ExtraParms']) {
|
|
||||||
url += scope[iterator + 'ExtraParms'];
|
|
||||||
}
|
|
||||||
Refresh({ scope: scope, set: set, iterator: iterator, url: url });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
scope.sort = function(fld) {
|
scope.sort = function(fld) {
|
||||||
// reset sort icons back to 'icon-sort' on all columns
|
// reset sort icons back to 'icon-sort' on all columns
|
||||||
// except the one clicked
|
// except the one clicked
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ angular.module('StreamListDefinition', [])
|
|||||||
index: false,
|
index: false,
|
||||||
hover: true,
|
hover: true,
|
||||||
"class": "table-condensed",
|
"class": "table-condensed",
|
||||||
|
searchWidgetLabel: 'Object',
|
||||||
|
searchWidgetLabel2: 'Modified by',
|
||||||
|
|
||||||
fields: {
|
fields: {
|
||||||
timestamp: {
|
timestamp: {
|
||||||
@@ -32,20 +34,16 @@ angular.module('StreamListDefinition', [])
|
|||||||
sourceModel: 'user',
|
sourceModel: 'user',
|
||||||
sourceField: 'username',
|
sourceField: 'username',
|
||||||
awToolTip: "\{\{ userToolTip \}\}",
|
awToolTip: "\{\{ userToolTip \}\}",
|
||||||
dataPlacement: 'top'
|
dataPlacement: 'top',
|
||||||
|
searchPlaceholder: 'Username',
|
||||||
|
searchWidget: 2
|
||||||
},
|
},
|
||||||
objects: {
|
objects: {
|
||||||
label: 'Objects',
|
label: 'Objects',
|
||||||
ngBindHtml: 'activity.objects',
|
ngBindHtml: 'activity.objects',
|
||||||
sortField: "object1__name,object2__name",
|
nosort: true,
|
||||||
searchable: false
|
searchable: false
|
||||||
},
|
},
|
||||||
object_name: {
|
|
||||||
label: 'Object name',
|
|
||||||
searchOnly: true,
|
|
||||||
searchType: 'or',
|
|
||||||
searchFields: ['object1__name', 'object2__name']
|
|
||||||
},
|
|
||||||
description: {
|
description: {
|
||||||
label: 'Description',
|
label: 'Description',
|
||||||
ngBindHtml: 'activity.description',
|
ngBindHtml: 'activity.description',
|
||||||
@@ -53,11 +51,68 @@ angular.module('StreamListDefinition', [])
|
|||||||
searchable: false
|
searchable: false
|
||||||
},
|
},
|
||||||
system_event: {
|
system_event: {
|
||||||
label: 'System event?',
|
label: 'System',
|
||||||
searchOnly: true,
|
searchOnly: true,
|
||||||
searchType: 'isnull',
|
searchType: 'isnull',
|
||||||
sourceModel: 'user',
|
sourceModel: 'user',
|
||||||
sourceField: 'username'
|
sourceField: 'username',
|
||||||
|
searchWidget: 2
|
||||||
|
},
|
||||||
|
// The following fields exist to forces loading each type of object into the search
|
||||||
|
// dropdown
|
||||||
|
all_objects: {
|
||||||
|
label: 'All',
|
||||||
|
searchOnly: true,
|
||||||
|
searchObject: 'all',
|
||||||
|
searchPlaceholder: ' '
|
||||||
|
},
|
||||||
|
credential_search: {
|
||||||
|
label: 'Credential',
|
||||||
|
searchOnly: true,
|
||||||
|
searchObject: 'credentials',
|
||||||
|
searchPlaceholder: 'Credential name'
|
||||||
|
},
|
||||||
|
group_search: {
|
||||||
|
label: 'Group',
|
||||||
|
searchOnly: true,
|
||||||
|
searchObject: 'groups',
|
||||||
|
searchPlaceholder: 'Group name'
|
||||||
|
},
|
||||||
|
host_search: {
|
||||||
|
label: 'Host',
|
||||||
|
searchOnly: true,
|
||||||
|
searchObject: 'hosts',
|
||||||
|
searchPlaceholder: 'Host name'
|
||||||
|
},
|
||||||
|
inventory_search: {
|
||||||
|
label: 'Inventory',
|
||||||
|
searchOnly: true,
|
||||||
|
searchObject: 'inventories',
|
||||||
|
searchPlaceholder: 'Inventory name'
|
||||||
|
},
|
||||||
|
job_template_search: {
|
||||||
|
label: 'Job Template',
|
||||||
|
searchOnly: true,
|
||||||
|
searchObject: 'job_templates',
|
||||||
|
searchPlaceholder: 'Job template name'
|
||||||
|
},
|
||||||
|
organization_search: {
|
||||||
|
label: 'Organization',
|
||||||
|
searchOnly: true,
|
||||||
|
searchObject: 'organizations',
|
||||||
|
searchPlaceholder: 'Organization name'
|
||||||
|
},
|
||||||
|
project_search: {
|
||||||
|
label: 'Project',
|
||||||
|
searchOnly: true,
|
||||||
|
searchObject: 'projects',
|
||||||
|
searchPlaceholder: 'Project name'
|
||||||
|
},
|
||||||
|
user_search: {
|
||||||
|
label: 'User',
|
||||||
|
searchOnly: true,
|
||||||
|
searchObject: 'users',
|
||||||
|
searchPlaceholder: 'Username'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -174,9 +174,10 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
|||||||
}])
|
}])
|
||||||
|
|
||||||
.factory('Stream', ['$rootScope', '$location', 'Rest', 'GetBasePath', 'ProcessErrors', 'Wait', 'StreamList', 'SearchInit',
|
.factory('Stream', ['$rootScope', '$location', 'Rest', 'GetBasePath', 'ProcessErrors', 'Wait', 'StreamList', 'SearchInit',
|
||||||
'PaginateInit', 'GenerateList', 'FormatDate', 'ShowStream', 'HideStream', 'BuildDescription', 'FixUrl', 'ShowDetail',
|
'PaginateInit', 'GenerateList', 'FormatDate', 'ShowStream', 'HideStream', 'BuildDescription', 'FixUrl', 'BuildUrl',
|
||||||
|
'ShowDetail',
|
||||||
function($rootScope, $location, Rest, GetBasePath, ProcessErrors, Wait, StreamList, SearchInit, PaginateInit, GenerateList,
|
function($rootScope, $location, Rest, GetBasePath, ProcessErrors, Wait, StreamList, SearchInit, PaginateInit, GenerateList,
|
||||||
FormatDate, ShowStream, HideStream, BuildDescription, FixUrl, ShowDetail) {
|
FormatDate, ShowStream, HideStream, BuildDescription, FixUrl, BuildUrl, ShowDetail) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
|
|
||||||
var list = StreamList;
|
var list = StreamList;
|
||||||
@@ -188,7 +189,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
|||||||
var type = (base == 'inventories') ? 'inventory' : base.replace(/s$/,'');
|
var type = (base == 'inventories') ? 'inventory' : base.replace(/s$/,'');
|
||||||
defaultUrl += '?or__object1=' + type + '&or__object2=' + type;
|
defaultUrl += '?or__object1=' + type + '&or__object2=' + type;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push the current page onto browser histor. If user clicks back button, restore current page without
|
// Push the current page onto browser histor. If user clicks back button, restore current page without
|
||||||
// stream widget
|
// stream widget
|
||||||
// window.history.pushState({}, "AnsibleWorks AWX", $location.path());
|
// window.history.pushState({}, "AnsibleWorks AWX", $location.path());
|
||||||
@@ -203,7 +204,8 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
|||||||
mode: 'edit',
|
mode: 'edit',
|
||||||
id: 'stream-content',
|
id: 'stream-content',
|
||||||
breadCrumbs: true,
|
breadCrumbs: true,
|
||||||
searchSize: 'col-lg-4'
|
searchSize: 'col-lg-3',
|
||||||
|
secondWidget: true
|
||||||
});
|
});
|
||||||
|
|
||||||
scope.closeStream = function() {
|
scope.closeStream = function() {
|
||||||
@@ -241,7 +243,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
|||||||
var deleted = /^\_delete/;
|
var deleted = /^\_delete/;
|
||||||
if (scope['activities'][i].summary_fields.object1) {
|
if (scope['activities'][i].summary_fields.object1) {
|
||||||
if ( !deleted.test(scope['activities'][i].summary_fields.object1.name) ) {
|
if ( !deleted.test(scope['activities'][i].summary_fields.object1.name) ) {
|
||||||
href = FixUrl(scope['activities'][i].related.object1);
|
href = BuildUrl(scope['activities'][i].summary_fields.object1);
|
||||||
scope['activities'][i].objects = "<a href=\"" + href + "\">" + scope['activities'][i].summary_fields.object1.name + "</a>";
|
scope['activities'][i].objects = "<a href=\"" + href + "\">" + scope['activities'][i].summary_fields.object1.name + "</a>";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -250,7 +252,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
|||||||
}
|
}
|
||||||
if (scope['activities'][i].summary_fields.object2) {
|
if (scope['activities'][i].summary_fields.object2) {
|
||||||
if ( !deleted.test(scope['activities'][i].summary_fields.object2.name) ) {
|
if ( !deleted.test(scope['activities'][i].summary_fields.object2.name) ) {
|
||||||
href = FixUrl(scope['activities'][i].related.object2);
|
href = BuildUrl(scope['activities'][i].summary_fields.object2);
|
||||||
scope['activities'][i].objects += ", <a href=\"" + href + "\">" + scope['activities'][i].summary_fields.object2.name + "</a>";
|
scope['activities'][i].objects += ", <a href=\"" + href + "\">" + scope['activities'][i].summary_fields.object2.name + "</a>";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -264,7 +266,17 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
|||||||
// Initialize search and paginate pieces and load data
|
// Initialize search and paginate pieces and load data
|
||||||
SearchInit({ scope: scope, set: list.name, list: list, url: defaultUrl });
|
SearchInit({ scope: scope, set: list.name, list: list, url: defaultUrl });
|
||||||
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
PaginateInit({ scope: scope, list: list, url: defaultUrl });
|
||||||
scope.search(list.iterator);
|
scope.search(list.iterator);
|
||||||
|
|
||||||
|
/*
|
||||||
|
scope.$watch(list.iterator + 'SearchField', function(newVal, oldVal) {
|
||||||
|
console.log('newVal: ' + newVal);
|
||||||
|
html += ""
|
||||||
|
html += "<input id=\"search_attribute_input\" type=\"text\" ng-show=\"" + iterator + "ShowAttribute\" class=\"form-control ";
|
||||||
|
html += "\" ng-model=\"" + iterator + "AttributeValue\" ng-change=\"search('" + iterator +
|
||||||
|
"')\" aw-placeholder=\"" + iterator + "AttributePlaceholder\" type=\"text\">\n";
|
||||||
|
});*/
|
||||||
|
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
@@ -151,6 +151,20 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Hos
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// awPlaceholder: Dynamic placeholder set to a scope variable you want watched.
|
||||||
|
// Value will be place in field placeholder attribute.
|
||||||
|
.directive('awPlaceholder', [ function() {
|
||||||
|
return {
|
||||||
|
require: 'ngModel',
|
||||||
|
link: function(scope, elm, attrs, ctrl) {
|
||||||
|
$(elm).attr('placeholder', scope[attrs.awPlaceholder]);
|
||||||
|
scope.$watch(attrs.awPlaceholder, function(newVal, oldVal) {
|
||||||
|
$(elm).attr('placeholder',newVal);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}])
|
||||||
|
|
||||||
// lookup Validate lookup value against API
|
// lookup Validate lookup value against API
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -477,20 +477,20 @@ angular.module('GeneratorHelpers', ['GeneratorHelpers'])
|
|||||||
var iterator = params.iterator;
|
var iterator = params.iterator;
|
||||||
var form = params.template;
|
var form = params.template;
|
||||||
var useMini = params.mini;
|
var useMini = params.mini;
|
||||||
var label = (params.label) ? params.label : null;
|
//var label = (params.label) ? params.label : null;
|
||||||
var html= '';
|
var html= '';
|
||||||
|
var secondWidget = params.secondWidget;
|
||||||
|
|
||||||
html += "<div class=\"row search-widget\">\n";
|
html += "<div class=\"row search-widget\">\n";
|
||||||
html += "<div class=\"";
|
html += "<div class=\"";
|
||||||
html += (params.size) ? params.size : "col-lg-4 col-md-6 col-sm-11 col-xs-11";
|
html += (params.size) ? params.size : "col-lg-4 col-md-6 col-sm-11 col-xs-11";
|
||||||
html += "\">\n";
|
html += "\" id=\"search-widget-container\">\n";
|
||||||
html += (label) ? "<label>" + label +"</label>" : "";
|
html += (form.searchWidgetLabel) ? "<label style=\"display:block\">" + form.searchWidgetLabel +"</label>" : "";
|
||||||
html += "<div class=\"input-group";
|
html += "<div class=\"input-group";
|
||||||
html += (useMini) ? " input-group-sm" : " input-group-sm";
|
html += (useMini) ? " input-group-sm" : " input-group-sm";
|
||||||
html += "\">\n";
|
html += "\">\n";
|
||||||
html += "<div class=\"input-group-btn dropdown\">\n";
|
html += "<div class=\"input-group-btn dropdown\">\n";
|
||||||
|
|
||||||
// Use standard button on mobile
|
|
||||||
html += "<button type=\"button\" ";
|
html += "<button type=\"button\" ";
|
||||||
html += "id=\"search_field_ddown\" ";
|
html += "id=\"search_field_ddown\" ";
|
||||||
html += "class=\"btn ";
|
html += "class=\"btn ";
|
||||||
@@ -499,27 +499,22 @@ angular.module('GeneratorHelpers', ['GeneratorHelpers'])
|
|||||||
html += "<span ng-bind=\"" + iterator + "SearchFieldLabel\"></span>\n";
|
html += "<span ng-bind=\"" + iterator + "SearchFieldLabel\"></span>\n";
|
||||||
html += "<span class=\"caret\"></span>\n";
|
html += "<span class=\"caret\"></span>\n";
|
||||||
html += "</button>\n";
|
html += "</button>\n";
|
||||||
|
|
||||||
// Use link and hover activation on desktop
|
|
||||||
//html += "<a href=\"\" id=\"search_field_ddown\" class=\"btn btn-default visible-lg\">";
|
|
||||||
//html += "<span ng-bind=\"" + iterator + "SearchFieldLabel\"></span>\n";
|
|
||||||
//html += "<span class=\"caret\"></span>\n";
|
|
||||||
//html += "</a>\n";
|
|
||||||
|
|
||||||
html += "<ul class=\"dropdown-menu\" id=\"" + iterator + "SearchDropdown\">\n";
|
html += "<ul class=\"dropdown-menu\" id=\"" + iterator + "SearchDropdown\">\n";
|
||||||
for ( var fld in form.fields) {
|
for ( var fld in form.fields) {
|
||||||
if (form.fields[fld].searchable == undefined || form.fields[fld].searchable == true) {
|
if ( (form.fields[fld].searchable == undefined || form.fields[fld].searchable == true)
|
||||||
html += "<li><a href=\"\" ng-click=\"setSearchField('" + iterator + "','";
|
&& (form.fields[fld].searchWidget == undefined || form.fields[fld].searchWidget == 1) ) {
|
||||||
html += fld + "','";
|
html += "<li><a href=\"\" ng-click=\"setSearchField('" + iterator + "','";
|
||||||
if (form.fields[fld].searchLabel) {
|
html += fld + "','";
|
||||||
html += form.fields[fld].searchLabel + "')\">" +
|
if (form.fields[fld].searchLabel) {
|
||||||
form.fields[fld].searchLabel + "</a></li>\n";
|
html += form.fields[fld].searchLabel + "', 1)\">" +
|
||||||
}
|
form.fields[fld].searchLabel + "</a></li>\n";
|
||||||
else {
|
}
|
||||||
html += form.fields[fld].label.replace(/\<br\>/g,' ') + "')\">" +
|
else {
|
||||||
form.fields[fld].label.replace(/\<br\>/g,' ') + "</a></li>\n";
|
html += form.fields[fld].label.replace(/\<br\>/g,' ') + "')\">" +
|
||||||
}
|
form.fields[fld].label.replace(/\<br\>/g,' ') + "</a></li>\n";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
html += "</ul>\n";
|
html += "</ul>\n";
|
||||||
html += "</div><!-- input-group-btn -->\n";
|
html += "</div><!-- input-group-btn -->\n";
|
||||||
@@ -529,37 +524,71 @@ angular.module('GeneratorHelpers', ['GeneratorHelpers'])
|
|||||||
html += "\"></select>\n";
|
html += "\"></select>\n";
|
||||||
|
|
||||||
html += "<input id=\"search_value_input\" type=\"text\" ng-hide=\"" + iterator + "SelectShow || " + iterator + "InputHide\" class=\"form-control ";
|
html += "<input id=\"search_value_input\" type=\"text\" ng-hide=\"" + iterator + "SelectShow || " + iterator + "InputHide\" class=\"form-control ";
|
||||||
html += "\" ng-model=\"" + iterator + "SearchValue\" ng-change=\"search('" + iterator +
|
html += "\" ng-model=\"" + iterator + "SearchValue\" ng-keydown=\"startSearch('" + iterator + "')\" " +
|
||||||
"')\" placeholder=\"Search\" type=\"text\" ng-disabled=\"" + iterator + "InputDisable\">\n";
|
"aw-placeholder=\"" + iterator + "SearchPlaceholder\" type=\"text\" ng-disabled=\"" + iterator + "InputDisable || " + iterator +
|
||||||
|
"HoldInput\">\n";
|
||||||
/*
|
|
||||||
html += "<div class=\"input-group-btn dropdown\">\n";
|
|
||||||
html += "<button type=\"button\" ";
|
|
||||||
html += "id=\"search_option_ddown\" ";
|
|
||||||
html += "ng-hide=\"" + iterator + "SelectShow || " + iterator + "HideSearchType || " + iterator + "InputHide\" class=\"btn ";
|
|
||||||
html += "dropdown-toggle\" data-toggle=\"dropdown\">\n";
|
|
||||||
html += "<span ng-bind=\"" + iterator + "SearchTypeLabel\"></span>\n";
|
|
||||||
html += "<span class=\"caret\"></span>\n";
|
|
||||||
html += "</button>\n";
|
|
||||||
html += "<ul class=\"dropdown-menu pull-right\">\n";
|
|
||||||
html += "<li><a href=\"\" ng-click=\"setSearchType('" + iterator + "','iexact','Exact Match')\">Exact Match</a></li>\n";
|
|
||||||
html += "<li><a href=\"\" ng-click=\"setSearchType('" + iterator + "','icontains','Contains')\">Contains</a></li>\n";
|
|
||||||
html += "</ul>\n";
|
|
||||||
html += "</div><!-- input-group-btn -->\n";
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// Reset button
|
// Reset button
|
||||||
html += "<div class=\"input-group-btn\">\n";
|
html += "<div class=\"input-group-btn\">\n";
|
||||||
html += "<button type=\"button\" class=\"btn btn-default btn-small\" ng-click=\"resetSearch('" + iterator + "')\" " +
|
html += "<button type=\"button\" class=\"btn btn-default btn-small\" ng-click=\"resetSearch('" + iterator + "', 1)\" " +
|
||||||
"aw-tool-tip=\"Reset filter\" data-placement=\"top\" " +
|
"aw-tool-tip=\"Reset filter\" data-placement=\"top\" " +
|
||||||
"><i class=\"icon-undo\"></i></button>\n";
|
"><i class=\"icon-undo\"></i></button>\n";
|
||||||
html += "</div><!-- input-group-btn -->\n";
|
html += "</div><!-- input-group-btn -->\n";
|
||||||
html += "</div><!-- input-group -->\n";
|
html += "</div><!-- input-group -->\n";
|
||||||
|
|
||||||
html += "</div><!-- col-lg-x -->\n";
|
html += "</div><!-- col-lg-x -->\n";
|
||||||
|
|
||||||
|
// Search Widget 2
|
||||||
|
// Used on activity stream. Set 'searchWidget2: true' on fields to be included.
|
||||||
|
if (secondWidget) {
|
||||||
|
html += "<div class=\"col-lg-3\" id=\"search-widget-container2\">\n";
|
||||||
|
html += (form.searchWidgetLabel2) ? "<label style=\"display:block\">" + form.searchWidgetLabel2 +"</label>" : "";
|
||||||
|
html += "<div class=\"input-group input-group-sm\">\n";
|
||||||
|
html += "<div class=\"input-group-btn dropdown2\">\n";
|
||||||
|
html += "<button type=\"button\" ";
|
||||||
|
html += "id=\"search_field_ddown2\" ";
|
||||||
|
html += "class=\"btn dropdown-toggle\" data-toggle=\"dropdown\">\n";
|
||||||
|
html += "<span ng-bind=\"" + iterator + "SearchFieldLabel2\"></span>\n";
|
||||||
|
html += "<span class=\"caret\"></span>\n";
|
||||||
|
html += "</button>\n";
|
||||||
|
|
||||||
|
html += "<ul class=\"dropdown-menu\" id=\"" + iterator + "SearchDropdown2\">\n";
|
||||||
|
for ( var fld in form.fields) {
|
||||||
|
if ( (form.fields[fld].searchable == undefined || form.fields[fld].searchable == true)
|
||||||
|
&& form.fields[fld].searchWidget == 2 ) {
|
||||||
|
html += "<li><a href=\"\" ng-click=\"setSearchField('" + iterator + "','";
|
||||||
|
html += fld + "','";
|
||||||
|
if (form.fields[fld].searchLabel) {
|
||||||
|
html += form.fields[fld].searchLabel + "', 2)\">" +
|
||||||
|
form.fields[fld].searchLabel + "</a></li>\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
html += form.fields[fld].label.replace(/\<br\>/g,' ') + "', 2)\">" +
|
||||||
|
form.fields[fld].label.replace(/\<br\>/g,' ') + "</a></li>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
html += "</ul>\n";
|
||||||
|
html += "</div><!-- input-group-btn -->\n";
|
||||||
|
|
||||||
|
html += "<input id=\"search_value_input\" type=\"text\" ng-hide=\"" + iterator + "SelectShow2 || " + iterator + "InputHide2\" class=\"form-control ";
|
||||||
|
html += "\" ng-model=\"" + iterator + "SearchValue2\" ng-keydown=\"startSearch('" + iterator + "')\" " +
|
||||||
|
"aw-placeholder=\"" + iterator + "SearchPlaceholder2\" type=\"text\" ng-disabled=\"" + iterator + "InputDisable2 || " + iterator +
|
||||||
|
"HoldInput2\">\n";
|
||||||
|
|
||||||
|
// Reset button
|
||||||
|
html += "<div class=\"input-group-btn\">\n";
|
||||||
|
html += "<button type=\"button\" class=\"btn btn-default btn-small\" ng-click=\"resetSearch('" + iterator + "', 2)\" " +
|
||||||
|
"aw-tool-tip=\"Reset filter\" data-placement=\"top\" " +
|
||||||
|
"><i class=\"icon-undo\"></i></button>\n";
|
||||||
|
html += "</div><!-- input-group-btn -->\n";
|
||||||
|
html += "</div><!-- input-group -->\n";
|
||||||
|
html += "</div><!-- col-lg-x -->\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spinner
|
||||||
html += "<div class=\"col-lg-1 col-md-1 col-sm-1 col-xs-1\"><i class=\"icon-spinner icon-spin icon-large\" ng-show=\"" + iterator +
|
html += "<div class=\"col-lg-1 col-md-1 col-sm-1 col-xs-1\"><i class=\"icon-spinner icon-spin icon-large\" ng-show=\"" + iterator +
|
||||||
"SearchSpin == true\"></i></div>\n";
|
"SearchSpin == true\"></i></div>\n";
|
||||||
|
|
||||||
return html;
|
return html;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,7 +194,8 @@ angular.module('ListGenerator', ['GeneratorHelpers'])
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (options.searchSize) {
|
if (options.searchSize) {
|
||||||
html += SearchWidget({ iterator: list.iterator, template: list, mini: true , size: options.searchSize });
|
html += SearchWidget({ iterator: list.iterator, template: list, mini: true , size: options.searchSize,
|
||||||
|
secondWidget: options.secondWidget });
|
||||||
}
|
}
|
||||||
else if (options.mode == 'summary') {
|
else if (options.mode == 'summary') {
|
||||||
html += SearchWidget({ iterator: list.iterator, template: list, mini: true , size: 'col-lg-6' });
|
html += SearchWidget({ iterator: list.iterator, template: list, mini: true , size: 'col-lg-6' });
|
||||||
@@ -214,6 +215,7 @@ angular.module('ListGenerator', ['GeneratorHelpers'])
|
|||||||
if (options.searchSize) {
|
if (options.searchSize) {
|
||||||
// User supplied searchSize, calc the remaining
|
// User supplied searchSize, calc the remaining
|
||||||
var size = parseInt(options.searchSize.replace(/([A-Z]|[a-z]|\-)/g,''));
|
var size = parseInt(options.searchSize.replace(/([A-Z]|[a-z]|\-)/g,''));
|
||||||
|
size += (options.secondWidget) ? 3 : 0;
|
||||||
html += 'col-lg-' + (11 - size);
|
html += 'col-lg-' + (11 - size);
|
||||||
}
|
}
|
||||||
else if (options.mode == 'summary') {
|
else if (options.mode == 'summary') {
|
||||||
|
|||||||
Reference in New Issue
Block a user