[Connect | Trunk]: Use method containsWord for search keyword on search communities

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@58863 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2020-06-05 13:03:25 +00:00
parent 5a9abc0252
commit 937bd0fb80
1 changed files with 5 additions and 7 deletions

View File

@ -176,7 +176,7 @@ export class SearchCommunitiesComponent {
* @param params, status
* @private
*/
private _getResults(params: Map<string, string>) {
private _getResults(params) {
this.searchUtils.status = this.errorCodes.LOADING;
this.disableForms = true;
this.results = this.totalResults;
@ -227,7 +227,6 @@ export class SearchCommunitiesComponent {
this.sort();
this.searchUtils.totalResults = this.results.length;
this.searchPage.prepareFiltersToShow(this.filters, this.searchUtils.totalResults);
this.results = this.results.slice((this.searchUtils.page - 1) * this.searchUtils.size, (this.searchUtils.page * this.searchUtils.size));
this.searchUtils.status = this.errorCodes.DONE;
if (this.searchUtils.totalResults == 0) {
@ -245,7 +244,6 @@ export class SearchCommunitiesComponent {
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
}
}
HelperFunctions.scroll();
}
@ -259,8 +257,8 @@ export class SearchCommunitiesComponent {
for (let i = 0; i < this.results.length; i++) {
for (let keyword of keywords) {
keyword = keyword.toLowerCase();
if (keyword != '' && (this.results[i].title.toLowerCase().includes(keyword) || this.results[i].shortTitle.toLowerCase().includes(keyword) ||
this.results[i].communityId.toLowerCase().includes(keyword) || this.results[i].description.toLowerCase().includes(keyword))) {
if (keyword != '' && (StringUtils.containsWord(this.results[i].title, keyword) || StringUtils.containsWord(this.results[i].shortTitle, keyword) ||
StringUtils.containsWord(this.results[i].communityId, keyword) || StringUtils.containsWord(this.results[i].description, keyword))) {
ret.push(this.results[i]);
break;
}
@ -275,7 +273,7 @@ export class SearchCommunitiesComponent {
*
* @param params
*/
private checkFilters(params: Map<string, string>) {
private checkFilters(params) {
let typeResults: CommunityInfo[] = this.applyFilter('type', params);
let statusResults: CommunityInfo[] = this.results;
let roleResults: CommunityInfo[] = this.results;
@ -312,7 +310,7 @@ export class SearchCommunitiesComponent {
private applyFilter(filterId: string, params): CommunityInfo[] {
let results: CommunityInfo[] = [];
let values: string[] = [];
if (params[filterId] != undefined) {
if (params[filterId]) {
values = (StringUtils.URIDecode(params[filterId])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, -1);
}
if (filterId == 'type') {