changes for adding stakeholder entities as enum

This commit is contained in:
Alex Martzios 2022-06-09 11:21:25 +03:00
parent 73dae143f3
commit 07c990824e
2 changed files with 20 additions and 10 deletions

View File

@ -6,6 +6,7 @@ import {CommunityInfo} from "../../connect/community/communityInfo";
import {Router} from "@angular/router";
import {LocalStorageService} from "../../services/localStorage.service";
import {Stakeholder, StakeholderInfo, Visibility} from "../../monitor/entities/stakeholder";
import {StringUtils} from '../../utils/string-utils.class';
@Component({
selector: 'portal-search-result',
@ -48,15 +49,11 @@ export class PortalSearchResultComponent implements OnInit{
}
mapType(type: string) {
if(type === 'ri') {
return 'Research Initiative';
} else if(type === 'community') {
return 'Research Community'
} else if(type === 'organization') {
return 'Institution';
} else {
return type;
}
if(type === 'community') {
return 'Research Community';
} else {
return StringUtils.getStakeholderType(type, false);
}
}
hasPermission(result: CommunityInfo & StakeholderInfo) {

View File

@ -1,6 +1,6 @@
import {UrlSegment} from '@angular/router';
import {AbstractControl, FormGroup, ValidationErrors, ValidatorFn, Validators} from "@angular/forms";
import {Stakeholder} from "../monitor/entities/stakeholder";
import {Stakeholder, StakeholderEntities} from "../monitor/entities/stakeholder";
import {CommunityInfo} from "../connect/community/communityInfo";
import {properties} from "../../../environments/environment";
import {OpenaireEntities} from "./properties/searchFields";
@ -493,4 +493,17 @@ export class StringUtils {
}
return entityType.toLowerCase().replace(" ", "-");
}
public static getStakeholderType(stakeholderType: string, plural: boolean = false): string {
if(stakeholderType == "funder") {
return plural ? StakeholderEntities.FUNDERS : StakeholderEntities.FUNDER;
} else if(stakeholderType == "ri") {
return plural ? StakeholderEntities.RIS : StakeholderEntities.RI;
} else if(stakeholderType == "organization") {
return plural ? StakeholderEntities.ORGANIZATIONS : StakeholderEntities.ORGANIZATION;
} else if(stakeholderType == "project") {
return plural ? StakeholderEntities.PROJECTS : StakeholderEntities.PROJECT;
}
return stakeholderType;
}
}