Search stakeholder: add validateSize() for the parameter of results size

This commit is contained in:
argirok 2021-08-13 15:52:49 +03:00
parent a44b4d40ab
commit 386fe30ff7
3 changed files with 23 additions and 26 deletions

@ -1 +1 @@
Subproject commit 410643a682b184f96982bb228657a16769c622ff
Subproject commit 18dd1379ad151d4988d7c58ae63a8ad8bfad5602

View File

@ -64,7 +64,7 @@ export class SearchStakeholdersComponent {
@ViewChild(NewSearchPageComponent, { static: true }) searchPage: NewSearchPageComponent;
private user: User;
private userFilterLoaded: boolean = false;
constructor(private route: ActivatedRoute,
private _stakeholderService: StakeholderService,
private userManagementService: UserManagementService) {
@ -72,7 +72,7 @@ export class SearchStakeholdersComponent {
this.errorMessages = new ErrorMessagesComponent();
this.searchUtils.status = this.errorCodes.LOADING;
}
public ngOnInit() {
this.piwikSiteId = this.properties.piwikSiteId;
this.baseUrl = this.properties.searchLinkToStakeholders;
@ -82,12 +82,9 @@ export class SearchStakeholdersComponent {
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 = "";
}
@ -95,7 +92,7 @@ export class SearchStakeholdersComponent {
this.searchLink = this.properties.searchLinkToStakeholders;
this.selectedFields = [];
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap, null, params, "stakeholder", null);
let queryParams = params;//this.searchPage.getQueryParamsFromUrl(params);
if (typeof document !== 'undefined') {
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
@ -116,7 +113,7 @@ export class SearchStakeholdersComponent {
});
}
/**
* Initialize stakeholders from Communities APIs
*
@ -143,8 +140,8 @@ export class SearchStakeholdersComponent {
}
));
}
/**
* Get all stakeholders from mock API and apply permission access validator,
* keyword searching, filter, paging and sorting.
@ -160,7 +157,7 @@ export class SearchStakeholdersComponent {
this.searchUtils.totalResults = 0;
this.applyParams(params);
}
/**
* Return the stakeholders in which user has permission to view or manage.
*/
@ -175,7 +172,7 @@ export class SearchStakeholdersComponent {
}
this.results = ret;
}
/**
* Apply permission access validator,
* keyword searching, filter, paging and sorting.
@ -210,8 +207,8 @@ export class SearchStakeholdersComponent {
}
}
}
/**
* Parse the given keywords into array and check if any of the requirements field of a funder includes
* one of the given words.
@ -231,7 +228,7 @@ export class SearchStakeholdersComponent {
}
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.
@ -265,7 +262,7 @@ export class SearchStakeholdersComponent {
return roleResults.includes(value);
});
}
/**
* Apply filter with filterId and return the results
*
@ -340,7 +337,7 @@ export class SearchStakeholdersComponent {
}
return results;
}
/**
* Reset the values of filter with id filterId with zero.
*
@ -356,7 +353,7 @@ export class SearchStakeholdersComponent {
}
}
}
/**
* Update the values of filter with id filterId based on
* results.
@ -395,7 +392,7 @@ export class SearchStakeholdersComponent {
}
}
}
/**
* Sorting results based on sortBy.
*/
@ -432,16 +429,16 @@ export class SearchStakeholdersComponent {
})
}
}
private isStakeholderManager(stakeholder) {
return Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user)
|| Session.isCommunityCurator(this.user) || Session.isManager(stakeholder.type, stakeholder.alias, this.user);
}
private isStakeholderMember(stakeholder) {
return this.isStakeholderManager(stakeholder) || Session.isSubscribedTo(stakeholder.type, stakeholder.alias, this.user);
}
/**
* Create Search Stakeholder filters.
*
@ -487,9 +484,9 @@ export class SearchStakeholdersComponent {
}
return filters;
}
private handleError(message: string, error) {
console.error('Communities Search Page: ' + message, error);
}
}

@ -1 +1 @@
Subproject commit 2f572df5783cb32cc84969b75939e45ffce3b424
Subproject commit 10dbbb5610afa279837add9be683938e86acd659