result landing: sort connect gateways

This commit is contained in:
Alex Martzios 2021-11-10 15:08:09 +02:00
parent 3632510e38
commit 32ccec5384
1 changed files with 18 additions and 2 deletions

View File

@ -69,7 +69,7 @@ import {HelperFunctions} from "../../utils/HelperFunctions.class";
<div>
<span class="uk-text-muted">Visit Connect gateways: </span>
</div>
<ul class="uk-list uk-column-1-2 padding-left">
<ul class="custom-list">
<li *ngFor="let gateway of gateways">
<a href="{{gateway.link}}" target="_blank">
{{ gateway.labelContext }}
@ -79,7 +79,7 @@ import {HelperFunctions} from "../../utils/HelperFunctions.class";
</ul>
</div>
</div>
<div class="uk-width-1-3@m relative">
<div class="uk-width-1-3@m uk-position-relative">
<img class="uk-position-bottom-right custom-height-130" src="assets/common-assets/connect_image_faded.png" alt="OpenAIRE Connect image">
</div>
</div>
@ -126,7 +126,9 @@ export class RelatedToComponent implements OnInit {
}
ngOnInit() {
this.contexts.sort(this.compare);
if(this.connectLinksView && properties.environment === "development") {
let index = 0;
this.contexts.forEach( context => {
if(context.idContext) {
this.subscriptions.push(
@ -154,6 +156,10 @@ export class RelatedToComponent implements OnInit {
}
this.gateways.push(context);
}
index++;
if(index == this.contexts.length -1) {
this.gateways.sort(this.compare);
}
})
);
})
@ -174,4 +180,14 @@ export class RelatedToComponent implements OnInit {
public scroll() {
HelperFunctions.scroll();
}
public compare(a, b) {
if(a.labelContext < b.labelContext) {
return -1;
}
if(a.labelContext > b.labelContext) {
return 1;
}
return 0;
}
}