Skip to content

Commit

Permalink
Use routes for navigation (DevExpress#5)
Browse files Browse the repository at this point in the history
* Use routes for navigation

* Remove icon

* generate navigation for treeview

* Fix indents

* Add HomeComponent to routes

* Add export navigation

* Add a new line
  • Loading branch information
dxvladislavvolkov committed Sep 11, 2018
1 parent 7a78420 commit e8a4616
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 88 deletions.
18 changes: 18 additions & 0 deletions src/app/app-navigation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const navigation = [
{
text: 'Home',
path: '/home',
icon: 'home',
items: [{
text: 'Profile',
path: '/profile'
}, {
text: 'Settings',
path: '/settings'
}]
}, {
text: 'About',
path: '/about',
icon: 'info'
}
];
31 changes: 14 additions & 17 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,20 @@ import { ProfileComponent } from './pages/profile/profile.component';
import { SettingsComponent } from './pages/settings/settings.component';
import { AboutComponent } from './pages/about/about.component'

const routes: Routes = [{
path: '',
redirectTo: 'profile',
pathMatch: 'full'
}, {
path: 'profile',
component: ProfileComponent,
data: { title: 'Profile' }
}, {
path: 'settings',
component: SettingsComponent,
data: { title: 'Settings' }
}, {
path: 'about',
component: AboutComponent,
data: { title: 'About' }
}
export const routes: Routes = [{
path: '',
redirectTo: 'profile',
pathMatch: 'full'
}, {
path: 'profile',
component: ProfileComponent
}, {
path: 'settings',
component: SettingsComponent
}, {
path: 'about',
component: AboutComponent
}
];

@NgModule({
Expand Down
12 changes: 6 additions & 6 deletions src/app/layout/layout.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="container">
<app-header
class="header dx-additional-color-scheme-dark"
<app-header
class="header dx-additional-color-scheme-dark"
(menuToggle)="menuOpened = !menuOpened;">
</app-header>
<dx-drawer
Expand All @@ -10,13 +10,13 @@
[minWidth]="minMenuWidth"
[shading]="shaderEnabled"
[(opened)]="menuOpened">
<app-navigation-menu

<app-navigation-menu
class="dx-additional-color-scheme-dark"
*dxTemplate="let dataMenu of 'panel'"
*dxTemplate="let dataMenu of 'panel'"
(selectedItemChanged)="navigationChanged($event)">
</app-navigation-menu>

<ng-content></ng-content>
</dx-drawer>
</div>
15 changes: 0 additions & 15 deletions src/app/services/navigation/navigation.service.spec.ts

This file was deleted.

41 changes: 0 additions & 41 deletions src/app/services/navigation/navigation.service.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<dx-tree-view
[items]="menuItems"
(onItemClick)="onItemSelectionChanged($event)"
(onItemClick)="onItemSelectionChanged($event)"
[selectByClick]="true"
selectionMode="single">
</dx-tree-view>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, NgModule, Output, EventEmitter } from '@angular/core';
import { DxTreeViewModule } from 'devextreme-angular/ui/tree-view';
import { NavigationService, Navigation } from '../../../services/navigation/navigation.service';
import { navigation } from '../../../app-navigation';
import { Router } from '@angular/router';

@Component({
Expand All @@ -11,17 +11,15 @@ import { Router } from '@angular/router';
display: block;
height: 100%;
}
`],
providers: [NavigationService]
`]
})
export class NavigationMenuComponent {
@Output() selectedItemChanged = new EventEmitter<string>();
menuItems: any;

menuItems: Navigation[];

constructor(private router: Router, navigationService: NavigationService) {
this.menuItems = navigationService.getNavigationData();
}
constructor(private router: Router) {
this.menuItems = navigation;
}

onItemSelectionChanged(event) {
this.selectedItemChanged.emit(event.itemData.text);
Expand Down

0 comments on commit e8a4616

Please sign in to comment.