Skip to content

Commit 863fc20

Browse files
committed
Bugfix: router link blank and router link
1 parent 5677a33 commit 863fc20

File tree

7 files changed

+43
-7
lines changed

7 files changed

+43
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [1.0.0] - 2023-11-14
7+
## [1.0.1] - 2023-12-13
8+
### Fixed
9+
- Router link blank and router link
10+
11+
## [1.0.0] - 2023-12-13
812
### Added
913
- Init project
1014
- Prototype

src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import {MatDatepickerModule} from "@angular/material/datepicker";
4545
import {MatNativeDateModule} from "@angular/material/core";
4646
import {MatFormFieldModule} from "@angular/material/form-field";
4747
import {MatButtonToggleModule} from "@angular/material/button-toggle";
48+
import {ExternalLinkBlankDirective} from "./external-link-blank.directive";
4849

4950
@NgModule({
5051
declarations: [
@@ -53,6 +54,7 @@ import {MatButtonToggleModule} from "@angular/material/button-toggle";
5354
SidebarComponent,
5455
TeilerAppPluginOrchestratorComponent,
5556
ExternalLinkDirective,
57+
ExternalLinkBlankDirective,
5658
TeilerBoxComponent,
5759
TeilerWelcomeComponent
5860
],
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { ExternalLinkBlankDirective } from './external-link-blank.directive';
2+
3+
describe('ExternalLinkBlankDirective', () => {
4+
it('should create an instance', () => {
5+
//TODO
6+
//const directive = new ExternalLinkBlankDirective();
7+
//expect(directive).toBeTruthy();
8+
});
9+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import {Directive, Input} from '@angular/core';
2+
import {RouterLink} from "@angular/router";
3+
4+
@Directive({
5+
selector: '[externalLinkBlank]'
6+
})
7+
export class ExternalLinkBlankDirective {
8+
9+
@Input('externalLinkBlank') externalLink: string = '';
10+
11+
constructor(private routerLinkWithHref: RouterLink) {
12+
routerLinkWithHref.onClick = () => {
13+
if (this.externalLink != null && this.externalLink != undefined && this.externalLink.length > 0) {
14+
window.open(this.externalLink, '_blank');
15+
return false;
16+
}
17+
return true;
18+
};
19+
}
20+
21+
22+
}

src/app/external-link.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class ExternalLinkDirective {
1111
constructor(private routerLinkWithHref: RouterLink) {
1212
routerLinkWithHref.onClick = () => {
1313
if (this.externalLink != null && this.externalLink != undefined && this.externalLink.length > 0) {
14-
window.open(this.externalLink, '_blank');
14+
window.location.href=this.externalLink;
1515
return false;
1616
}
1717
return true;

src/app/sidebar/sidebar.component.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
</div>
5151
</ng-template>
5252
<a mat-list-item routerLink="{{'/'+teilerApp.routerLink}}"
53-
[externalLink]="teilerApp.sourceUrl??''" class="sidebar-text">{{teilerApp.title}}</a>
53+
[externalLinkBlank]="teilerApp.sourceUrl??''" class="sidebar-text">{{teilerApp.title}}</a>
5454
</div>
5555
</div>
5656
</div>
@@ -593,4 +593,3 @@
593593
</div>
594594
</div>
595595
</div>
596-

src/app/teiler-main-menu/teiler-main-menu.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</a>
2929
</div>
3030
<div *ngIf="teilerApp.externLink">
31-
<a routerLink="{{'/'+teilerApp.routerLink}}" [externalLink]="teilerApp.sourceUrl??''">
31+
<a routerLink="{{'/'+teilerApp.routerLink}}" [externalLinkBlank]="teilerApp.sourceUrl??''">
3232
<teiler-box [teilerApp]="teilerApp"></teiler-box>
3333
</a>
3434
</div>
@@ -48,7 +48,7 @@
4848
</a>
4949
</div>
5050
<div *ngIf="teilerApp.externLink">
51-
<a routerLink="{{'/'+teilerApp.routerLink}}" [externalLink]="teilerApp.sourceUrl??''">
51+
<a routerLink="{{'/'+teilerApp.routerLink}}" [externalLinkBlank]="teilerApp.sourceUrl??''">
5252
<teiler-box [teilerApp]="teilerApp"></teiler-box>
5353
</a>
5454
</div>
@@ -75,7 +75,7 @@ <h3 i18n>Lokale Apps</h3>
7575
</a>
7676
</div>
7777
<div *ngIf="teilerApp.externLink">
78-
<a routerLink="{{'/'+teilerApp.routerLink}}" [externalLink]="teilerApp.sourceUrl??''">
78+
<a routerLink="{{'/'+teilerApp.routerLink}}" [externalLinkBlank]="teilerApp.sourceUrl??''">
7979
<teiler-box [teilerApp]="teilerApp"></teiler-box>
8080
</a>
8181
</div>

0 commit comments

Comments
 (0)