Resource Service: Add target for links in resources.

This commit is contained in:
Konstantinos Triantafyllou 2023-07-04 14:20:50 +03:00
parent e9a62e1f61
commit 4bec610237
1 changed files with 7 additions and 7 deletions

View File

@ -26,27 +26,27 @@ export class ResourcesService {
constructor(private http: HttpClient) {
}
private async getResourcesItemsAsync(prefix = '', portal: string = null): Promise<MenuItem[]> {
private async getResourcesItemsAsync(prefix = '', portal: string = null, target = '_self'): Promise<MenuItem[]> {
let items = [
new MenuItem("methodology", "Methodology", "", "", false, [],
null, {}, null, null, null, null, '_self'),
ResourcesService.setLink(new MenuItem("methodological-approach", "Methodological Approach",
"", "", false, [], null, {}, null, null, null, null, '_self'),
"", "", false, [], null, {}, null, null, null, null, target),
prefix + "/methodology/methodological-approach", portal),
ResourcesService.setLink(new MenuItem("terminology", "Terminology and construction",
"", "", false, [], null, {}, null, null, null, null, '_self'),
"", "", false, [], null, {}, null, null, null, null, target),
prefix + "/methodology/terminology", portal)];
items.push(new MenuItem("indicators-page", "Indicators",
"", "", false, [], null, {}));
items.push(ResourcesService.setLink(new MenuItem("indicator-themes", "Indicator Themes",
"", "", false, [], null, {}, null, null, null, null, '_self'), prefix + "/indicators/themes", portal));
"", "", false, [], null, {}, null, null, null, null, target), prefix + "/indicators/themes", portal));
let promise = new Promise<void>(resolve => {
this.isPagesEnabled().subscribe(status => {
ResourcesService.types.forEach((type, index) => {
if (status[index]) {
items.push(ResourcesService.setLink(
new MenuItem("indicators-" + type.value, type.label,
"", "", false, [], null, {}, null, null, null, null, '_self'),
"", "", false, [], null, {}, null, null, null, null, target),
prefix + "/indicators/" + type.value, portal)
);
}
@ -61,13 +61,13 @@ export class ResourcesService {
return items;
}
setResources(items: MenuItem[], prefix = '', portal: string = null) {
setResources(items: MenuItem[], prefix = '', portal: string = null, target = '_self') {
if (this.subscription) {
this.subscription.unsubscribe();
}
let resources = new MenuItem('resources', 'Resources', "", "", false, [], null, {});
let index = items.push(resources) - 1;
this.subscription = from(this.getResourcesItemsAsync(prefix, portal)).subscribe(resourcesItems => {
this.subscription = from(this.getResourcesItemsAsync(prefix, portal, target)).subscribe(resourcesItems => {
items[index].items = resourcesItems;
});
}