mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-04-26 18:13:11 +00:00
+ Added hidden property to the nav items + Updated fuse-navigation component docs + Updated other components that uses fuse-navigation service + Updated various packages including Angular and Angular Material
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
import { EventEmitter, Injectable } from '@angular/core';
|
|
import { Subject } from 'rxjs/Subject';
|
|
|
|
@Injectable()
|
|
export class FuseNavigationService
|
|
{
|
|
flatNavigation: any[] = [];
|
|
|
|
onItemCollapsed: Subject<any> = new Subject;
|
|
onItemCollapseToggled: Subject<any> = new Subject;
|
|
|
|
constructor()
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Get flattened navigation array
|
|
* @param navigation
|
|
* @returns {any[]}
|
|
*/
|
|
getFlatNavigation(navigation)
|
|
{
|
|
for ( const navItem of navigation )
|
|
{
|
|
if ( navItem.type === 'item' )
|
|
{
|
|
this.flatNavigation.push({
|
|
title: navItem.title,
|
|
type : navItem.type,
|
|
icon : navItem.icon || false,
|
|
url : navItem.url
|
|
});
|
|
|
|
continue;
|
|
}
|
|
|
|
if ( navItem.type === 'collapse' || navItem.type === 'group' )
|
|
{
|
|
if ( navItem.children )
|
|
{
|
|
this.getFlatNavigation(navItem.children);
|
|
}
|
|
}
|
|
}
|
|
|
|
return this.flatNavigation;
|
|
}
|
|
}
|