mirror of
https://github.com/ansible/awx.git
synced 2026-05-15 21:37:42 -02:30
Added support for many (unlimited) search widgets on a page. Activity widget now has 2 object search widgets. Adding a setHeader function to Rest.js library.
This commit is contained in:
@@ -39,7 +39,7 @@ angular.module('ActivityDetailDefinition', [])
|
|||||||
object1_name: {
|
object1_name: {
|
||||||
label: 'Name',
|
label: 'Name',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
ngHide: '!object1',
|
ngHide: '!object1_name',
|
||||||
readonly: true
|
readonly: true
|
||||||
},
|
},
|
||||||
object2: {
|
object2: {
|
||||||
@@ -51,12 +51,13 @@ angular.module('ActivityDetailDefinition', [])
|
|||||||
object2_name: {
|
object2_name: {
|
||||||
label: 'Name',
|
label: 'Name',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
ngHide: '!object2',
|
ngHide: '!object2_name',
|
||||||
readonly: true
|
readonly: true
|
||||||
},
|
},
|
||||||
changes: {
|
changes: {
|
||||||
label: 'Changes',
|
label: 'Changes',
|
||||||
type: 'textarea',
|
type: 'textarea',
|
||||||
|
ngHide: '!changes',
|
||||||
readonly: true
|
readonly: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,9 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
|||||||
var defaultUrl = params.url;
|
var defaultUrl = params.url;
|
||||||
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;
|
||||||
|
var expected_objects=0;
|
||||||
|
var found_objects=0;
|
||||||
|
|
||||||
if (scope.searchTimer) {
|
if (scope.searchTimer) {
|
||||||
$timeout.cancel(scope.searchTimer);
|
$timeout.cancel(scope.searchTimer);
|
||||||
@@ -114,74 +116,68 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
|||||||
// Functions to handle search widget changes
|
// Functions to handle search widget changes
|
||||||
scope.setSearchField = function(iterator, fld, label, widget) {
|
scope.setSearchField = function(iterator, fld, label, widget) {
|
||||||
|
|
||||||
var modifier = (widget == undefined || widget == 1) ? '' : widget;
|
var modifier = (widget == undefined || widget == 1) ? '' : widget;
|
||||||
scope[iterator + 'SearchFieldLabel' + modifier] = label;
|
scope[iterator + 'SearchFieldLabel' + modifier] = label;
|
||||||
scope[iterator + 'SearchField' + modifier] = fld;
|
scope[iterator + 'SearchField' + modifier] = fld;
|
||||||
scope[iterator + 'SearchValue' + modifier] = '';
|
scope[iterator + 'SearchValue' + modifier] = '';
|
||||||
scope[iterator + 'SelectShow' + modifier] = false;
|
scope[iterator + 'SelectShow' + modifier] = false;
|
||||||
scope[iterator + 'HideSearchType' + modifier] = false;
|
scope[iterator + 'HideSearchType' + modifier] = false;
|
||||||
scope[iterator + 'InputHide' + modifier] = false;
|
scope[iterator + 'InputHide' + modifier] = false;
|
||||||
scope[iterator + 'SearchType' + modifier] = 'icontains';
|
scope[iterator + 'SearchType' + modifier] = 'icontains';
|
||||||
scope[iterator + 'SearchPlaceholder' + modifier] = (list.fields[fld].searchPlaceholder) ? list.fields[fld].searchPlaceholder : 'Search';
|
scope[iterator + 'SearchPlaceholder' + modifier] = (list.fields[fld].searchPlaceholder) ? list.fields[fld].searchPlaceholder : 'Search';
|
||||||
scope[iterator + 'InputDisable' + modifier] = (list.fields[fld].searchObject == 'all') ? true : false;
|
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" + modifier] = 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' + modifier] = true;
|
scope[iterator + 'InputDisable' + modifier] = true;
|
||||||
scope[iterator + "SearchValue" + modifier] = 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" + modifier] = { 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" + modifier] = { value: 0 };
|
scope[iterator + "SearchSelectValue" + modifier] = { value: 0 };
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
scope[iterator + "SearchSelectValue" + modifier] = { 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" + modifier] = 'in';
|
scope[iterator + "SearchType" + modifier] = 'in';
|
||||||
scope[iterator + "SearchValue" + modifier] = list.fields[fld].searchValue;
|
scope[iterator + "SearchValue" + modifier] = list.fields[fld].searchValue;
|
||||||
scope[iterator + "InputDisable" + modifier] = 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_or')) {
|
|| list.fields[fld].searchType == 'select' || list.fields[fld].searchType == 'select_or')) {
|
||||||
scope[iterator + 'SelectShow' + modifier] = true;
|
scope[iterator + 'SelectShow' + modifier] = true;
|
||||||
scope[iterator + 'SearchSelectOpts' + modifier] = 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' + modifier] = 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' + modifier] = 'isnull';
|
scope[iterator + 'SearchType' + modifier] = 'isnull';
|
||||||
scope[iterator + 'InputDisable' + modifier] = true;
|
scope[iterator + 'InputDisable' + modifier] = true;
|
||||||
scope[iterator + 'SearchValue' + modifier] = 'true';
|
scope[iterator + 'SearchValue' + modifier] = 'true';
|
||||||
}
|
}
|
||||||
scope.search(iterator);
|
scope.search(iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.resetSearch = function(iterator, widget) {
|
scope.resetSearch = function(iterator, widget) {
|
||||||
// Respdond to click of reset button
|
// Respdond to click of reset button
|
||||||
setDefaults(widget);
|
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.search(iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
//scope.setSearchType = function(iterator, type, label) {
|
|
||||||
// scope[iterator + 'SearchTypeLabel'] = label;
|
|
||||||
// scope[iterator + 'SearchType'] = type;
|
|
||||||
// scope.search(iterator);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (scope.removeDoSearch) {
|
if (scope.removeDoSearch) {
|
||||||
scope.removeDoSearch();
|
scope.removeDoSearch();
|
||||||
}
|
}
|
||||||
@@ -212,85 +208,126 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
|||||||
Refresh({ scope: scope, set: set, iterator: iterator, url: url });
|
Refresh({ scope: scope, set: set, iterator: iterator, url: url });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (scope.removeFoundObject) {
|
||||||
|
scope.removeFoundObject();
|
||||||
|
}
|
||||||
|
scope.removeFoundObject = scope.$on('foundObject', function(e, iterator, page, load, spin, widget, pk) {
|
||||||
|
found_objects++;
|
||||||
|
// Add new criteria to search params
|
||||||
|
var modifier = (widget == 1) ? '' : widget;
|
||||||
|
var objs = list.fields[scope[iterator + 'SearchField' + modifier]].searchObject;
|
||||||
|
var o = (objs == 'inventories') ? 'inventory' : objs.replace(/s$/,'');
|
||||||
|
var searchFld = list.fields[scope[iterator + 'SearchField' + modifier]].searchField;
|
||||||
|
scope[iterator + 'SearchParams'] += '&' + searchFld + '__icontains=' + o;
|
||||||
|
if (!Empty(pk)) {
|
||||||
|
scope[iterator + 'SearchParams'] += '&' + searchFld + '_id__in=' + pk;
|
||||||
|
}
|
||||||
|
// Move to the next phase once all object types are processed
|
||||||
|
if (found_objects == expected_objects) {
|
||||||
|
scope.$emit('prepareSearch2', iterator, page, load, spin);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (scope.removePrepareSearch) {
|
if (scope.removePrepareSearch) {
|
||||||
scope.removePrepareSearch();
|
scope.removePrepareSearch();
|
||||||
}
|
}
|
||||||
scope.removePrepareSearch = scope.$on('prepareSearch', function(e, iterator, page, load, spin) {
|
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
|
// Start build the search key/value pairs. This will process search widget, if the
|
||||||
// selected field is an object type (used on activity stream).
|
// selected field is an object type (used on activity stream).
|
||||||
//
|
//
|
||||||
scope[iterator + 'HoldInput'] = true;
|
|
||||||
scope[iterator + 'SearchParams'] = '';
|
scope[iterator + 'SearchParams'] = '';
|
||||||
if (list.fields[scope[iterator + 'SearchField']].searchObject &&
|
var widgets = (list.searchWidgets) ? list.searchWidgets : 1;
|
||||||
list.fields[scope[iterator + 'SearchField']].searchObject !== 'all') {
|
var modifier;
|
||||||
//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.
|
// Determine how many object values we're dealing with.
|
||||||
var objs = list.fields[scope[iterator + 'SearchField']].searchObject;
|
expected_objects = 0;
|
||||||
var o = (objs == 'inventories') ? 'inventory' : objs.replace(/s$/,'');
|
found_objects = 0;
|
||||||
scope[iterator + 'SearchParams'] = 'or__object1=' + o + '&or__object2=' + o;
|
for (var i=1; i <= widgets; i++) {
|
||||||
if (scope[iterator + 'SearchValue']) {
|
modifier = (i == 1) ? '' : i;
|
||||||
var objUrl = GetBasePath('base') + objs + '/?name__icontains=' + scope[iterator + 'SearchValue'];
|
if ($('#search-widget-container' + modifier) &&
|
||||||
Rest.setUrl(objUrl);
|
list.fields[scope[iterator + 'SearchField' + modifier]] &&
|
||||||
Rest.get()
|
list.fields[scope[iterator + 'SearchField' + modifier]].searchObject &&
|
||||||
.success( function(data, status, headers, config) {
|
list.fields[scope[iterator + 'SearchField' + modifier]].searchObject !== 'all') {
|
||||||
var list='';
|
expected_objects++;
|
||||||
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);
|
for (var i=1; i <= widgets; i++) {
|
||||||
|
var modifier = (i == 1) ? '' : i;
|
||||||
|
if ( $('#search-widget-container' + modifier) ) {
|
||||||
|
if (list.fields[scope[iterator + 'SearchField' + modifier]] &&
|
||||||
|
list.fields[scope[iterator + 'SearchField' + modifier]].searchObject &&
|
||||||
|
list.fields[scope[iterator + 'SearchField' + modifier]].searchObject !== 'all') {
|
||||||
|
scope[iterator + 'HoldInput' + modifier] = true;
|
||||||
|
if (scope[iterator + 'SearchValue' + modifier]) {
|
||||||
|
var objs = list.fields[scope[iterator + 'SearchField' + modifier]].searchObject;
|
||||||
|
var objUrl = GetBasePath('base') + objs + '/?name__icontains=' + scope[iterator + 'SearchValue'];
|
||||||
|
Rest.setUrl(objUrl);
|
||||||
|
Rest.get()
|
||||||
|
.success( function(data, status, headers, config) {
|
||||||
|
var pk='';
|
||||||
|
for (var j=0; j < data.results.length; j++) {
|
||||||
|
pk += "," + data.results[j].id;
|
||||||
|
}
|
||||||
|
pk = pk.replace(/^\,/,'');
|
||||||
|
console.log(config);
|
||||||
|
scope.$emit('foundObject', iterator, page, load, spin, i, pk);
|
||||||
|
})
|
||||||
|
.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('foundObject', iterator, page, load, spin, i, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (expected_objects == 0) {
|
||||||
|
// No search widgets contain objects
|
||||||
|
scope.$emit('prepareSearch2', iterator, page, load, spin);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (scope.removePrepareSearch2) {
|
if (scope.removePrepareSearch2) {
|
||||||
scope.removePrepareSearch2();
|
scope.removePrepareSearch2();
|
||||||
}
|
}
|
||||||
scope.removePrepareSearch2 = scope.$on('prepareSearch2', function(e, iterator, page, load, spin, startingWidget) {
|
scope.removePrepareSearch2 = scope.$on('prepareSearch2', function(e, iterator, page, load, spin) {
|
||||||
// Continue building the search by examining the remaining search widgets. If we're looking at activity_stream,
|
// Continue building the search by examining the remaining search widgets. If we're looking at activity_stream,
|
||||||
// there's more than one.
|
// there's more than one.
|
||||||
for (var i=startingWidget; i <= 3; i++) {
|
var widgets = (list.searchWidgets) ? list.searchWidgets : 1;
|
||||||
var modifier = (i == 1) ? '' : i;
|
var modifier;
|
||||||
|
for (var i=1; i <= widgets; i++) {
|
||||||
|
modifier = (i == 1) ? '' : i;
|
||||||
scope[iterator + 'HoldInput' + modifier] = true;
|
scope[iterator + 'HoldInput' + modifier] = true;
|
||||||
if ( $('#search-widget-container' + modifier) ) {
|
if ($('#search-widget-container' + modifier) &&
|
||||||
// if the search widget exists, add its parameters to the query
|
list.fields[scope[iterator + 'SearchField' + modifier]] &&
|
||||||
|
!list.fields[scope[iterator + 'SearchField' + modifier]].searchObject) {
|
||||||
|
|
||||||
|
// if the search widget exists and its value is not an object, add its parameters to the query
|
||||||
|
|
||||||
if ( (!scope[iterator + 'SelectShow' + modifier] && !Empty(scope[iterator + 'SearchValue' + modifier])) ||
|
if ( (!scope[iterator + 'SelectShow' + modifier] && !Empty(scope[iterator + 'SearchValue' + modifier])) ||
|
||||||
(scope[iterator + 'SelectShow' + modifier] && scope[iterator + 'SearchSelectValue' + modifier]) ||
|
(scope[iterator + 'SelectShow' + modifier] && scope[iterator + 'SearchSelectValue' + modifier]) ||
|
||||||
(list.fields[scope[iterator + 'SearchField' + modifier]] &&
|
(list.fields[scope[iterator + 'SearchField' + modifier]] &&
|
||||||
list.fields[scope[iterator + 'SearchField' + modifier]].searchType == 'gtzero') ) {
|
list.fields[scope[iterator + 'SearchField' + modifier]].searchType == 'gtzero') ) {
|
||||||
if (list.fields[scope[iterator + 'SearchField' + modifier]].searchField) {
|
if (list.fields[scope[iterator + 'SearchField' + modifier]].searchField) {
|
||||||
scope[iterator + 'SearchParams'] = 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) {
|
else if (list.fields[scope[iterator + 'SearchField' + modifier]].sourceModel) {
|
||||||
// handle fields whose source is a related model e.g. inventories.organization
|
// handle fields whose source is a related model e.g. inventories.organization
|
||||||
scope[iterator + 'SearchParams'] = list.fields[scope[iterator + 'SearchField' + modifier]].sourceModel + '__' +
|
scope[iterator + 'SearchParams'] += '&' + list.fields[scope[iterator + 'SearchField' + modifier]].sourceModel + '__' +
|
||||||
list.fields[scope[iterator + 'SearchField' + modifier]].sourceField + '__';
|
list.fields[scope[iterator + 'SearchField' + modifier]].sourceField + '__';
|
||||||
}
|
}
|
||||||
else if ( (list.fields[scope[iterator + 'SearchField' + modifier]].searchType == 'select') &&
|
else if ( (list.fields[scope[iterator + 'SearchField' + modifier]].searchType == 'select') &&
|
||||||
(scope[iterator + 'SearchSelectValue' + modifier].value == '' ||
|
(scope[iterator + 'SearchSelectValue' + modifier].value == '' ||
|
||||||
scope[iterator + 'SearchSelectValue' + modifier].value == null) ) {
|
scope[iterator + 'SearchSelectValue' + modifier].value == null) ) {
|
||||||
scope[iterator + 'SearchParams'] = scope[iterator + 'SearchField' + modifier];
|
scope[iterator + 'SearchParams'] += '&' + scope[iterator + 'SearchField' + modifier];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
scope[iterator + 'SearchParams'] = scope[iterator + 'SearchField' + modifier] + '__';
|
scope[iterator + 'SearchParams'] += '&' + scope[iterator + 'SearchField' + modifier] + '__';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( list.fields[scope[iterator + 'SearchField' + modifier]].searchType &&
|
if ( list.fields[scope[iterator + 'SearchField' + modifier]].searchType &&
|
||||||
@@ -307,7 +344,7 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
|||||||
scope[iterator + 'SearchSelectValue' + modifier].value == null) ) {
|
scope[iterator + 'SearchSelectValue' + modifier].value == null) ) {
|
||||||
scope[iterator + 'SearchParams'] += 'iexact=';
|
scope[iterator + 'SearchParams'] += 'iexact=';
|
||||||
}
|
}
|
||||||
else if ( (list.fields[scope[iterator + 'SearchField' + modifier]].searchType &&
|
/*else if ( (list.fields[scope[iterator + 'SearchField' + modifier]].searchType &&
|
||||||
(list.fields[scope[iterator + 'SearchField' + modifier]].searchType == 'or')) ) {
|
(list.fields[scope[iterator + 'SearchField' + modifier]].searchType == 'or')) ) {
|
||||||
scope[iterator + 'SearchParams'] = ''; //start over
|
scope[iterator + 'SearchParams'] = ''; //start over
|
||||||
var val = scope[iterator + 'SearchValue' + modifier];
|
var val = scope[iterator + 'SearchValue' + modifier];
|
||||||
@@ -317,7 +354,7 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper'])
|
|||||||
'__icontains=' + escape(val);
|
'__icontains=' + escape(val);
|
||||||
}
|
}
|
||||||
scope[iterator + 'SearchParams'].replace(/^\&/,'');
|
scope[iterator + 'SearchParams'].replace(/^\&/,'');
|
||||||
}
|
}*/
|
||||||
else {
|
else {
|
||||||
scope[iterator + 'SearchParams'] += scope[iterator + 'SearchType' + modifier] + '=';
|
scope[iterator + 'SearchParams'] += scope[iterator + 'SearchType' + modifier] + '=';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ angular.module('StreamListDefinition', [])
|
|||||||
index: false,
|
index: false,
|
||||||
hover: true,
|
hover: true,
|
||||||
"class": "table-condensed",
|
"class": "table-condensed",
|
||||||
searchWidgetLabel: 'Object',
|
searchWidgets: 3,
|
||||||
searchWidgetLabel2: 'Modified by',
|
|
||||||
|
|
||||||
fields: {
|
fields: {
|
||||||
timestamp: {
|
timestamp: {
|
||||||
@@ -29,14 +28,14 @@ angular.module('StreamListDefinition', [])
|
|||||||
searchable: false
|
searchable: false
|
||||||
},
|
},
|
||||||
user: {
|
user: {
|
||||||
label: 'User',
|
label: 'Initiated by',
|
||||||
ngBindHtml: 'activity.user',
|
ngBindHtml: 'activity.user',
|
||||||
sourceModel: 'user',
|
sourceModel: 'user',
|
||||||
sourceField: 'username',
|
sourceField: 'username',
|
||||||
awToolTip: "\{\{ userToolTip \}\}",
|
awToolTip: "\{\{ userToolTip \}\}",
|
||||||
dataPlacement: 'top',
|
dataPlacement: 'top',
|
||||||
searchPlaceholder: 'Username',
|
searchPlaceholder: 'Initiated by username',
|
||||||
searchWidget: 2
|
searchWidget: 1
|
||||||
},
|
},
|
||||||
objects: {
|
objects: {
|
||||||
label: 'Objects',
|
label: 'Objects',
|
||||||
@@ -51,68 +50,162 @@ angular.module('StreamListDefinition', [])
|
|||||||
searchable: false
|
searchable: false
|
||||||
},
|
},
|
||||||
system_event: {
|
system_event: {
|
||||||
label: 'System',
|
label: 'System event',
|
||||||
searchOnly: true,
|
searchOnly: true,
|
||||||
searchType: 'isnull',
|
searchType: 'isnull',
|
||||||
sourceModel: 'user',
|
sourceModel: 'user',
|
||||||
sourceField: 'username',
|
sourceField: 'username',
|
||||||
searchWidget: 2
|
searchWidget: 1
|
||||||
},
|
},
|
||||||
// The following fields exist to forces loading each type of object into the search
|
|
||||||
|
// The following fields exist to force loading each type of object into the search
|
||||||
// dropdown
|
// dropdown
|
||||||
all_objects: {
|
all_objects: {
|
||||||
label: 'All',
|
label: 'All',
|
||||||
searchOnly: true,
|
searchOnly: true,
|
||||||
searchObject: 'all',
|
searchObject: 'all',
|
||||||
searchPlaceholder: ' '
|
searchPlaceholder: 'All primary objects',
|
||||||
|
searchWidget: 2,
|
||||||
|
searchField: 'object1'
|
||||||
},
|
},
|
||||||
credential_search: {
|
credential_search: {
|
||||||
label: 'Credential',
|
label: 'Credential',
|
||||||
searchOnly: true,
|
searchOnly: true,
|
||||||
searchObject: 'credentials',
|
searchObject: 'credentials',
|
||||||
searchPlaceholder: 'Credential name'
|
searchPlaceholder: 'Primary credential name',
|
||||||
|
searchWidget: 2,
|
||||||
|
searchField: 'object1'
|
||||||
},
|
},
|
||||||
group_search: {
|
group_search: {
|
||||||
label: 'Group',
|
label: 'Group',
|
||||||
searchOnly: true,
|
searchOnly: true,
|
||||||
searchObject: 'groups',
|
searchObject: 'groups',
|
||||||
searchPlaceholder: 'Group name'
|
searchPlaceholder: 'Primary group name',
|
||||||
|
searchWidget: 2,
|
||||||
|
searchField: 'object1'
|
||||||
},
|
},
|
||||||
host_search: {
|
host_search: {
|
||||||
label: 'Host',
|
label: 'Host',
|
||||||
searchOnly: true,
|
searchOnly: true,
|
||||||
searchObject: 'hosts',
|
searchObject: 'hosts',
|
||||||
searchPlaceholder: 'Host name'
|
searchPlaceholder: 'Primary host name',
|
||||||
|
searchWidget: 2,
|
||||||
|
searchField: 'object1'
|
||||||
},
|
},
|
||||||
inventory_search: {
|
inventory_search: {
|
||||||
label: 'Inventory',
|
label: 'Inventory',
|
||||||
searchOnly: true,
|
searchOnly: true,
|
||||||
searchObject: 'inventories',
|
searchObject: 'inventories',
|
||||||
searchPlaceholder: 'Inventory name'
|
searchPlaceholder: 'Primary inventory name',
|
||||||
|
searchWidget: 2,
|
||||||
|
searchField: 'object1'
|
||||||
},
|
},
|
||||||
job_template_search: {
|
job_template_search: {
|
||||||
label: 'Job Template',
|
label: 'Job Template',
|
||||||
searchOnly: true,
|
searchOnly: true,
|
||||||
searchObject: 'job_templates',
|
searchObject: 'job_templates',
|
||||||
searchPlaceholder: 'Job template name'
|
searchPlaceholder: 'Primary job template name',
|
||||||
|
searchWidget: 2,
|
||||||
|
searchField: 'object1'
|
||||||
},
|
},
|
||||||
organization_search: {
|
organization_search: {
|
||||||
label: 'Organization',
|
label: 'Organization',
|
||||||
searchOnly: true,
|
searchOnly: true,
|
||||||
searchObject: 'organizations',
|
searchObject: 'organizations',
|
||||||
searchPlaceholder: 'Organization name'
|
searchPlaceholder: 'Primary organization name',
|
||||||
|
searchWidget: 2,
|
||||||
|
searchField: 'object1'
|
||||||
},
|
},
|
||||||
project_search: {
|
project_search: {
|
||||||
label: 'Project',
|
label: 'Project',
|
||||||
searchOnly: true,
|
searchOnly: true,
|
||||||
searchObject: 'projects',
|
searchObject: 'projects',
|
||||||
searchPlaceholder: 'Project name'
|
searchPlaceholder: 'Primary project name',
|
||||||
|
searchWidget: 2,
|
||||||
|
searchField: 'object1'
|
||||||
},
|
},
|
||||||
user_search: {
|
user_search: {
|
||||||
label: 'User',
|
label: 'User',
|
||||||
searchOnly: true,
|
searchOnly: true,
|
||||||
searchObject: 'users',
|
searchObject: 'users',
|
||||||
searchPlaceholder: 'Username'
|
searchPlaceholder: 'Primary username',
|
||||||
|
searchWidget: 2,
|
||||||
|
searchField: 'object1'
|
||||||
|
},
|
||||||
|
|
||||||
|
// The following fields exist to force loading each type of object into the search
|
||||||
|
// dropdown
|
||||||
|
all_objects3: {
|
||||||
|
label: 'All',
|
||||||
|
searchOnly: true,
|
||||||
|
searchObject: 'all',
|
||||||
|
searchPlaceholder: 'All related objects',
|
||||||
|
searchWidget: 3,
|
||||||
|
searchField: 'object2'
|
||||||
|
},
|
||||||
|
credential_search3: {
|
||||||
|
label: 'Credential',
|
||||||
|
searchOnly: true,
|
||||||
|
searchObject: 'credentials',
|
||||||
|
searchPlaceholder: 'Related credential name',
|
||||||
|
searchWidget: 3,
|
||||||
|
searchField: 'object2'
|
||||||
|
},
|
||||||
|
group_search3: {
|
||||||
|
label: 'Group',
|
||||||
|
searchOnly: true,
|
||||||
|
searchObject: 'groups',
|
||||||
|
searchPlaceholder: 'Related group name',
|
||||||
|
searchWidget: 3,
|
||||||
|
searchField: 'object2'
|
||||||
|
},
|
||||||
|
host_search3: {
|
||||||
|
label: 'Host',
|
||||||
|
searchOnly: true,
|
||||||
|
searchObject: 'hosts',
|
||||||
|
searchPlaceholder: 'Related host name',
|
||||||
|
searchWidget: 3,
|
||||||
|
searchField: 'object2'
|
||||||
|
},
|
||||||
|
inventory_search3: {
|
||||||
|
label: 'Inventory',
|
||||||
|
searchOnly: true,
|
||||||
|
searchObject: 'inventories',
|
||||||
|
searchPlaceholder: 'Related inventory name',
|
||||||
|
searchWidget: 3,
|
||||||
|
searchField: 'object2'
|
||||||
|
},
|
||||||
|
job_template_search3: {
|
||||||
|
label: 'Job Template',
|
||||||
|
searchOnly: true,
|
||||||
|
searchObject: 'job_templates',
|
||||||
|
searchPlaceholder: 'Related job template name',
|
||||||
|
searchWidget: 3,
|
||||||
|
searchField: 'object2'
|
||||||
|
},
|
||||||
|
organization_search3: {
|
||||||
|
label: 'Organization',
|
||||||
|
searchOnly: true,
|
||||||
|
searchObject: 'organizations',
|
||||||
|
searchPlaceholder: 'Related organization name',
|
||||||
|
searchWidget: 3,
|
||||||
|
searchField: 'object2'
|
||||||
|
},
|
||||||
|
project_search3: {
|
||||||
|
label: 'Project',
|
||||||
|
searchOnly: true,
|
||||||
|
searchObject: 'projects',
|
||||||
|
searchPlaceholder: 'Related project name',
|
||||||
|
searchWidget: 3,
|
||||||
|
searchField: 'object2'
|
||||||
|
},
|
||||||
|
user_search3: {
|
||||||
|
label: 'User',
|
||||||
|
searchOnly: true,
|
||||||
|
searchObject: 'users',
|
||||||
|
searchPlaceholder: 'Related username',
|
||||||
|
searchWidget: 3,
|
||||||
|
searchField: 'object2'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -92,14 +92,20 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
|||||||
}
|
}
|
||||||
descr += activity.operation;
|
descr += activity.operation;
|
||||||
descr += (/e$/.test(activity.operation)) ? 'd ' : 'ed ';
|
descr += (/e$/.test(activity.operation)) ? 'd ' : 'ed ';
|
||||||
if (activity.summary_fields.object2) {
|
if (activity.summary_fields.object2 && activity.summary_fields.object2.name) {
|
||||||
descr += activity.summary_fields.object2.base + ' <a href=\"' + BuildUrl(activity.summary_fields.object2) + '\">'
|
descr += activity.summary_fields.object2.base + ' <a href=\"' + BuildUrl(activity.summary_fields.object2) + '\">'
|
||||||
+ activity.summary_fields.object2.name + '</a>' + [ (activity.operation == 'disassociate') ? ' from ' : ' to '];
|
+ activity.summary_fields.object2.name + '</a>' + [ (activity.operation == 'disassociate') ? ' from ' : ' to '];
|
||||||
}
|
}
|
||||||
if (activity.summary_fields.object1) {
|
else if (activity.object2) {
|
||||||
|
descr += activity.object2 + [ (activity.operation == 'disassociate') ? ' from ' : ' to '];
|
||||||
|
}
|
||||||
|
if (activity.summary_fields.object1 && activity.summary_fields.object1.name) {
|
||||||
descr += activity.summary_fields.object1.base + ' <a href=\"' + BuildUrl(activity.summary_fields.object1) + '\">'
|
descr += activity.summary_fields.object1.base + ' <a href=\"' + BuildUrl(activity.summary_fields.object1) + '\">'
|
||||||
+ activity.summary_fields.object1.name + '</a>';
|
+ activity.summary_fields.object1.name + '</a>';
|
||||||
}
|
}
|
||||||
|
else if (activity.object1) {
|
||||||
|
descr += activity.object1;
|
||||||
|
}
|
||||||
return descr;
|
return descr;
|
||||||
}
|
}
|
||||||
}])
|
}])
|
||||||
@@ -241,7 +247,7 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
|||||||
// Objects
|
// Objects
|
||||||
var href;
|
var href;
|
||||||
var deleted = /^\_delete/;
|
var deleted = /^\_delete/;
|
||||||
if (scope['activities'][i].summary_fields.object1) {
|
if (scope['activities'][i].summary_fields.object1 && scope['activities'][i].summary_fields.object1.name) {
|
||||||
if ( !deleted.test(scope['activities'][i].summary_fields.object1.name) ) {
|
if ( !deleted.test(scope['activities'][i].summary_fields.object1.name) ) {
|
||||||
href = BuildUrl(scope['activities'][i].summary_fields.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>";
|
||||||
@@ -250,15 +256,23 @@ angular.module('StreamWidget', ['RestServices', 'Utilities', 'StreamListDefiniti
|
|||||||
scope['activities'][i].objects = scope['activities'][i].summary_fields.object1.name;
|
scope['activities'][i].objects = scope['activities'][i].summary_fields.object1.name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (scope['activities'][i].summary_fields.object2) {
|
else if (scope['activities'][i].object1) {
|
||||||
|
scope['activities'][i].objects = scope['activities'][i].object1;
|
||||||
|
}
|
||||||
|
if (scope['activities'][i].summary_fields.object2 && scope['activities'][i].summary_fields.object2.name) {
|
||||||
if ( !deleted.test(scope['activities'][i].summary_fields.object2.name) ) {
|
if ( !deleted.test(scope['activities'][i].summary_fields.object2.name) ) {
|
||||||
href = BuildUrl(scope['activities'][i].summary_fields.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 {
|
||||||
scope['activities'][i].objects += scope['activities'][i].summary_fields.object2.name;
|
scope['activities'][i].objects += "," + scope['activities'][i].summary_fields.object2.name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (scope['activities'][i].object2) {
|
||||||
|
scope['activities'][i].objects += ", " + scope['activities'][i].object1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Description
|
||||||
scope['activities'][i].description = BuildDescription(scope['activities'][i]);
|
scope['activities'][i].description = BuildDescription(scope['activities'][i]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ angular.module('RestServices',['ngCookies','AuthService'])
|
|||||||
.factory('Rest', ['$http','$rootScope','$cookieStore', '$q', 'Authorization',
|
.factory('Rest', ['$http','$rootScope','$cookieStore', '$q', 'Authorization',
|
||||||
function($http, $rootScope, $cookieStore, $q, Authorization) {
|
function($http, $rootScope, $cookieStore, $q, Authorization) {
|
||||||
return {
|
return {
|
||||||
|
|
||||||
|
headers: {},
|
||||||
|
|
||||||
setUrl: function (url) {
|
setUrl: function (url) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
@@ -42,6 +44,13 @@ function($http, $rootScope, $cookieStore, $q, Authorization) {
|
|||||||
};
|
};
|
||||||
return promise;
|
return promise;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setHeader: function(hdr) {
|
||||||
|
// Passin in { key: value } pairs to be added to the header
|
||||||
|
for (var h in hdr) {
|
||||||
|
this.headers[h] = hdr.h;
|
||||||
|
}
|
||||||
|
},
|
||||||
get: function(args) {
|
get: function(args) {
|
||||||
args = (args) ? args : {};
|
args = (args) ? args : {};
|
||||||
this.params = (args.params) ? args.params : null;
|
this.params = (args.params) ? args.params : null;
|
||||||
@@ -52,9 +61,10 @@ function($http, $rootScope, $cookieStore, $q, Authorization) {
|
|||||||
return this.createResponse({ detail: 'Token is expired' }, 401);
|
return this.createResponse({ detail: 'Token is expired' }, 401);
|
||||||
}
|
}
|
||||||
else if (token) {
|
else if (token) {
|
||||||
|
this.setHeader({ Authorization: 'Token ' + token });
|
||||||
return $http({method: 'GET',
|
return $http({method: 'GET',
|
||||||
url: this.url,
|
url: this.url,
|
||||||
headers: { 'Authorization': 'Token ' + token },
|
headers: this.headers,
|
||||||
params: this.params
|
params: this.params
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -477,110 +477,63 @@ 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 html= '';
|
var html= '';
|
||||||
var secondWidget = params.secondWidget;
|
var searchWidgets = (params.searchWidgets) ? params.searchWidgets : 1;
|
||||||
|
|
||||||
html += "<div class=\"row search-widget\">\n";
|
html += "<div class=\"row search-widget\">\n";
|
||||||
html += "<div class=\"";
|
for (var i=1; i <= searchWidgets; i++) {
|
||||||
html += (params.size) ? params.size : "col-lg-4 col-md-6 col-sm-11 col-xs-11";
|
var modifier = (i == 1) ? '' : i;
|
||||||
html += "\" id=\"search-widget-container\">\n";
|
html += "<div class=\"";
|
||||||
html += (form.searchWidgetLabel) ? "<label style=\"display:block\">" + form.searchWidgetLabel +"</label>" : "";
|
html += (params.size) ? params.size : "col-lg-4 col-md-6 col-sm-11 col-xs-11";
|
||||||
html += "<div class=\"input-group";
|
html += "\" id=\"search-widget-container" + modifier + "\">\n";
|
||||||
html += (useMini) ? " input-group-sm" : " input-group-sm";
|
//html += (form.searchWidgetLabel) ? "<label style=\"display:block\">" + form.searchWidgetLabel +"</label>" : "";
|
||||||
html += "\">\n";
|
html += "<div class=\"input-group";
|
||||||
html += "<div class=\"input-group-btn dropdown\">\n";
|
html += (useMini) ? " input-group-sm" : " input-group-sm";
|
||||||
|
html += "\">\n";
|
||||||
html += "<button type=\"button\" ";
|
html += "<div class=\"input-group-btn dropdown\">\n";
|
||||||
html += "id=\"search_field_ddown\" ";
|
|
||||||
html += "class=\"btn ";
|
|
||||||
html += "dropdown-toggle\" data-toggle=\"dropdown\"";
|
|
||||||
html += ">\n";
|
|
||||||
html += "<span ng-bind=\"" + iterator + "SearchFieldLabel\"></span>\n";
|
|
||||||
html += "<span class=\"caret\"></span>\n";
|
|
||||||
html += "</button>\n";
|
|
||||||
|
|
||||||
html += "<ul class=\"dropdown-menu\" id=\"" + iterator + "SearchDropdown\">\n";
|
|
||||||
for ( var fld in form.fields) {
|
|
||||||
if ( (form.fields[fld].searchable == undefined || form.fields[fld].searchable == true)
|
|
||||||
&& (form.fields[fld].searchWidget == undefined || form.fields[fld].searchWidget == 1) ) {
|
|
||||||
html += "<li><a href=\"\" ng-click=\"setSearchField('" + iterator + "','";
|
|
||||||
html += fld + "','";
|
|
||||||
if (form.fields[fld].searchLabel) {
|
|
||||||
html += form.fields[fld].searchLabel + "', 1)\">" +
|
|
||||||
form.fields[fld].searchLabel + "</a></li>\n";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
html += form.fields[fld].label.replace(/\<br\>/g,' ') + "')\">" +
|
|
||||||
form.fields[fld].label.replace(/\<br\>/g,' ') + "</a></li>\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
html += "</ul>\n";
|
|
||||||
html += "</div><!-- input-group-btn -->\n";
|
|
||||||
|
|
||||||
html += "<select id=\"search_value_select\" ng-show=\"" + iterator + "SelectShow\" ng-model=\""+ iterator + "SearchSelectValue\" ng-change=\"search('" + iterator + "')\" ";
|
|
||||||
html += "ng-options=\"c.name for c in " + iterator + "SearchSelectOpts\" class=\"form-control search-select";
|
|
||||||
html += "\"></select>\n";
|
|
||||||
|
|
||||||
html += "<input id=\"search_value_input\" type=\"text\" ng-hide=\"" + iterator + "SelectShow || " + iterator + "InputHide\" class=\"form-control ";
|
|
||||||
html += "\" ng-model=\"" + iterator + "SearchValue\" ng-keydown=\"startSearch('" + iterator + "')\" " +
|
|
||||||
"aw-placeholder=\"" + iterator + "SearchPlaceholder\" type=\"text\" ng-disabled=\"" + iterator + "InputDisable || " + iterator +
|
|
||||||
"HoldInput\">\n";
|
|
||||||
|
|
||||||
// Reset button
|
|
||||||
html += "<div class=\"input-group-btn\">\n";
|
|
||||||
html += "<button type=\"button\" class=\"btn btn-default btn-small\" ng-click=\"resetSearch('" + iterator + "', 1)\" " +
|
|
||||||
"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";
|
|
||||||
|
|
||||||
// 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 += "<button type=\"button\" ";
|
||||||
html += "id=\"search_field_ddown2\" ";
|
html += "id=\"search_field_ddown\" ";
|
||||||
html += "class=\"btn dropdown-toggle\" data-toggle=\"dropdown\">\n";
|
html += "class=\"btn ";
|
||||||
html += "<span ng-bind=\"" + iterator + "SearchFieldLabel2\"></span>\n";
|
html += "dropdown-toggle\" data-toggle=\"dropdown\"";
|
||||||
|
html += ">\n";
|
||||||
|
html += "<span ng-bind=\"" + iterator + "SearchFieldLabel" + modifier + "\"></span>\n";
|
||||||
html += "<span class=\"caret\"></span>\n";
|
html += "<span class=\"caret\"></span>\n";
|
||||||
html += "</button>\n";
|
html += "</button>\n";
|
||||||
|
html += "<ul class=\"dropdown-menu\" id=\"" + iterator + "SearchDropdown" + modifier + "\">\n";
|
||||||
html += "<ul class=\"dropdown-menu\" id=\"" + iterator + "SearchDropdown2\">\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)
|
||||||
&& form.fields[fld].searchWidget == 2 ) {
|
&& (((form.fields[fld].searchWidget == undefined || form.fields[fld].searchWidget == 1) && i == 1 ) ||
|
||||||
|
(form.fields[fld].searchWidget == i)) ) {
|
||||||
html += "<li><a href=\"\" ng-click=\"setSearchField('" + iterator + "','";
|
html += "<li><a href=\"\" ng-click=\"setSearchField('" + iterator + "','";
|
||||||
html += fld + "','";
|
html += fld + "','";
|
||||||
if (form.fields[fld].searchLabel) {
|
if (form.fields[fld].searchLabel) {
|
||||||
html += form.fields[fld].searchLabel + "', 2)\">" +
|
html += form.fields[fld].searchLabel + "', " + i + ")\">" +
|
||||||
form.fields[fld].searchLabel + "</a></li>\n";
|
form.fields[fld].searchLabel + "</a></li>\n";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
html += form.fields[fld].label.replace(/\<br\>/g,' ') + "', 2)\">" +
|
html += form.fields[fld].label.replace(/\<br\>/g,' ') + "', " + i + ")\">" +
|
||||||
form.fields[fld].label.replace(/\<br\>/g,' ') + "</a></li>\n";
|
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";
|
||||||
|
|
||||||
|
html += "<select id=\"search_value_select\" ng-show=\"" + iterator + "SelectShow" + modifier + "\" " +
|
||||||
|
"ng-model=\""+ iterator + "SearchSelectValue" + modifier + "\" ng-change=\"search('" + iterator + "')\" ";
|
||||||
|
html += "ng-options=\"c.name for c in " + iterator + "SearchSelectOpts" + modifier + "\" class=\"form-control search-select";
|
||||||
|
html += "\"></select>\n";
|
||||||
|
|
||||||
html += "<input id=\"search_value_input\" type=\"text\" ng-hide=\"" + iterator + "SelectShow2 || " + iterator + "InputHide2\" class=\"form-control ";
|
html += "<input id=\"search_value_input\" type=\"text\" ng-hide=\"" + iterator + "SelectShow || " + iterator + "InputHide\" " +
|
||||||
html += "\" ng-model=\"" + iterator + "SearchValue2\" ng-keydown=\"startSearch('" + iterator + "')\" " +
|
"class=\"form-control\" ng-model=\"" + iterator + "SearchValue" + modifier + "\" ng-keydown=\"startSearch('" + iterator +
|
||||||
"aw-placeholder=\"" + iterator + "SearchPlaceholder2\" type=\"text\" ng-disabled=\"" + iterator + "InputDisable2 || " + iterator +
|
"')\" aw-placeholder=\"" + iterator + "SearchPlaceholder" + modifier + "\" type=\"text\" ng-disabled=\"" + iterator +
|
||||||
"HoldInput2\">\n";
|
"InputDisable" + modifier + " || " + iterator + "HoldInput" + modifier + "\">\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 + "', 2)\" " +
|
//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";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ 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 });
|
searchWidgets: list.searchWidgets });
|
||||||
}
|
}
|
||||||
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' });
|
||||||
@@ -215,8 +215,9 @@ 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;
|
size = (list.searchWidgets) ? list.searchWidgets * size : size;
|
||||||
html += 'col-lg-' + (11 - size);
|
console.log('size: ' + (12 - size - 1));
|
||||||
|
html += 'col-lg-' + (12 - size - 1);
|
||||||
}
|
}
|
||||||
else if (options.mode == 'summary') {
|
else if (options.mode == 'summary') {
|
||||||
html += 'col-lg-5';
|
html += 'col-lg-5';
|
||||||
|
|||||||
Reference in New Issue
Block a user