[monitor-admin-library | DONE | CHANGED]: Make stakeholder types dynamic for Session methods.
This commit is contained in:
parent
1710819fb9
commit
b67c242fe7
|
@ -1,3 +1,5 @@
|
||||||
|
import {stakeholderTypes} from "../../monitor/entities/stakeholder";
|
||||||
|
|
||||||
export class User {
|
export class User {
|
||||||
email: string;
|
email: string;
|
||||||
firstname: string;
|
firstname: string;
|
||||||
|
@ -98,23 +100,11 @@ export class Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static isMonitorCurator(user: User): boolean {
|
public static isMonitorCurator(user: User): boolean {
|
||||||
return this.isCommunityCurator(user) || this.isProjectCurator(user) || this.isFunderCurator(user) || this.isOrganizationCurator(user);
|
return stakeholderTypes.filter(stakeholderType => this.isTypeCurator(stakeholderType.value, user)).length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static isCommunityCurator(user: User): boolean {
|
public static isCommunityCurator(user: User): boolean {
|
||||||
return this.isTypeCurator("Community", user);
|
return this.isTypeCurator("community", user);
|
||||||
}
|
|
||||||
|
|
||||||
public static isFunderCurator(user: User): boolean {
|
|
||||||
return this.isTypeCurator("Funder", user);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static isProjectCurator(user: User): boolean {
|
|
||||||
return this.isTypeCurator("Project", user);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static isOrganizationCurator(user: User): boolean {
|
|
||||||
return this.isTypeCurator("Institution", user);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static isTypeCurator(type: string, user: User): boolean {
|
private static isTypeCurator(type: string, user: User): boolean {
|
||||||
|
@ -122,16 +112,7 @@ export class Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static isCurator(type: string, user: User): boolean {
|
public static isCurator(type: string, user: User): boolean {
|
||||||
if (type == 'funder') {
|
return stakeholderTypes.find(stakeholderType => stakeholderType.value == type) && this.isTypeCurator(type, user);
|
||||||
return user && this.isFunderCurator(user);
|
|
||||||
} else if (type == 'ri' || type == 'community') {
|
|
||||||
return user && this.isCommunityCurator(user);
|
|
||||||
} else if (type == 'organization' || type == 'institution') {
|
|
||||||
return user && this.isOrganizationCurator(user);
|
|
||||||
} else if (type == 'project') {
|
|
||||||
return user && this.isProjectCurator(user);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static isPortalAdministrator(user: User): boolean {
|
public static isPortalAdministrator(user: User): boolean {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import {
|
||||||
Stakeholder,
|
Stakeholder,
|
||||||
StakeholderEntities,
|
StakeholderEntities,
|
||||||
SubCategory,
|
SubCategory,
|
||||||
Topic,
|
Topic, stakeholderTypes,
|
||||||
Visibility
|
Visibility
|
||||||
} from "../../monitor/entities/stakeholder";
|
} from "../../monitor/entities/stakeholder";
|
||||||
import {AbstractControl, ValidatorFn, Validators} from "@angular/forms";
|
import {AbstractControl, ValidatorFn, Validators} from "@angular/forms";
|
||||||
|
@ -28,10 +28,7 @@ export class StakeholderUtils {
|
||||||
];
|
];
|
||||||
|
|
||||||
types: Option[] = [
|
types: Option[] = [
|
||||||
{value: 'funder', label: StakeholderEntities.FUNDER},
|
...stakeholderTypes
|
||||||
{value: 'ri', label: StakeholderEntities.RI},
|
|
||||||
{value: 'project', label: StakeholderEntities.PROJECT},
|
|
||||||
{value: 'organization', label: StakeholderEntities.ORGANIZATION}
|
|
||||||
];
|
];
|
||||||
|
|
||||||
visibility: Option[] = [
|
visibility: Option[] = [
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import {SafeResourceUrl} from "@angular/platform-browser";
|
import {SafeResourceUrl} from "@angular/platform-browser";
|
||||||
import {properties} from "../../../../environments/environment";
|
import {properties} from "../../../../environments/environment";
|
||||||
import {Session, User} from "../../login/utils/helper.class";
|
import {Session, User} from "../../login/utils/helper.class";
|
||||||
|
import {Option} from "../../sharedComponents/input/input.component";
|
||||||
|
|
||||||
export const ChartHelper = {
|
export const ChartHelper = {
|
||||||
prefix: "((__",
|
prefix: "((__",
|
||||||
|
@ -309,3 +310,10 @@ export enum StakeholderEntities {
|
||||||
ORGANIZATIONS = 'Research Institutions',
|
ORGANIZATIONS = 'Research Institutions',
|
||||||
PROJECTS = 'Projects'
|
PROJECTS = 'Projects'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export let stakeholderTypes: Option[] = [
|
||||||
|
{value: 'funder', label: StakeholderEntities.FUNDER},
|
||||||
|
{value: 'ri', label: StakeholderEntities.RI},
|
||||||
|
{value: 'project', label: StakeholderEntities.PROJECT},
|
||||||
|
{value: 'organization', label: StakeholderEntities.ORGANIZATION}
|
||||||
|
];
|
||||||
|
|
|
@ -5,6 +5,7 @@ import {Meta, Title} from "@angular/platform-browser";
|
||||||
import {SEOService} from "../../sharedComponents/SEO/SEO.service";
|
import {SEOService} from "../../sharedComponents/SEO/SEO.service";
|
||||||
import {Breadcrumb} from "../../utils/breadcrumbs/breadcrumbs.component";
|
import {Breadcrumb} from "../../utils/breadcrumbs/breadcrumbs.component";
|
||||||
import {Subscriber} from "rxjs";
|
import {Subscriber} from "rxjs";
|
||||||
|
import {StakeholderEntities} from "../entities/stakeholder";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'indicator-themes-page',
|
selector: 'indicator-themes-page',
|
||||||
|
@ -53,9 +54,9 @@ import {Subscriber} from "rxjs";
|
||||||
This is the current set of indicator themes we cover. We’ll keep enriching it as new requests and data are coming into the <a href="https://graph.openaire.eu" class="text-graph" target="_blank">OpenAIRE Graph</a>. We are at your disposal, should you have any recommendations!
|
This is the current set of indicator themes we cover. We’ll keep enriching it as new requests and data are coming into the <a href="https://graph.openaire.eu" class="text-graph" target="_blank">OpenAIRE Graph</a>. We are at your disposal, should you have any recommendations!
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Check out the indicator pages (for <a [routerLink]="['../funder']" [relativeTo]="route">funders</a>,
|
Check out the indicator pages (for <a [routerLink]="['../funder']" [relativeTo]="route" class="uk-text-lowercase">{{entities.FUNDERS}}</a>,
|
||||||
<a [routerLink]="['../organization']" [relativeTo]="route">research institutions</a> and
|
<a [routerLink]="['../organization']" [relativeTo]="route" class="uk-text-lowercase">{{entities.ORGANIZATIONS}}</a> and
|
||||||
<a [routerLink]="['../ri']" [relativeTo]="route">research initiatives</a>)
|
<a [routerLink]="['../ri']" [relativeTo]="route" class="uk-text-lowercase">{{entities.RIS}}</a>)
|
||||||
for the specific indicators for each type of dashboard, and the <a [routerLink]="['../../methodology']" [relativeTo]="route">methodology and terminology</a> page on how we produce the metrics.
|
for the specific indicators for each type of dashboard, and the <a [routerLink]="['../../methodology']" [relativeTo]="route">methodology and terminology</a> page on how we produce the metrics.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -67,6 +68,7 @@ import {Subscriber} from "rxjs";
|
||||||
export class IndicatorThemesComponent implements OnInit, OnDestroy {
|
export class IndicatorThemesComponent implements OnInit, OnDestroy {
|
||||||
private subscriptions: any[] = [];
|
private subscriptions: any[] = [];
|
||||||
public properties = properties;
|
public properties = properties;
|
||||||
|
public entities = StakeholderEntities;
|
||||||
public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'Resources - Themes'}];
|
public breadcrumbs: Breadcrumb[] = [{name: 'home', route: '/'}, {name: 'Resources - Themes'}];
|
||||||
|
|
||||||
constructor(private router: Router,
|
constructor(private router: Router,
|
||||||
|
|
Loading…
Reference in New Issue