[Connect |Trunk]

Fixing issues with Communities search (new search component update)



git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@58577 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2020-04-29 07:53:37 +00:00
parent 960f9b7839
commit f12abdcd8d
1 changed files with 12 additions and 6 deletions

View File

@ -54,7 +54,8 @@ export class SearchCommunitiesComponent {
public fieldIds: string[] = ["q"];
public refineFields: string[] = this.searchFields.COMMUNITIES_SEARCH_FIELDS;
public fieldIdsMap = {["q"]:{name:"All fields", type:"keyword", param:"q", operator: "op", equalityOperator: "=", filterType: null}};
public selectedFields: AdvancedField[] = [new AdvancedField(this.fieldIds[0], "", this.fieldIdsMap[this.fieldIds[0]].name, this.fieldIdsMap[this.fieldIds[0]].type,"", "and")];
public selectedFields: AdvancedField[] = [];//[new AdvancedField(this.fieldIds[0], "", this.fieldIdsMap[this.fieldIds[0]].name, this.fieldIdsMap[this.fieldIds[0]].type,"", "and")];
public keyword = "";
public searchLink;
public showType = false;
public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'communities'}];
@ -72,6 +73,7 @@ export class SearchCommunitiesComponent {
}
public ngOnInit() {
var firstLoad = true;
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
@ -80,7 +82,10 @@ export class SearchCommunitiesComponent {
});
this.sub = this.route.queryParams.subscribe(params => {
this.searchPage.resultsPerPage = 10;
this.searchUtils.keyword = (params['fv0']?params['fv0']:'');
// this.searchUtils.keyword = (params['fv0']?params['fv0']:'');
// this.searchUtils.keyword = StringUtils.URIDecode(this.searchUtils.keyword);
this.keyword = (params['fv0']?params['fv0']:'');
this.keyword = StringUtils.URIDecode(this.keyword);
this.searchUtils.page = (params['page'] === undefined) ? 1: + params['page'];
this.searchUtils.sortBy = (params['sortBy'] === undefined)? '' : params['sortBy'];
this.searchUtils.size = (params['size'] === undefined) ? this.searchPage.resultsPerPage: +params['size'];
@ -94,7 +99,7 @@ export class SearchCommunitiesComponent {
}
this.searchPage.refineFields = this.refineFields;
this.searchLink = this.properties.searchLinkToCommunities;
this.selectedFields[0] = new AdvancedField(this.fieldIds[0], "", this.fieldIdsMap[this.fieldIds[0]].name, this.fieldIdsMap[this.fieldIds[0]].type,this.searchUtils.keyword, "and");
this.selectedFields = [];
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields,[], this.fieldIdsMap,null,params, "community", null);
let queryParams = params;//this.searchPage.getQueryParamsFromUrl(params);
@ -212,7 +217,7 @@ export class SearchCommunitiesComponent {
*/
public applyParams(params: Map<string, string>) {
this.showCommunities();
if(this.searchUtils.keyword && this.searchUtils.keyword != '') {
if(this.keyword && this.keyword != '') {
this.searchForKeywords();
}
this.checkFilters(params);
@ -221,7 +226,8 @@ export class SearchCommunitiesComponent {
// this.searchPage.checkSelectedFilters(this.filters);
// this.searchPage.updateBaseUrlWithParameters(this.filters);
// this.searchPage.buildPageURLParameters(this.filters, [], false);
this.filters = this.searchPage.prepareFiltersToShow(this.filters,this.searchUtils.totalResults);
// this.filters =
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;
@ -250,7 +256,7 @@ export class SearchCommunitiesComponent {
*/
private searchForKeywords() {
let ret: CommunityInfo[] = [];
let keywords: string[] = this.searchUtils.keyword.split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1);
let keywords: string[] = this.keyword.split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1);
for(let i = 0; i < this.results.length; i++) {
for(let keyword of keywords) {
keyword = keyword.toLowerCase();