Remove the {navigation} import from the ThemeOptions and inject it where we actually use the fuseThemeOptions

This commit is contained in:
Sercan Yemen 2018-04-04 14:41:43 +03:00
parent 831d48f5a3
commit 02df48ab4e
3 changed files with 17 additions and 12 deletions

View File

@ -1,4 +1,4 @@
import { Component, ElementRef, HostBinding, OnDestroy, OnInit, Renderer2, ViewChild } from '@angular/core'; import { Component, ElementRef, HostBinding, Input, OnDestroy, OnInit, Renderer2, ViewChild } from '@angular/core';
import { style, animate, AnimationBuilder, AnimationPlayer } from '@angular/animations'; import { style, animate, AnimationBuilder, AnimationPlayer } from '@angular/animations';
import { Subscription } from 'rxjs/Subscription'; import { Subscription } from 'rxjs/Subscription';
@ -6,8 +6,6 @@ import { fuseAnimations } from '@fuse/animations';
import { FuseConfigService } from '@fuse/services/config.service'; import { FuseConfigService } from '@fuse/services/config.service';
import { FuseNavigationService } from '@fuse/components/navigation/navigation.service'; import { FuseNavigationService } from '@fuse/components/navigation/navigation.service';
import { navigation } from 'app/navigation/navigation';
@Component({ @Component({
selector : 'fuse-theme-options', selector : 'fuse-theme-options',
templateUrl: './theme-options.component.html', templateUrl: './theme-options.component.html',
@ -16,6 +14,7 @@ import { navigation } from 'app/navigation/navigation';
}) })
export class FuseThemeOptionsComponent implements OnInit, OnDestroy export class FuseThemeOptionsComponent implements OnInit, OnDestroy
{ {
@Input() navigation;
@ViewChild('openButton') openButton; @ViewChild('openButton') openButton;
@ViewChild('panel') panel; @ViewChild('panel') panel;
@ViewChild('overlay') overlay: ElementRef; @ViewChild('overlay') overlay: ElementRef;
@ -43,10 +42,17 @@ export class FuseThemeOptionsComponent implements OnInit, OnDestroy
this.config = newConfig; this.config = newConfig;
} }
); );
}
ngOnInit()
{
this.renderer.listen(this.overlay.nativeElement, 'click', () => {
this.closeBar();
});
// Get the nav model and add customize nav item // Get the nav model and add customize nav item
// that opens the bar programmatically // that opens the bar programmatically
const nav: any = navigation; const nav: any = this.navigation;
nav.push({ nav.push({
'id' : 'custom-function', 'id' : 'custom-function',
@ -66,13 +72,6 @@ export class FuseThemeOptionsComponent implements OnInit, OnDestroy
}); });
} }
ngOnInit()
{
this.renderer.listen(this.overlay.nativeElement, 'click', () => {
this.closeBar();
});
}
ngOnDestroy() ngOnDestroy()
{ {
this.onConfigChanged.unsubscribe(); this.onConfigChanged.unsubscribe();

View File

@ -74,4 +74,4 @@
</mat-sidenav-container> </mat-sidenav-container>
<fuse-theme-options></fuse-theme-options> <fuse-theme-options [navigation]="navigation"></fuse-theme-options>

View File

@ -5,6 +5,8 @@ import { Subscription } from 'rxjs/Subscription';
import { FuseConfigService } from '@fuse/services/config.service'; import { FuseConfigService } from '@fuse/services/config.service';
import { navigation } from 'app/navigation/navigation';
@Component({ @Component({
selector : 'fuse-main', selector : 'fuse-main',
templateUrl : './main.component.html', templateUrl : './main.component.html',
@ -15,6 +17,8 @@ export class FuseMainComponent implements OnDestroy
{ {
onConfigChanged: Subscription; onConfigChanged: Subscription;
fuseSettings: any; fuseSettings: any;
navigation: any;
@HostBinding('attr.fuse-layout-mode') layoutMode; @HostBinding('attr.fuse-layout-mode') layoutMode;
constructor( constructor(
@ -38,6 +42,8 @@ export class FuseMainComponent implements OnDestroy
{ {
this.document.body.className += ' is-mobile'; this.document.body.className += ' is-mobile';
} }
this.navigation = navigation;
} }
ngOnDestroy() ngOnDestroy()