resultLanding: display community categories and concepts only when on browsing that community

This commit is contained in:
Alex Martzios 2021-11-23 13:50:44 +02:00
parent 55f7167fb4
commit de6c91cbab
2 changed files with 17 additions and 11 deletions

View File

@ -6,7 +6,7 @@ export class ConnectHelper {
public static getCommunityFromDomain(domain: string): string{
if(properties.environment == "development") {
domain = "beta.connect.openaire.eu"; //for testing
domain = "aginfra.openaire.eu"; //for testing
}
domain = domain.indexOf("//") != -1? domain.split("//")[1]:domain; //remove https:// prefix
if (domain.indexOf('openaire.eu') === -1) {
@ -49,6 +49,6 @@ export class ConnectHelper {
public static isPrivate(community, user) {
return community && (community.status == "hidden" || (community.status == "manager" && !(Session.isCommunityCurator(user) || Session.isManager("community", community.communityId, user))))
return community && (community.status == "hidden" || (community.status == "manager" && !(Session.isPortalAdministrator(user) || Session.isCommunityCurator(user) || Session.isManager("community", community.communityId, user))))
}
}

View File

@ -39,16 +39,19 @@ import {HelperFunctions} from "../../utils/HelperFunctions.class";
<div>
<div *ngIf="gateways && gateways.length > 0" class="uk-text-muted">Other Communities</div>
<ul class="custom-list" [ngClass]="{'uk-padding-remove uk-margin-remove': !gateways || gateways.length == 0}">
<li *ngFor="let community of otherCommunities">
<li *ngFor="let community of otherCommunities; let i = index">
{{community.labelContext}}
<span *ngIf="community.labelCategory && (currentCommunity == community.idContext)">
<span uk-icon="icon: arrow-right"></span> {{community.labelCategory}}
</span>
<span *ngIf="community.labelConcept && (currentCommunity == community.idContext)">
: {{community.labelConcept}}
</span>
</li>
</ul>
</div>
</div>
</ng-container>
<!-- TODO: Connect relatedTo component with concepts this time -->
<!-- <ng-container *ngIf="connectLinksView; else elseBlock"> -->
<!-- One gateway link -->
<!-- <div *ngIf="gateways && gateways.length === 1" class="uk-margin-medium-top uk-width-1-2@m">
@ -157,6 +160,7 @@ export class RelatedToComponent implements OnInit {
public showNum: number = 5;
public gateways = [];
public otherCommunities = [];
public currentCommunity = ConnectHelper.getCommunityFromDomain(properties.domain);
private subscriptions = [];
constructor(private communityService: CommunityService,
@ -174,7 +178,7 @@ export class RelatedToComponent implements OnInit {
//- handling subscribe errors?
this.subscriptions.push(
this.communityService.getCommunity(context.idContext).subscribe( community => {
if(community && !ConnectHelper.isPrivate(community,user) && (ConnectHelper.getCommunityFromDomain(properties.domain) != context.idContext)) {
if(community && !ConnectHelper.isPrivate(community,user) && (this.currentCommunity != context.idContext)) {
// creating the link, based on the enviroment
let url = '';
if(properties.environment == "beta") {
@ -190,12 +194,14 @@ export class RelatedToComponent implements OnInit {
}
this.gateways.push(context);
} else {
for(let other of this.otherCommunities) {
if(other.idContext == context.idContext) {
return; // skips so that we don't get duplicate communities because of the multiple concepts
if(this.currentCommunity != context.idContext) {
for(let other of this.otherCommunities) {
if(other.idContext == context.idContext) {
return; // skips so that we don't get duplicate communities because of the multiple concepts
}
}
}
this.otherCommunities.push(context)
this.otherCommunities.push(context);
}
index++;
if(index == this.contexts.length) {