mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-01-10 12:35:07 +00:00
Removed the id from the navigation as there might be multiple navigations
Fixed: getFlatNavigation doesn't correctly get the 'collapsable' items because of the item.type change Closes #71: getFlatNavigation method not correctly working when its called multiple times
This commit is contained in:
parent
224bbf479a
commit
64e0451dc6
|
@ -1,5 +1,4 @@
|
||||||
<div id="main-navigation" class="nav"
|
<div class="nav" [ngClass]="{'horizontal':layout === 'horizontal', 'vertical':layout === 'vertical'}">
|
||||||
[ngClass]="{'horizontal':layout === 'horizontal', 'vertical':layout === 'vertical'}">
|
|
||||||
|
|
||||||
<!-- Vertical Navigation Layout -->
|
<!-- Vertical Navigation Layout -->
|
||||||
<ng-container *ngIf="layout === 'vertical'">
|
<ng-container *ngIf="layout === 'vertical'">
|
||||||
|
@ -21,7 +20,8 @@
|
||||||
<ng-container *ngFor="let item of navigation">
|
<ng-container *ngFor="let item of navigation">
|
||||||
|
|
||||||
<fuse-nav-horizontal-collapsable *ngIf="item.type=='group'" [item]="item"></fuse-nav-horizontal-collapsable>
|
<fuse-nav-horizontal-collapsable *ngIf="item.type=='group'" [item]="item"></fuse-nav-horizontal-collapsable>
|
||||||
<fuse-nav-horizontal-collapsable *ngIf="item.type=='collapse'" [item]="item"></fuse-nav-horizontal-collapsable>
|
<fuse-nav-horizontal-collapsable *ngIf="item.type=='collapse'"
|
||||||
|
[item]="item"></fuse-nav-horizontal-collapsable>
|
||||||
<fuse-nav-horizontal-item *ngIf="item.type=='item'" [item]="item"></fuse-nav-horizontal-item>
|
<fuse-nav-horizontal-item *ngIf="item.type=='item'" [item]="item"></fuse-nav-horizontal-item>
|
||||||
|
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { BehaviorSubject, Observable, Subject } from 'rxjs';
|
import { BehaviorSubject, Observable, Subject } from 'rxjs';
|
||||||
|
|
||||||
|
import { FuseNavigationItem } from '@fuse/types';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class FuseNavigationService
|
export class FuseNavigationService
|
||||||
{
|
{
|
||||||
flatNavigation: any[] = [];
|
|
||||||
|
|
||||||
onItemCollapsed: Subject<any>;
|
onItemCollapsed: Subject<any>;
|
||||||
onItemCollapseToggled: Subject<any>;
|
onItemCollapseToggled: Subject<any>;
|
||||||
|
|
||||||
|
@ -138,39 +138,30 @@ export class FuseNavigationService
|
||||||
* Get flattened navigation array
|
* Get flattened navigation array
|
||||||
*
|
*
|
||||||
* @param navigation
|
* @param navigation
|
||||||
|
* @param flatNavigation
|
||||||
* @returns {any[]}
|
* @returns {any[]}
|
||||||
*/
|
*/
|
||||||
getFlatNavigation(navigation): any
|
getFlatNavigation(navigation, flatNavigation: FuseNavigationItem[] = []): any
|
||||||
{
|
{
|
||||||
for ( const navItem of navigation )
|
for ( const item of navigation )
|
||||||
{
|
{
|
||||||
if ( navItem.type === 'item' )
|
if ( item.type === 'item' )
|
||||||
{
|
{
|
||||||
this.flatNavigation.push({
|
flatNavigation.push(item);
|
||||||
id : navItem.id || null,
|
|
||||||
title : navItem.title || null,
|
|
||||||
translate : navItem.translate || null,
|
|
||||||
type : navItem.type,
|
|
||||||
icon : navItem.icon || null,
|
|
||||||
url : navItem.url || null,
|
|
||||||
function : navItem.function || null,
|
|
||||||
exactMatch: navItem.exactMatch || false,
|
|
||||||
badge : navItem.badge || null
|
|
||||||
});
|
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( navItem.type === 'collapse' || navItem.type === 'group' )
|
if ( item.type === 'collapsable' || item.type === 'group' )
|
||||||
{
|
{
|
||||||
if ( navItem.children )
|
if ( item.children )
|
||||||
{
|
{
|
||||||
this.getFlatNavigation(navItem.children);
|
this.getFlatNavigation(item.children, flatNavigation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.flatNavigation;
|
return flatNavigation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user