mirror of https://github.com/abpframework/abp
parent
9c0fe4c8e1
commit
962e636640
@ -1,37 +1,14 @@
|
||||
import { ABP, ConfigState } from '@abp/ng.core';
|
||||
import { Component, Input, Renderer2, TrackByFunction } from '@angular/core';
|
||||
import { Select } from '@ngxs/store';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ABP, RoutesService, TreeNode } from '@abp/ng.core';
|
||||
import { Component, Input, TrackByFunction } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'abp-routes',
|
||||
templateUrl: 'routes.component.html',
|
||||
})
|
||||
export class RoutesComponent {
|
||||
@Select(ConfigState.getOne('routes'))
|
||||
routes$: Observable<ABP.FullRoute[]>;
|
||||
@Input() smallScreen: boolean;
|
||||
|
||||
@Input()
|
||||
smallScreen: boolean;
|
||||
trackByFn: TrackByFunction<TreeNode<ABP.Route>> = (_, item) => item.name;
|
||||
|
||||
get visibleRoutes$(): Observable<ABP.FullRoute[]> {
|
||||
return this.routes$.pipe(map(routes => getVisibleRoutes(routes)));
|
||||
}
|
||||
|
||||
trackByFn: TrackByFunction<ABP.FullRoute> = (_, item) => item.name;
|
||||
|
||||
constructor(private renderer: Renderer2) {}
|
||||
}
|
||||
|
||||
function getVisibleRoutes(routes: ABP.FullRoute[]) {
|
||||
return routes.reduce((acc, val) => {
|
||||
if (val.invisible) return acc;
|
||||
|
||||
if (val.children && val.children.length) {
|
||||
val.children = getVisibleRoutes(val.children);
|
||||
}
|
||||
|
||||
return [...acc, val];
|
||||
}, []);
|
||||
constructor(public readonly routes: RoutesService) {}
|
||||
}
|
||||
|
Loading…
Reference in new issue