maps components structure created

This commit is contained in:
nixa 2016-05-02 16:55:58 +03:00
parent bff8af282e
commit 57b694c81b
9 changed files with 78 additions and 15 deletions

View file

@ -0,0 +1,19 @@
import {Component, ViewEncapsulation} from 'angular2/core';
@Component({
selector: 'google-maps',
pipes: [],
providers: [],
styles: [],
template: 'googleMaps'
})
export class GoogleMaps {
constructor() {
}
ngOnInit() {
console.log('googleMaps');
}
}

View file

@ -0,0 +1 @@
export * from './googleMaps.component';

View file

@ -0,0 +1 @@
export * from './maps.component';

View file

@ -0,0 +1,29 @@
import {Component, ViewEncapsulation} from 'angular2/core';
import {RouteConfig} from 'angular2/router';
import {GoogleMaps} from './components/googleMaps';
@Component({
selector: 'maps',
pipes: [],
providers: [],
styles: [],
template: `<router-outlet></router-outlet>`
})
@RouteConfig([
{
name: 'GoogleMaps',
component: GoogleMaps,
path: '/google-maps',
useAsDefault: true
},
])
export class Maps {
constructor() {
}
ngOnInit() {
}
}

View file

@ -1,9 +1,10 @@
import {Component, ViewEncapsulation} from 'angular2/core'; import {Component, ViewEncapsulation} from 'angular2/core';
import {RouteConfig, Router} from 'angular2/router'; import {RouteConfig, Router} from 'angular2/router';
import {PageTop, ContentTop, Sidebar} from '../theme';
import {Dashboard} from './dashboard'; import {Dashboard} from './dashboard';
import {Ui} from './ui'; import {Ui} from './ui';
import {PageTop, ContentTop, Sidebar} from '../theme'; import {Maps} from './maps';
@Component({ @Component({
selector: 'pages', selector: 'pages',
@ -32,6 +33,11 @@ import {PageTop, ContentTop, Sidebar} from '../theme';
component: Ui, component: Ui,
path: '/ui/...', path: '/ui/...',
}, },
{
name: 'Maps',
component: Maps,
path: '/maps/...',
},
]) ])
export class Pages { export class Pages {

View file

@ -15,15 +15,7 @@ import {Typography} from './components/typography';
name: 'Typography', name: 'Typography',
component: Typography, component: Typography,
path: '/typography', path: '/typography',
useAsDefault: true, useAsDefault: true
data: {
title: 'Typography',
selected: false,
expanded: false,
sidebarMeta: {
order: 0,
}
}
}, },
]) ])
export class Ui { export class Ui {

View file

@ -102,22 +102,23 @@ export class Sidebar {
private selectMenuItem() { private selectMenuItem() {
let currentMenu; let currentMenu;
let isCurrent = (instruction) => (instruction ? this._router.isRouteActive(this._router.generate([instruction])) : false); let isCurrent = (instructions) => (instructions.filter(i => typeof i !== 'undefined').length > 0 ? this._router.isRouteActive(this._router.generate(instructions)) : false);
let assignCurrent = (menu) => (menu.selected ? currentMenu = menu : null); let assignCurrent = (menu) => (menu.selected ? currentMenu = menu : null);
this.menuItems.forEach(function (menu: any) { this.menuItems.forEach(function (menu: any) {
menu.selected = isCurrent(menu.name); menu.selected = isCurrent([menu.name]);
menu.expanded = menu.expanded || menu.selected; menu.expanded = menu.expanded || menu.selected;
assignCurrent(menu); assignCurrent(menu);
if (menu.subMenu) { if (menu.subMenu) {
menu.subMenu.forEach(function (subMenu) { menu.subMenu.forEach(function (subMenu) {
subMenu.selected = isCurrent(subMenu.name) && !subMenu.disabled; subMenu.selected = isCurrent([menu.name, subMenu.name]) && !subMenu.disabled;
assignCurrent(menu); assignCurrent(menu);
}); });
} }
}); });
// notifies all subscribers // notifies all subscribers
this._themeGlobal.setData('menu.activeLink', currentMenu); this._themeGlobal.setData('menu.activeLink', currentMenu);
} }

View file

@ -27,11 +27,11 @@
[ngClass]="{expanded: subitem.expanded, 'slide-right': subitem.slideRight}"> [ngClass]="{expanded: subitem.expanded, 'slide-right': subitem.slideRight}">
<li *ngFor="#subSubitem of subitem.subMenu" (mouseenter)="hoverItem($event, item)" <li *ngFor="#subSubitem of subitem.subMenu" (mouseenter)="hoverItem($event, item)"
[ngClass]="{selected: subitem.selected}"> [ngClass]="{selected: subitem.selected}">
<a (mouseenter)="hoverItem($event, item)" [routerLink]="[subSubitem.name]"> <a (mouseenter)="hoverItem($event, item)" [routerLink]="[item.name, subitem.name, subSubitem.name]">
{{ subSubitem.title }}</a> {{ subSubitem.title }}</a>
</li> </li>
</ul> </ul>
<a *ngIf="!subitem.subMenu" [routerLink]="[subitem.name]" <a *ngIf="!subitem.subMenu" [routerLink]="[item.name, subitem.name]"
(mouseenter)="hoverItem($event, item)" target="{{subitem.blank ? '_blank' : '_self'}}"> (mouseenter)="hoverItem($event, item)" target="{{subitem.blank ? '_blank' : '_self'}}">
{{ subitem.title}} {{ subitem.title}}
</a> </a>

View file

@ -20,6 +20,20 @@ export class SidebarService {
expanded: false, expanded: false,
order: 200 order: 200
}, },
{
title: 'Maps',
name: 'Maps',
icon: 'ion-ios-location-outline',
selected: false,
expanded: false,
order: 300,
subMenu: [
{
title: 'Google Maps',
name: 'GoogleMaps',
}
]
},
{ {
title: 'Pages', title: 'Pages',
icon: 'ion-document', icon: 'ion-document',