mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-01-09 20:15:07 +00:00
(FuseNavigation) Added support for new "isActiveMatchOptions" for Basic navigation items; https://github.com/angular/angular/pull/40303
(docs) Updated FuseNavigation documentation
This commit is contained in:
parent
fd859a8663
commit
e4df408abe
|
@ -11,7 +11,7 @@
|
||||||
[ngClass]="{'fuse-horizontal-navigation-item-active-forced': item.active}"
|
[ngClass]="{'fuse-horizontal-navigation-item-active-forced': item.active}"
|
||||||
[routerLink]="[item.link]"
|
[routerLink]="[item.link]"
|
||||||
[routerLinkActive]="'fuse-horizontal-navigation-item-active'"
|
[routerLinkActive]="'fuse-horizontal-navigation-item-active'"
|
||||||
[routerLinkActiveOptions]="{exact: item.exactMatch || false}">
|
[routerLinkActiveOptions]="item.isActiveMatchOptions">
|
||||||
<ng-container *ngTemplateOutlet="itemTemplate"></ng-container>
|
<ng-container *ngTemplateOutlet="itemTemplate"></ng-container>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
[ngClass]="{'fuse-horizontal-navigation-item-active-forced': item.active}"
|
[ngClass]="{'fuse-horizontal-navigation-item-active-forced': item.active}"
|
||||||
[routerLink]="[item.link]"
|
[routerLink]="[item.link]"
|
||||||
[routerLinkActive]="'fuse-horizontal-navigation-item-active'"
|
[routerLinkActive]="'fuse-horizontal-navigation-item-active'"
|
||||||
[routerLinkActiveOptions]="{exact: item.exactMatch || false}"
|
[routerLinkActiveOptions]="item.isActiveMatchOptions"
|
||||||
(click)="item.function(item)">
|
(click)="item.function(item)">
|
||||||
<ng-container *ngTemplateOutlet="itemTemplate"></ng-container>
|
<ng-container *ngTemplateOutlet="itemTemplate"></ng-container>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { takeUntil } from 'rxjs/operators';
|
||||||
import { FuseHorizontalNavigationComponent } from '@fuse/components/navigation/horizontal/horizontal.component';
|
import { FuseHorizontalNavigationComponent } from '@fuse/components/navigation/horizontal/horizontal.component';
|
||||||
import { FuseNavigationService } from '@fuse/components/navigation/navigation.service';
|
import { FuseNavigationService } from '@fuse/components/navigation/navigation.service';
|
||||||
import { FuseNavigationItem } from '@fuse/components/navigation/navigation.types';
|
import { FuseNavigationItem } from '@fuse/components/navigation/navigation.types';
|
||||||
|
import { FuseUtilsService } from '@fuse/services/utils/utils.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector : 'fuse-horizontal-navigation-basic-item',
|
selector : 'fuse-horizontal-navigation-basic-item',
|
||||||
|
@ -24,7 +25,8 @@ export class FuseHorizontalNavigationBasicItemComponent implements OnInit, OnDes
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
private _changeDetectorRef: ChangeDetectorRef,
|
private _changeDetectorRef: ChangeDetectorRef,
|
||||||
private _fuseNavigationService: FuseNavigationService
|
private _fuseNavigationService: FuseNavigationService,
|
||||||
|
private _fuseUtilsService: FuseUtilsService
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -38,6 +40,13 @@ export class FuseHorizontalNavigationBasicItemComponent implements OnInit, OnDes
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void
|
ngOnInit(): void
|
||||||
{
|
{
|
||||||
|
// If the item doesn't have "isActiveMatchOptions",
|
||||||
|
// set it using the equivalent form of "item.exactMatch"
|
||||||
|
if ( !this.item.isActiveMatchOptions )
|
||||||
|
{
|
||||||
|
this.item.isActiveMatchOptions = this.item.exactMatch ? this._fuseUtilsService.exactMatchOptions : this._fuseUtilsService.subsetMatchOptions;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the parent navigation component
|
// Get the parent navigation component
|
||||||
this._fuseHorizontalNavigationComponent = this._fuseNavigationService.getComponent(this.name);
|
this._fuseHorizontalNavigationComponent = this._fuseNavigationService.getComponent(this.name);
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { IsActiveMatchOptions } from '@angular/router';
|
||||||
|
|
||||||
export interface FuseNavigationItem
|
export interface FuseNavigationItem
|
||||||
{
|
{
|
||||||
id?: string;
|
id?: string;
|
||||||
|
@ -16,6 +18,7 @@ export interface FuseNavigationItem
|
||||||
link?: string;
|
link?: string;
|
||||||
externalLink?: boolean;
|
externalLink?: boolean;
|
||||||
exactMatch?: boolean;
|
exactMatch?: boolean;
|
||||||
|
isActiveMatchOptions?: IsActiveMatchOptions;
|
||||||
function?: (item: FuseNavigationItem) => void;
|
function?: (item: FuseNavigationItem) => void;
|
||||||
classes?: {
|
classes?: {
|
||||||
title?: string;
|
title?: string;
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
[ngClass]="{'fuse-vertical-navigation-item-active-forced': item.active}"
|
[ngClass]="{'fuse-vertical-navigation-item-active-forced': item.active}"
|
||||||
[routerLink]="[item.link]"
|
[routerLink]="[item.link]"
|
||||||
[routerLinkActive]="'fuse-vertical-navigation-item-active'"
|
[routerLinkActive]="'fuse-vertical-navigation-item-active'"
|
||||||
[routerLinkActiveOptions]="{exact: item.exactMatch || false}">
|
[routerLinkActiveOptions]="item.isActiveMatchOptions">
|
||||||
<ng-container *ngTemplateOutlet="itemTemplate"></ng-container>
|
<ng-container *ngTemplateOutlet="itemTemplate"></ng-container>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
[ngClass]="{'fuse-vertical-navigation-item-active-forced': item.active}"
|
[ngClass]="{'fuse-vertical-navigation-item-active-forced': item.active}"
|
||||||
[routerLink]="[item.link]"
|
[routerLink]="[item.link]"
|
||||||
[routerLinkActive]="'fuse-vertical-navigation-item-active'"
|
[routerLinkActive]="'fuse-vertical-navigation-item-active'"
|
||||||
[routerLinkActiveOptions]="{exact: item.exactMatch || false}"
|
[routerLinkActiveOptions]="item.isActiveMatchOptions"
|
||||||
(click)="item.function(item)">
|
(click)="item.function(item)">
|
||||||
<ng-container *ngTemplateOutlet="itemTemplate"></ng-container>
|
<ng-container *ngTemplateOutlet="itemTemplate"></ng-container>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -40,6 +40,13 @@ export class FuseVerticalNavigationBasicItemComponent implements OnInit, OnDestr
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void
|
ngOnInit(): void
|
||||||
{
|
{
|
||||||
|
// If the item doesn't have "isActiveMatchOptions",
|
||||||
|
// set it using the equivalent form of "item.exactMatch"
|
||||||
|
if ( !this.item.isActiveMatchOptions )
|
||||||
|
{
|
||||||
|
this.item.isActiveMatchOptions = this.item.exactMatch ? this._fuseUtilsService.exactMatchOptions : this._fuseUtilsService.subsetMatchOptions;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the parent navigation component
|
// Get the parent navigation component
|
||||||
this._fuseVerticalNavigationComponent = this._fuseNavigationService.getComponent(this.name);
|
this._fuseVerticalNavigationComponent = this._fuseNavigationService.getComponent(this.name);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import { IsActiveMatchOptions } from '@angular/router';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
|
@ -12,6 +13,36 @@ export class FuseUtilsService
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------------------------
|
||||||
|
// @ Accessors
|
||||||
|
// -----------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the equivalent "IsActiveMatchOptions" options for "exact = true".
|
||||||
|
*/
|
||||||
|
get exactMatchOptions(): IsActiveMatchOptions
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
paths : 'exact',
|
||||||
|
fragment : 'ignored',
|
||||||
|
matrixParams: 'ignored',
|
||||||
|
queryParams : 'exact'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the equivalent "IsActiveMatchOptions" options for "exact = false".
|
||||||
|
*/
|
||||||
|
get subsetMatchOptions(): IsActiveMatchOptions
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
paths : 'subset',
|
||||||
|
fragment : 'ignored',
|
||||||
|
matrixParams: 'ignored',
|
||||||
|
queryParams : 'subset'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------
|
||||||
// @ Public methods
|
// @ Public methods
|
||||||
// -----------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -97,6 +97,7 @@
|
||||||
link?: string;
|
link?: string;
|
||||||
externalLink?: boolean;
|
externalLink?: boolean;
|
||||||
exactMatch?: boolean;
|
exactMatch?: boolean;
|
||||||
|
isActiveMatchOptions?: IsActiveMatchOptions;
|
||||||
function?: (item: FuseNavigationItem) => void;
|
function?: (item: FuseNavigationItem) => void;
|
||||||
classes?: {
|
classes?: {
|
||||||
title?: string;
|
title?: string;
|
||||||
|
@ -203,7 +204,21 @@
|
||||||
<div>exactMatch</div>
|
<div>exactMatch</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
Sets the <em>exactMatch</em> parameter on the <em>router link active options</em>.
|
Sets the <em>exact</em> parameter on the <em>[routerLinkActiveOptions]</em>.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="font-mono text-md text-secondary">
|
||||||
|
<div>isActiveMatchOptions</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Sets the <em>isActiveMatchOptions</em> object on the <em>[routerLinkActiveOptions]</em>. If provided, <em>exactMatch</em> option will be
|
||||||
|
ignored.
|
||||||
|
<a
|
||||||
|
href="https://angular.io/api/router/IsActiveMatchOptions"
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer">https://angular.io/api/router/IsActiveMatchOptions
|
||||||
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user