Merge pull request #1181 from girishso/star-search2
PLT-747: Allow search results to match portions of words
Этот коммит содержится в:
@@ -105,8 +105,15 @@ export default class SearchBar extends React.Component {
|
|||||||
performSearch(terms, isMentionSearch) {
|
performSearch(terms, isMentionSearch) {
|
||||||
if (terms.length) {
|
if (terms.length) {
|
||||||
this.setState({isSearching: true});
|
this.setState({isSearching: true});
|
||||||
|
|
||||||
|
// append * if not present
|
||||||
|
let searchTerms = terms;
|
||||||
|
if (searchTerms.search(/\*\s*$/) === -1) {
|
||||||
|
searchTerms = searchTerms + '*';
|
||||||
|
}
|
||||||
|
|
||||||
client.search(
|
client.search(
|
||||||
terms,
|
searchTerms,
|
||||||
(data) => {
|
(data) => {
|
||||||
this.setState({isSearching: false});
|
this.setState({isSearching: false});
|
||||||
if (utils.isMobile()) {
|
if (utils.isMobile()) {
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ function highlightSearchTerm(text, tokens, searchTerm) {
|
|||||||
|
|
||||||
var newTokens = new Map();
|
var newTokens = new Map();
|
||||||
for (const [alias, token] of tokens) {
|
for (const [alias, token] of tokens) {
|
||||||
if (token.originalText === searchTerm) {
|
if (token.originalText.indexOf(searchTerm.replace(/\*$/, '')) > -1) {
|
||||||
const index = tokens.size + newTokens.size;
|
const index = tokens.size + newTokens.size;
|
||||||
const newAlias = `MM_SEARCHTERM${index}`;
|
const newAlias = `MM_SEARCHTERM${index}`;
|
||||||
|
|
||||||
@@ -276,7 +276,7 @@ function highlightSearchTerm(text, tokens, searchTerm) {
|
|||||||
return prefix + alias;
|
return prefix + alias;
|
||||||
}
|
}
|
||||||
|
|
||||||
return output.replace(new RegExp(`(^|\\W)(${searchTerm})\\b`, 'gi'), replaceSearchTermWithToken);
|
return output.replace(new RegExp(`()(${searchTerm})`, 'gi'), replaceSearchTermWithToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
function replaceTokens(text, tokens) {
|
function replaceTokens(text, tokens) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user