-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4815 from abpframework/feat/4814
Added a optional property named visible to NavItem interface
- Loading branch information
Showing
3 changed files
with
36 additions
and
28 deletions.
There are no files selected for viewing
28 changes: 15 additions & 13 deletions
28
npm/ng-packs/packages/theme-basic/src/lib/components/nav-items/nav-items.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
<ul class="navbar-nav"> | ||
<li | ||
class="nav-item d-flex align-items-center" | ||
*ngFor="let item of navItems.items$ | async; trackBy: trackByFn" | ||
[abpPermission]="item.requiredPolicy" | ||
> | ||
<ng-container | ||
*ngIf="item.component; else htmlTemplate" | ||
[ngComponentOutlet]="item.component" | ||
></ng-container> | ||
<ng-container *ngFor="let item of navItems.items$ | async; trackBy: trackByFn"> | ||
<li | ||
class="nav-item d-flex align-items-center" | ||
*ngIf="item.visible()" | ||
[abpPermission]="item.requiredPolicy" | ||
> | ||
<ng-container | ||
*ngIf="item.component; else htmlTemplate" | ||
[ngComponentOutlet]="item.component" | ||
></ng-container> | ||
|
||
<ng-template #htmlTemplate> | ||
<div [innerHTML]="item.html" (click)="item.action ? item.action() : null"></div> | ||
</ng-template> | ||
</li> | ||
<ng-template #htmlTemplate> | ||
<div [innerHTML]="item.html" (click)="item.action ? item.action() : null"></div> | ||
</ng-template> | ||
</li> | ||
</ng-container> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import { Type } from '@angular/core'; | ||
|
||
export interface NavItem { | ||
export class NavItem { | ||
id: string | number; | ||
component?: Type<any>; | ||
html?: string; | ||
action?: () => void; | ||
order?: number; | ||
requiredPolicy?: string; | ||
visible?: () => boolean; | ||
constructor(props: Partial<NavItem>) { | ||
props = { ...props, visible: props.visible || (() => true) }; | ||
Object.assign(this, props); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters