Commit 8197216c authored by jgould's avatar jgould

bold matches

parent 0673ed52
...@@ -37,7 +37,7 @@ morpheus.MetadataUtil.search = function (options) { ...@@ -37,7 +37,7 @@ morpheus.MetadataUtil.search = function (options) {
var isColumns = options.isColumns; var isColumns = options.isColumns;
text = $.trim(text); text = $.trim(text);
if (text === '') { if (text === '') {
return null; return null;
} }
var tokens = morpheus.Util.getAutocompleteTokens(text); var tokens = morpheus.Util.getAutocompleteTokens(text);
if (tokens.length == 0) { if (tokens.length == 0) {
...@@ -162,6 +162,7 @@ morpheus.MetadataUtil.autocomplete = function (model) { ...@@ -162,6 +162,7 @@ morpheus.MetadataUtil.autocomplete = function (model) {
// check for term:searchText // check for term:searchText
var matches = []; var matches = [];
var regex = null; var regex = null;
var regexMatch = null;
var searchModel = model; var searchModel = model;
var token = tokens != null && tokens.length > 0 ? tokens[tokens.selectionStartIndex] var token = tokens != null && tokens.length > 0 ? tokens[tokens.selectionStartIndex]
: ''; : '';
...@@ -192,7 +193,8 @@ morpheus.MetadataUtil.autocomplete = function (model) { ...@@ -192,7 +193,8 @@ morpheus.MetadataUtil.autocomplete = function (model) {
var set = new morpheus.Set(); var set = new morpheus.Set();
// regex used to determine if a string starts with substring `q` // regex used to determine if a string starts with substring `q`
regex = new RegExp('^' + morpheus.Util.escapeRegex(token), 'i'); regex = new RegExp(morpheus.Util.escapeRegex(token), 'i');
regexMatch = new RegExp('(' + morpheus.Util.escapeRegex(token) + ')', 'i');
// iterate through the pool of strings and for any string that // iterate through the pool of strings and for any string that
// contains the substring `q`, add it to the `matches` array // contains the substring `q`, add it to the `matches` array
var max = 10; var max = 10;
...@@ -259,7 +261,7 @@ morpheus.MetadataUtil.autocomplete = function (model) { ...@@ -259,7 +261,7 @@ morpheus.MetadataUtil.autocomplete = function (model) {
value: quotedField + ':' + quotedValue, value: quotedField + ':' + quotedValue,
label: '<span style="font-weight:300;">' + field label: '<span style="font-weight:300;">' + field
+ ':</span>' + ':</span>'
+ '<span style="font-weight:900;">' + val + '<span>' + val.replace(regexMatch, '<b>$1</b>')
+ '</span>' + '</span>'
}); });
...@@ -272,6 +274,7 @@ morpheus.MetadataUtil.autocomplete = function (model) { ...@@ -272,6 +274,7 @@ morpheus.MetadataUtil.autocomplete = function (model) {
if (regex == null) { if (regex == null) {
regex = new RegExp('.*', 'i'); regex = new RegExp('.*', 'i');
} }
for (var j = 0; j < searchModel.getMetadataCount(); j++) { for (var j = 0; j < searchModel.getMetadataCount(); j++) {
var v = searchModel.get(j); var v = searchModel.get(j);
var dataType = morpheus.VectorUtil.getDataType(v); var dataType = morpheus.VectorUtil.getDataType(v);
...@@ -285,7 +288,7 @@ morpheus.MetadataUtil.autocomplete = function (model) { ...@@ -285,7 +288,7 @@ morpheus.MetadataUtil.autocomplete = function (model) {
} }
matches.push({ matches.push({
value: quotedField + ':', value: quotedField + ':',
label: '<span style="font-weight:300;">' + field label: '<span style="font-weight:300;">' + (regexMatch == null ? field : field.replace(regexMatch, '<b>$1</b>'))
+ ':</span>', + ':</span>',
show: true show: true
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment