[Monitor | Trunk]: Fix visibility for stakeholders search page

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor@59740 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
Konstantinos Triantafyllou 2020-11-02 16:55:32 +00:00
parent c179f79f51
commit 5c43afcd9e
2 changed files with 40 additions and 16 deletions

View File

@ -195,7 +195,7 @@
<div class="uk-card uk-card-default uk-text-center uk-position-relative">
<div *ngIf="stakeholder.visibility && stakeholder.visibility !== 'PUBLIC'"
class="uk-position-top-right uk-margin-top uk-margin-right uk-flex uk-flex-middle">
<icon [name]="visibilityIcon.get(stakeholder.visibility)" [flex]="true"></icon>
<icon [name]="visibilityIcon.get(stakeholder.visibility)"></icon>
<span class="space uk-text-small uk-text-capitalize">{{stakeholder.visibility.toLowerCase()}}</span>
</div>
<img *ngIf="stakeholder.logoUrl" class="uk-margin-auto" [src]="stakeholder.logoUrl">

View File

@ -12,7 +12,7 @@ import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
import {UserManagementService} from "../openaireLibrary/services/user-management.service";
import {StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service";
import {NewSearchPageComponent} from "../openaireLibrary/searchPages/searchUtils/newSearchPage.component";
import {StakeholderInfo} from "../openaireLibrary/monitor/entities/stakeholder";
import {Stakeholder, StakeholderInfo} from "../openaireLibrary/monitor/entities/stakeholder";
import {properties} from "../../environments/environment";
@Component({
@ -130,7 +130,8 @@ export class SearchStakeholdersComponent {
}
for (let i = 0; i < data.length; i++) {
this.totalResults[i] = data[i];
this.totalResults[i].isManager = this.isStakeholderManager();
this.totalResults[i].isManager = this.isStakeholderManager(data);
this.totalResults[i].isMember = this.isStakeholderMember(data);
}
this._getResults(params);
},
@ -168,10 +169,12 @@ export class SearchStakeholdersComponent {
private showFunders() {
let ret = [];
for (let result of this.results) {
if (!result.isActive || (!result.isPublic && !this.isStakeholderManager())) {
continue;
if(result.visibility === 'PUBLIC' ||
(result.visibility === 'RESTRICTED' && this.isStakeholderMember(result)) ||
(result.visibility === 'PRIVATE' && this.isStakeholderManager(result))
) {
ret.push(result);
}
ret.push(result);
}
this.results = ret;
}
@ -298,12 +301,17 @@ export class SearchStakeholdersComponent {
} else {
for (let value of values) {
if (value.replace(/["']/g, "") == 'public') {
if (this.results[i].isPublic) {
if (this.results[i].visibility === 'PUBLIC') {
results.push(this.results[i]);
break;
}
} else if (value.replace(/["']/g, "") == 'restricted') {
if (this.results[i].visibility === 'RESTRICTED') {
results.push(this.results[i]);
break;
}
} else if (value.replace(/["']/g, "") == 'private') {
if (!this.results[i].isPublic) {
if (this.results[i].visibility === 'PRIVATE') {
results.push(this.results[i]);
break;
}
@ -323,6 +331,12 @@ export class SearchStakeholdersComponent {
break;
}
}
if (value.replace(/["']/g, "") == 'member') {
if (this.results[i].isMember) {
results.push(this.results[i]);
break;
}
}
}
}
}
@ -364,15 +378,20 @@ export class SearchStakeholdersComponent {
}
}
} else if (this.filters[i].filterId == 'access') {
if (results[k].isPublic) {
if (results[k].visibility === 'PUBLIC') {
this.filters[i].values[0].number++;
} else {
} else if (results[k].visibility === 'RESTRICTED') {
this.filters[i].values[1].number++;
} else {
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].isMember) {
this.filters[i].values[1].number++;
}
}
break;
}
@ -417,8 +436,13 @@ export class SearchStakeholdersComponent {
}
}
private isStakeholderManager() {
return Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user) || Session.isCommunityCurator(this.user);
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);
}
/**
@ -437,12 +461,12 @@ export class SearchStakeholdersComponent {
if (this.user) {
filter_names.push("Accessibility");
filter_ids.push("access");
value_names.push(["Public", "Private"]);
value_original_ids.push(["public", "private"]);
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"]);
value_names.push(["Manager", "Member"]);
value_original_ids.push(["manager", "member"]);
this.userFilterLoaded = true;
}
let filters: Filter[] = [];