mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-03 21:49:23 +08:00
Merge pull request #1238 from ZmagoD/zd_SCI_2511
fixes smart annotation serch queries/dropdown item picker [fixes SCI-…
This commit is contained in:
commit
752fb8dcd8
3 changed files with 26 additions and 5 deletions
|
@ -352,7 +352,23 @@ var SmartAnnotation = (function() {
|
|||
},
|
||||
beforeInsert: function(value, li) {
|
||||
return _generateInputTag(value, li);
|
||||
}
|
||||
},
|
||||
matcher:function(flag, subtext, should_startWithSpace, acceptSpaceBar) {
|
||||
var _a, _y, match, regexp, space;
|
||||
flag = flag.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
||||
if (should_startWithSpace) {
|
||||
flag = '(?:^|\\s)' + flag;
|
||||
}
|
||||
_a = decodeURI("%C3%80");
|
||||
_y = decodeURI("%C3%BF");
|
||||
regexp = new RegExp(flag + "([A-Za-z" + _a + "-" + _y + "0-9_\\s\+\-\]*)$|" + flag + "([^\\x00-\\xff]*)$", 'gi');
|
||||
match = regexp.exec(subtext);
|
||||
if (match) {
|
||||
return match[2] || match[1];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
},
|
||||
headerTpl: generateFilterMenu(defaultFilterType),
|
||||
limit: <%= Constants::ATWHO_SEARCH_LIMIT %>,
|
||||
|
|
|
@ -21,17 +21,22 @@ module SearchableModel
|
|||
end
|
||||
|
||||
if options[:whole_word].to_s == 'true' ||
|
||||
options[:whole_phrase].to_s == 'true'
|
||||
options[:whole_phrase].to_s == 'true' ||
|
||||
options[:at_search].to_s == 'true'
|
||||
unless attrs.empty?
|
||||
like = options[:match_case].to_s == 'true' ? '~' : '~*'
|
||||
like = 'SIMILAR TO' if options[:at_search].to_s == 'true'
|
||||
|
||||
if options[:whole_word].to_s == 'true'
|
||||
a_query = query.split
|
||||
.map { |a| Regexp.escape(a) }
|
||||
.join('|')
|
||||
elsif options[:at_search].to_s == 'true'
|
||||
a_query = "%#{Regexp.escape(query).downcase}%"
|
||||
else
|
||||
a_query = Regexp.escape(query)
|
||||
end
|
||||
|
||||
# quick fix to enable searching by repositoy_row id
|
||||
id_index = { present: false }
|
||||
where_str =
|
||||
|
@ -40,7 +45,8 @@ module SearchableModel
|
|||
id_index = { present: true, val: i }
|
||||
"(#{a}) = :t#{i} OR "
|
||||
else
|
||||
"(trim_html_tags(#{a})) #{like} :t#{i} OR "
|
||||
col = options[:at_search].to_s == 'true' ? "lower(#{a})": a
|
||||
"(trim_html_tags(#{col})) #{like} :t#{i} OR "
|
||||
end
|
||||
end
|
||||
).join[0..-5]
|
||||
|
@ -53,7 +59,6 @@ module SearchableModel
|
|||
end
|
||||
end
|
||||
).to_h
|
||||
|
||||
return where(where_str, vals)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -101,7 +101,7 @@ class SmartAnnotation
|
|||
def repository_rows(repository)
|
||||
res = RepositoryRow
|
||||
.where(repository: repository)
|
||||
.where_attributes_like('name', @query)
|
||||
.where_attributes_like('name', @query, at_search: true)
|
||||
.limit(Constants::ATWHO_SEARCH_LIMIT)
|
||||
rep_items_list = []
|
||||
splitted_name = repository.name.gsub(/[^0-9a-z ]/i, '').split
|
||||
|
|
Loading…
Reference in a new issue