Change filters in order to be the same with stakeholders
This commit is contained in:
parent
3786d98ec5
commit
89810c107b
|
@ -1 +1 @@
|
|||
Subproject commit 02efeb40382226445223ad82088b8387a2368180
|
||||
Subproject commit 104c54a3e861d65817aac59c56640457664eeaab
|
|
@ -30,7 +30,8 @@ import {Subscriber} from "rxjs";
|
|||
[showIndexInfo]=false
|
||||
[simpleView]="true"
|
||||
[fieldIds]="fieldIds" [fieldIdsMap]="fieldIdsMap" [selectedFields]="selectedFields"
|
||||
[simpleSearchLink]="searchLink" [entitiesSelection]="false" [showBreadcrumb]="true" [basicMetaDescription]="['Research communities', 'Discover OpenAIRE research gateways for research communities.']">
|
||||
[simpleSearchLink]="searchLink" [entitiesSelection]="false" [showBreadcrumb]="true"
|
||||
[basicMetaDescription]="['Research communities', 'Discover OpenAIRE research gateways for research communities.']">
|
||||
</new-search-page>
|
||||
`
|
||||
})
|
||||
|
@ -64,10 +65,10 @@ export class SearchCommunitiesComponent {
|
|||
public showType = false;
|
||||
public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'communities'}];
|
||||
properties: EnvProperties;
|
||||
@ViewChild(NewSearchPageComponent, { static: true }) searchPage: NewSearchPageComponent;
|
||||
@ViewChild(NewSearchPageComponent, {static: true}) searchPage: NewSearchPageComponent;
|
||||
private user: User;
|
||||
private userFilterLoaded: boolean = false;
|
||||
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private _communitiesService: CommunitiesService,
|
||||
private userManagementService: UserManagementService) {
|
||||
|
@ -75,7 +76,7 @@ export class SearchCommunitiesComponent {
|
|||
this.errorMessages = new ErrorMessagesComponent();
|
||||
this.searchUtils.status = this.errorCodes.LOADING;
|
||||
}
|
||||
|
||||
|
||||
public ngOnInit() {
|
||||
this.properties = properties;
|
||||
this.piwikSiteId = this.properties.piwikSiteId;
|
||||
|
@ -96,7 +97,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;
|
||||
if (typeof document !== 'undefined') {
|
||||
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
||||
|
@ -108,7 +109,7 @@ export class SearchCommunitiesComponent {
|
|||
}
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscriptions.forEach(subscription => {
|
||||
if (subscription instanceof Subscriber) {
|
||||
|
@ -116,7 +117,7 @@ export class SearchCommunitiesComponent {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize communities from Communities APIs
|
||||
*
|
||||
|
@ -130,12 +131,8 @@ export class SearchCommunitiesComponent {
|
|||
}
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
this.totalResults[i] = data[i];
|
||||
this.totalResults[i].isManager = false;
|
||||
this.totalResults[i].isSubscribed = false;
|
||||
if (this.user) {
|
||||
this.totalResults[i].isManager = this.isCommunityManager(this.totalResults[i]);
|
||||
this.totalResults[i].isSubscribed = Session.isSubscribedTo('community', this.totalResults[i].communityId, this.user);
|
||||
}
|
||||
this.totalResults[i].isManager = this.isCommunityManager(this.totalResults[i]);
|
||||
this.totalResults[i].isSubscribed = Session.isSubscribedTo('community', this.totalResults[i].communityId, this.user);
|
||||
}
|
||||
this._getResults(params);
|
||||
},
|
||||
|
@ -146,8 +143,8 @@ export class SearchCommunitiesComponent {
|
|||
}
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get all communities from Communities API and apply permission access validator,
|
||||
* keyword searching, filter, paging and sorting.
|
||||
|
@ -163,7 +160,7 @@ export class SearchCommunitiesComponent {
|
|||
this.searchUtils.totalResults = 0;
|
||||
this.applyParams(params);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the communities in which user has permission to view or manage.
|
||||
*/
|
||||
|
@ -178,7 +175,7 @@ export class SearchCommunitiesComponent {
|
|||
}
|
||||
this.results = ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Apply permission access validator,
|
||||
* keyword searching, filter, paging and sorting.
|
||||
|
@ -212,8 +209,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.
|
||||
|
@ -233,7 +230,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.
|
||||
|
@ -242,32 +239,31 @@ export class SearchCommunitiesComponent {
|
|||
*/
|
||||
private checkFilters(params) {
|
||||
let typeResults: CommunityInfo[] = this.applyFilter('type', params);
|
||||
let statusResults: CommunityInfo[] = this.results;
|
||||
let accessResults: CommunityInfo[] = this.applyFilter('access', params);
|
||||
let roleResults: CommunityInfo[] = this.results;
|
||||
if (this.user) {
|
||||
statusResults = this.applyFilter('status', params);
|
||||
roleResults = this.applyFilter('role', params);
|
||||
this.resetFilterNumbers('status');
|
||||
this.updateFilterNumbers(typeResults.filter(value => {
|
||||
return roleResults.includes(value);
|
||||
}), 'status');
|
||||
this.resetFilterNumbers('role');
|
||||
this.updateFilterNumbers(statusResults.filter(value => {
|
||||
this.updateFilterNumbers(accessResults.filter(value => {
|
||||
return typeResults.includes(value);
|
||||
}), 'role');
|
||||
}
|
||||
this.resetFilterNumbers('access');
|
||||
this.updateFilterNumbers(typeResults.filter(value => {
|
||||
return roleResults.includes(value);
|
||||
}), 'access');
|
||||
this.resetFilterNumbers('type');
|
||||
this.updateFilterNumbers(statusResults.filter(value => {
|
||||
this.updateFilterNumbers(accessResults.filter(value => {
|
||||
return roleResults.includes(value);
|
||||
}), 'type');
|
||||
this.results = statusResults.filter(value => {
|
||||
this.results = accessResults.filter(value => {
|
||||
return typeResults.includes(value);
|
||||
})
|
||||
this.results = this.results.filter(value => {
|
||||
return roleResults.includes(value);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Apply filter with filterId and return the results
|
||||
*
|
||||
|
@ -293,19 +289,24 @@ export class SearchCommunitiesComponent {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if (filterId == 'status') {
|
||||
} else if (filterId == 'access') {
|
||||
for (let i = 0; i < this.results.length; i++) {
|
||||
if (values.length == 0) {
|
||||
results.push(this.results[i]);
|
||||
} else {
|
||||
for (let value of values) {
|
||||
if (value.replace(/["']/g, "") == 'subscribed') {
|
||||
if (this.results[i].isSubscribed) {
|
||||
if (value.replace(/["']/g, "") == 'public') {
|
||||
if (this.results[i].status === 'all') {
|
||||
results.push(this.results[i]);
|
||||
break;
|
||||
}
|
||||
} else if (value.replace(/["']/g, "") == 'nonsubscribed') {
|
||||
if (!this.results[i].isSubscribed) {
|
||||
} else if (value.replace(/["']/g, "") == 'restricted') {
|
||||
if (this.results[i].status === 'manager') {
|
||||
results.push(this.results[i]);
|
||||
break;
|
||||
}
|
||||
} else if (value.replace(/["']/g, "") == 'private') {
|
||||
if (this.results[i].status === 'hidden') {
|
||||
results.push(this.results[i]);
|
||||
break;
|
||||
}
|
||||
|
@ -325,13 +326,19 @@ export class SearchCommunitiesComponent {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (value.replace(/["']/g, "") == 'subscriber') {
|
||||
if (this.results[i].isSubscribed) {
|
||||
results.push(this.results[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reset the values of filter with id filterId with zero.
|
||||
*
|
||||
|
@ -347,7 +354,7 @@ export class SearchCommunitiesComponent {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the values of filter with id filterId based on
|
||||
* results.
|
||||
|
@ -365,23 +372,28 @@ export class SearchCommunitiesComponent {
|
|||
this.filters[i].values[j].number++;
|
||||
}
|
||||
}
|
||||
} else if (this.filters[i].filterId == 'status') {
|
||||
if (results[k].isSubscribed) {
|
||||
} else if (this.filters[i].filterId == 'access') {
|
||||
if (results[k].status === 'all') {
|
||||
this.filters[i].values[0].number++;
|
||||
} else {
|
||||
} else if (results[k].status === 'manager') {
|
||||
this.filters[i].values[1].number++;
|
||||
} else if (this.user) {
|
||||
this.filters[i].values[2].number++;
|
||||
}
|
||||
} else if (this.filters[i].filterId == 'role') {
|
||||
if (results[k].isManager) {
|
||||
this.filters[i].values[0].number++;
|
||||
}
|
||||
if (results[k].isSubscribed) {
|
||||
this.filters[i].values[1].number++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sorting results based on sortBy.
|
||||
*/
|
||||
|
@ -418,12 +430,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.
|
||||
*
|
||||
|
@ -444,16 +456,18 @@ export class SearchCommunitiesComponent {
|
|||
} else {
|
||||
filter_original_ids = searchFields.COMMUNITIES_SEARCH_FIELDS.splice(0, 1);
|
||||
}
|
||||
if (this.user) {
|
||||
filter_names.push("Status");
|
||||
filter_ids.push("status");
|
||||
value_names.push(["Subscribed", "Non-subscribed"]);
|
||||
value_original_ids.push(["subscribed", "nonsubscribed"]);
|
||||
filter_names.push("Accessibility");
|
||||
filter_ids.push("access");
|
||||
if (!this.user) {
|
||||
value_names.push(["Public", "Restricted"]);
|
||||
value_original_ids.push(["public", "restricted"]);
|
||||
} else {
|
||||
value_names.push(["Public", "Restricted", "Private"]);
|
||||
value_original_ids.push(["public", "restricted", "private"]);
|
||||
filter_names.push("Role");
|
||||
filter_ids.push("role");
|
||||
value_names.push(["Manager"]);
|
||||
value_original_ids.push(["manager"]);
|
||||
this.userFilterLoaded = true;
|
||||
value_names.push(["Manager", "Subscriber"]);
|
||||
value_original_ids.push(["manager", "subscriber"]);
|
||||
}
|
||||
let filters: Filter[] = [];
|
||||
for (let i = 0; i < filter_names.length; i++) {
|
||||
|
@ -476,9 +490,9 @@ export class SearchCommunitiesComponent {
|
|||
}
|
||||
return filters;
|
||||
}
|
||||
|
||||
|
||||
private handleError(message: string, error) {
|
||||
console.error('Communities Search Page: ' + message, error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue