changes for the fix in search pages - #6937
This commit is contained in:
parent
7bae78623e
commit
f3a4d7758c
|
@ -1 +1 @@
|
|||
Subproject commit 2007e129664da2e7893aab97b5736cf92585f32d
|
||||
Subproject commit 18dd1379ad151d4988d7c58ae63a8ad8bfad5602
|
|
@ -68,7 +68,7 @@ export class SearchCommunitiesComponent {
|
|||
@ViewChild(NewSearchPageComponent, { static: true }) searchPage: NewSearchPageComponent;
|
||||
private user: User;
|
||||
private userFilterLoaded: boolean = false;
|
||||
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private _communitiesService: CommunitiesService,
|
||||
private userManagementService: UserManagementService) {
|
||||
|
@ -76,25 +76,22 @@ export class SearchCommunitiesComponent {
|
|||
this.errorMessages = new ErrorMessagesComponent();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
}
|
||||
|
||||
|
||||
public ngOnInit() {
|
||||
var firstLoad = true;
|
||||
this.properties = properties;
|
||||
this.piwikSiteId = this.properties.piwikSiteId;
|
||||
this.baseUrl = this.properties.searchLinkToCommunities;
|
||||
|
||||
|
||||
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
||||
this.searchPage.resultsPerPage = 10;
|
||||
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'];
|
||||
this.searchUtils.validateSize(params['size']);
|
||||
this.searchUtils.baseUrl = this.baseUrl;
|
||||
this.searchPage.searchUtils = this.searchUtils;
|
||||
if (this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) {
|
||||
this.searchUtils.size = this.searchPage.resultsPerPage;
|
||||
}
|
||||
if (this.searchUtils.sortBy && this.searchUtils.sortBy != "creationdate,descending" && this.searchUtils.sortBy != "creationdate,ascending") {
|
||||
this.searchUtils.sortBy = "";
|
||||
}
|
||||
|
@ -102,7 +99,7 @@ export class SearchCommunitiesComponent {
|
|||
this.searchLink = this.properties.searchLinkToCommunities;
|
||||
this.selectedFields = [];
|
||||
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap, null, params, "community", null);
|
||||
|
||||
|
||||
let queryParams = params;//this.searchPage.getQueryParamsFromUrl(params);
|
||||
if (typeof document !== 'undefined') {
|
||||
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
||||
|
@ -114,7 +111,7 @@ export class SearchCommunitiesComponent {
|
|||
}
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscriptions.forEach(subscription => {
|
||||
if (subscription instanceof Subscriber) {
|
||||
|
@ -122,7 +119,7 @@ export class SearchCommunitiesComponent {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize communities from Communities APIs
|
||||
*
|
||||
|
@ -156,8 +153,8 @@ export class SearchCommunitiesComponent {
|
|||
}
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get all communities from Communities API and apply permission access validator,
|
||||
* keyword searching, filter, paging and sorting.
|
||||
|
@ -173,7 +170,7 @@ export class SearchCommunitiesComponent {
|
|||
this.searchUtils.totalResults = 0;
|
||||
this.applyParams(params);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the communities in which user has permission to view or manage.
|
||||
*/
|
||||
|
@ -197,7 +194,7 @@ export class SearchCommunitiesComponent {
|
|||
}
|
||||
this.results = ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Apply permission access validator,
|
||||
* keyword searching, filter, paging and sorting.
|
||||
|
@ -232,8 +229,8 @@ export class SearchCommunitiesComponent {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Parse the given keywords into array and check if any of the requirements field of a community includes
|
||||
* one of the given words.
|
||||
|
@ -253,7 +250,7 @@ export class SearchCommunitiesComponent {
|
|||
}
|
||||
this.results = ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check the current results if they satisfy the values of each filter category and
|
||||
* update the number of possible results in each value.
|
||||
|
@ -287,7 +284,7 @@ export class SearchCommunitiesComponent {
|
|||
return roleResults.includes(value);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Apply filter with filterId and return the results
|
||||
*
|
||||
|
@ -351,7 +348,7 @@ export class SearchCommunitiesComponent {
|
|||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reset the values of filter with id filterId with zero.
|
||||
*
|
||||
|
@ -367,7 +364,7 @@ export class SearchCommunitiesComponent {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the values of filter with id filterId based on
|
||||
* results.
|
||||
|
@ -401,7 +398,7 @@ export class SearchCommunitiesComponent {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sorting results based on sortBy.
|
||||
*/
|
||||
|
@ -438,12 +435,12 @@ export class SearchCommunitiesComponent {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private isCommunityManager(community: CommunityInfo): boolean {
|
||||
return Session.isPortalAdministrator(this.user) || Session.isCommunityCurator(this.user) || Session.isManager('community', community.communityId, this.user);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create Search Communities filters.
|
||||
*
|
||||
|
@ -496,9 +493,9 @@ export class SearchCommunitiesComponent {
|
|||
}
|
||||
return filters;
|
||||
}
|
||||
|
||||
|
||||
private handleError(message: string, error) {
|
||||
console.error('Communities Search Page: ' + message, error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import {SearchResult} from "../../openaireLibrary/utils/entities/searchResult";
|
|||
type=" Content provider"
|
||||
[results]="results"
|
||||
[searchUtils]="searchUtils"
|
||||
[sortedByChanged]="searchUtils.sortBy" [resultsPerPageChanged]="searchUtils.size"
|
||||
[sortedByChanged]="searchUtils.sortBy"
|
||||
[fieldIds]="fieldIds" [fieldIdsMap]="fieldIdsMap" [selectedFields]="selectedFields"
|
||||
|
||||
[simpleSearchLink]="properties.searchLinkToDataProviders"
|
||||
|
@ -93,10 +93,7 @@ export class OpenaireSearchDataprovidersComponent {
|
|||
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
||||
let page = (params['page'] === undefined) ? 1 : +params['page'];
|
||||
this.searchUtils.page = (page <= 0) ? 1 : page;
|
||||
this.searchUtils.size = (params['size']=== undefined)?10:+params['size'];
|
||||
if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) {
|
||||
this.searchUtils.size = 10;
|
||||
}
|
||||
this.searchUtils.validateSize(params['size']);
|
||||
this.keyword = decodeURIComponent(params['fv0']?params['fv0']:(params['keyword']?params['keyword']:''));
|
||||
this.selectedFields = [];
|
||||
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, [], [], this.fieldIdsMap, this.customFilter, params, "dataprovider");
|
||||
|
|
|
@ -25,7 +25,7 @@ import {SearchResult} from "../../openaireLibrary/utils/entities/searchResult";
|
|||
type="project"
|
||||
[results]="results"
|
||||
[searchUtils]="searchUtils"
|
||||
[sortedByChanged]="searchUtils.sortBy" [resultsPerPageChanged]="searchUtils.size"
|
||||
[sortedByChanged]="searchUtils.sortBy"
|
||||
[fieldIds]="fieldIds" [fieldIdsMap]="fieldIdsMap" [selectedFields]="selectedFields"
|
||||
|
||||
[simpleSearchLink]="properties.searchLinkToProjects"
|
||||
|
@ -92,10 +92,8 @@ export class OpenaireSearchProjectsComponent {
|
|||
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
||||
let page = (params['page'] === undefined) ? 1 : +params['page'];
|
||||
this.searchUtils.page = (page <= 0) ? 1 : page;
|
||||
this.searchUtils.size = (params['size']=== undefined)?10:+params['size'];
|
||||
if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) {
|
||||
this.searchUtils.size = 10;
|
||||
}
|
||||
this.searchUtils.validateSize(params['size']);
|
||||
|
||||
this.keyword = decodeURIComponent(params['fv0']?params['fv0']:(params['keyword']?params['keyword']:''));
|
||||
this.selectedFields = [];
|
||||
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap, this.customFilter, params, "project");
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit ffc664c3672226fb16eacb4886a3f328f5bf1d33
|
||||
Subproject commit 10dbbb5610afa279837add9be683938e86acd659
|
Loading…
Reference in New Issue