Skip to content

Commit

Permalink
Bugfix: router link blank and router link
Browse files Browse the repository at this point in the history
  • Loading branch information
djuarezgf committed Dec 13, 2023
1 parent 5677a33 commit 863fc20
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 7 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.0] - 2023-11-14
## [1.0.1] - 2023-12-13
### Fixed
- Router link blank and router link

## [1.0.0] - 2023-12-13
### Added
- Init project
- Prototype
Expand Down
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {MatDatepickerModule} from "@angular/material/datepicker";
import {MatNativeDateModule} from "@angular/material/core";
import {MatFormFieldModule} from "@angular/material/form-field";
import {MatButtonToggleModule} from "@angular/material/button-toggle";
import {ExternalLinkBlankDirective} from "./external-link-blank.directive";

@NgModule({
declarations: [
Expand All @@ -53,6 +54,7 @@ import {MatButtonToggleModule} from "@angular/material/button-toggle";
SidebarComponent,
TeilerAppPluginOrchestratorComponent,
ExternalLinkDirective,
ExternalLinkBlankDirective,
TeilerBoxComponent,
TeilerWelcomeComponent
],
Expand Down
9 changes: 9 additions & 0 deletions src/app/external-link-blank.directive.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { ExternalLinkBlankDirective } from './external-link-blank.directive';

describe('ExternalLinkBlankDirective', () => {
it('should create an instance', () => {
//TODO
//const directive = new ExternalLinkBlankDirective();
//expect(directive).toBeTruthy();
});
});
22 changes: 22 additions & 0 deletions src/app/external-link-blank.directive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {Directive, Input} from '@angular/core';
import {RouterLink} from "@angular/router";

@Directive({
selector: '[externalLinkBlank]'
})
export class ExternalLinkBlankDirective {

@Input('externalLinkBlank') externalLink: string = '';

constructor(private routerLinkWithHref: RouterLink) {
routerLinkWithHref.onClick = () => {
if (this.externalLink != null && this.externalLink != undefined && this.externalLink.length > 0) {
window.open(this.externalLink, '_blank');
return false;
}
return true;
};
}


}
2 changes: 1 addition & 1 deletion src/app/external-link.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class ExternalLinkDirective {
constructor(private routerLinkWithHref: RouterLink) {
routerLinkWithHref.onClick = () => {
if (this.externalLink != null && this.externalLink != undefined && this.externalLink.length > 0) {
window.open(this.externalLink, '_blank');
window.location.href=this.externalLink;
return false;
}
return true;
Expand Down
3 changes: 1 addition & 2 deletions src/app/sidebar/sidebar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</div>
</ng-template>
<a mat-list-item routerLink="{{'/'+teilerApp.routerLink}}"
[externalLink]="teilerApp.sourceUrl??''" class="sidebar-text">{{teilerApp.title}}</a>
[externalLinkBlank]="teilerApp.sourceUrl??''" class="sidebar-text">{{teilerApp.title}}</a>
</div>
</div>
</div>
Expand Down Expand Up @@ -593,4 +593,3 @@
</div>
</div>
</div>

6 changes: 3 additions & 3 deletions src/app/teiler-main-menu/teiler-main-menu.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</a>
</div>
<div *ngIf="teilerApp.externLink">
<a routerLink="{{'/'+teilerApp.routerLink}}" [externalLink]="teilerApp.sourceUrl??''">
<a routerLink="{{'/'+teilerApp.routerLink}}" [externalLinkBlank]="teilerApp.sourceUrl??''">
<teiler-box [teilerApp]="teilerApp"></teiler-box>
</a>
</div>
Expand All @@ -48,7 +48,7 @@
</a>
</div>
<div *ngIf="teilerApp.externLink">
<a routerLink="{{'/'+teilerApp.routerLink}}" [externalLink]="teilerApp.sourceUrl??''">
<a routerLink="{{'/'+teilerApp.routerLink}}" [externalLinkBlank]="teilerApp.sourceUrl??''">
<teiler-box [teilerApp]="teilerApp"></teiler-box>
</a>
</div>
Expand All @@ -75,7 +75,7 @@ <h3 i18n>Lokale Apps</h3>
</a>
</div>
<div *ngIf="teilerApp.externLink">
<a routerLink="{{'/'+teilerApp.routerLink}}" [externalLink]="teilerApp.sourceUrl??''">
<a routerLink="{{'/'+teilerApp.routerLink}}" [externalLinkBlank]="teilerApp.sourceUrl??''">
<teiler-box [teilerApp]="teilerApp"></teiler-box>
</a>
</div>
Expand Down

0 comments on commit 863fc20

Please sign in to comment.