[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:
parent
c179f79f51
commit
5c43afcd9e
|
@ -195,7 +195,7 @@
|
||||||
<div class="uk-card uk-card-default uk-text-center uk-position-relative">
|
<div class="uk-card uk-card-default uk-text-center uk-position-relative">
|
||||||
<div *ngIf="stakeholder.visibility && stakeholder.visibility !== 'PUBLIC'"
|
<div *ngIf="stakeholder.visibility && stakeholder.visibility !== 'PUBLIC'"
|
||||||
class="uk-position-top-right uk-margin-top uk-margin-right uk-flex uk-flex-middle">
|
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>
|
<span class="space uk-text-small uk-text-capitalize">{{stakeholder.visibility.toLowerCase()}}</span>
|
||||||
</div>
|
</div>
|
||||||
<img *ngIf="stakeholder.logoUrl" class="uk-margin-auto" [src]="stakeholder.logoUrl">
|
<img *ngIf="stakeholder.logoUrl" class="uk-margin-auto" [src]="stakeholder.logoUrl">
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
|
||||||
import {UserManagementService} from "../openaireLibrary/services/user-management.service";
|
import {UserManagementService} from "../openaireLibrary/services/user-management.service";
|
||||||
import {StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service";
|
import {StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service";
|
||||||
import {NewSearchPageComponent} from "../openaireLibrary/searchPages/searchUtils/newSearchPage.component";
|
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";
|
import {properties} from "../../environments/environment";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -130,7 +130,8 @@ export class SearchStakeholdersComponent {
|
||||||
}
|
}
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
this.totalResults[i] = data[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);
|
this._getResults(params);
|
||||||
},
|
},
|
||||||
|
@ -168,11 +169,13 @@ export class SearchStakeholdersComponent {
|
||||||
private showFunders() {
|
private showFunders() {
|
||||||
let ret = [];
|
let ret = [];
|
||||||
for (let result of this.results) {
|
for (let result of this.results) {
|
||||||
if (!result.isActive || (!result.isPublic && !this.isStakeholderManager())) {
|
if(result.visibility === 'PUBLIC' ||
|
||||||
continue;
|
(result.visibility === 'RESTRICTED' && this.isStakeholderMember(result)) ||
|
||||||
}
|
(result.visibility === 'PRIVATE' && this.isStakeholderManager(result))
|
||||||
|
) {
|
||||||
ret.push(result);
|
ret.push(result);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.results = ret;
|
this.results = ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,12 +301,17 @@ export class SearchStakeholdersComponent {
|
||||||
} else {
|
} else {
|
||||||
for (let value of values) {
|
for (let value of values) {
|
||||||
if (value.replace(/["']/g, "") == 'public') {
|
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]);
|
results.push(this.results[i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (value.replace(/["']/g, "") == 'private') {
|
} else if (value.replace(/["']/g, "") == 'private') {
|
||||||
if (!this.results[i].isPublic) {
|
if (this.results[i].visibility === 'PRIVATE') {
|
||||||
results.push(this.results[i]);
|
results.push(this.results[i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -323,6 +331,12 @@ export class SearchStakeholdersComponent {
|
||||||
break;
|
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') {
|
} else if (this.filters[i].filterId == 'access') {
|
||||||
if (results[k].isPublic) {
|
if (results[k].visibility === 'PUBLIC') {
|
||||||
this.filters[i].values[0].number++;
|
this.filters[i].values[0].number++;
|
||||||
} else {
|
} else if (results[k].visibility === 'RESTRICTED') {
|
||||||
this.filters[i].values[1].number++;
|
this.filters[i].values[1].number++;
|
||||||
|
} else {
|
||||||
|
this.filters[i].values[2].number++;
|
||||||
}
|
}
|
||||||
} else if (this.filters[i].filterId == 'role') {
|
} else if (this.filters[i].filterId == 'role') {
|
||||||
if (results[k].isManager) {
|
if (results[k].isManager) {
|
||||||
this.filters[i].values[0].number++;
|
this.filters[i].values[0].number++;
|
||||||
}
|
}
|
||||||
|
if (results[k].isMember) {
|
||||||
|
this.filters[i].values[1].number++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -417,8 +436,13 @@ export class SearchStakeholdersComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private isStakeholderManager() {
|
private isStakeholderManager(stakeholder) {
|
||||||
return Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user) || Session.isCommunityCurator(this.user);
|
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) {
|
if (this.user) {
|
||||||
filter_names.push("Accessibility");
|
filter_names.push("Accessibility");
|
||||||
filter_ids.push("access");
|
filter_ids.push("access");
|
||||||
value_names.push(["Public", "Private"]);
|
value_names.push(["Public", "Restricted", "Private"]);
|
||||||
value_original_ids.push(["public", "private"]);
|
value_original_ids.push(["public", "restricted", "private"]);
|
||||||
filter_names.push("Role");
|
filter_names.push("Role");
|
||||||
filter_ids.push("role");
|
filter_ids.push("role");
|
||||||
value_names.push(["Manager"]);
|
value_names.push(["Manager", "Member"]);
|
||||||
value_original_ids.push(["manager"]);
|
value_original_ids.push(["manager", "member"]);
|
||||||
this.userFilterLoaded = true;
|
this.userFilterLoaded = true;
|
||||||
}
|
}
|
||||||
let filters: Filter[] = [];
|
let filters: Filter[] = [];
|
||||||
|
|
Loading…
Reference in New Issue