(FuseNavigation) Use the generic return type for "getComponent"

(docs) Updated FuseNavigation docs
This commit is contained in:
sercan 2021-05-18 13:10:39 +03:00
parent c1ca701e92
commit 5c40e99518
14 changed files with 42 additions and 42 deletions

View File

@ -3,7 +3,7 @@ import { ActivatedRoute, Data, Router } from '@angular/router';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { FuseMediaWatcherService } from '@fuse/services/media-watcher'; import { FuseMediaWatcherService } from '@fuse/services/media-watcher';
import { FuseNavigationService } from '@fuse/components/navigation'; import { FuseNavigationService, FuseVerticalNavigationComponent } from '@fuse/components/navigation';
import { InitialData } from 'app/app.types'; import { InitialData } from 'app/app.types';
@Component({ @Component({
@ -87,7 +87,7 @@ export class CenteredLayoutComponent implements OnInit, OnDestroy
toggleNavigation(name: string): void toggleNavigation(name: string): void
{ {
// Get the navigation // Get the navigation
const navigation = this._fuseNavigationService.getComponent(name); const navigation = this._fuseNavigationService.getComponent<FuseVerticalNavigationComponent>(name);
if ( navigation ) if ( navigation )
{ {

View File

@ -3,7 +3,7 @@ import { ActivatedRoute, Data, Router } from '@angular/router';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { FuseMediaWatcherService } from '@fuse/services/media-watcher'; import { FuseMediaWatcherService } from '@fuse/services/media-watcher';
import { FuseNavigationService } from '@fuse/components/navigation'; import { FuseNavigationService, FuseVerticalNavigationComponent } from '@fuse/components/navigation';
import { InitialData } from 'app/app.types'; import { InitialData } from 'app/app.types';
@Component({ @Component({
@ -87,7 +87,7 @@ export class EnterpriseLayoutComponent implements OnInit, OnDestroy
toggleNavigation(name: string): void toggleNavigation(name: string): void
{ {
// Get the navigation // Get the navigation
const navigation = this._fuseNavigationService.getComponent(name); const navigation = this._fuseNavigationService.getComponent<FuseVerticalNavigationComponent>(name);
if ( navigation ) if ( navigation )
{ {

View File

@ -3,7 +3,7 @@ import { ActivatedRoute, Data, Router } from '@angular/router';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { FuseMediaWatcherService } from '@fuse/services/media-watcher'; import { FuseMediaWatcherService } from '@fuse/services/media-watcher';
import { FuseNavigationService } from '@fuse/components/navigation'; import { FuseNavigationService, FuseVerticalNavigationComponent } from '@fuse/components/navigation';
import { InitialData } from 'app/app.types'; import { InitialData } from 'app/app.types';
@Component({ @Component({
@ -87,7 +87,7 @@ export class MaterialLayoutComponent implements OnInit, OnDestroy
toggleNavigation(name: string): void toggleNavigation(name: string): void
{ {
// Get the navigation // Get the navigation
const navigation = this._fuseNavigationService.getComponent(name); const navigation = this._fuseNavigationService.getComponent<FuseVerticalNavigationComponent>(name);
if ( navigation ) if ( navigation )
{ {

View File

@ -3,7 +3,7 @@ import { ActivatedRoute, Data, Router } from '@angular/router';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { FuseMediaWatcherService } from '@fuse/services/media-watcher'; import { FuseMediaWatcherService } from '@fuse/services/media-watcher';
import { FuseNavigationService } from '@fuse/components/navigation'; import { FuseNavigationService, FuseVerticalNavigationComponent } from '@fuse/components/navigation';
import { InitialData } from 'app/app.types'; import { InitialData } from 'app/app.types';
@Component({ @Component({
@ -87,7 +87,7 @@ export class ModernLayoutComponent implements OnInit, OnDestroy
toggleNavigation(name: string): void toggleNavigation(name: string): void
{ {
// Get the navigation // Get the navigation
const navigation = this._fuseNavigationService.getComponent(name); const navigation = this._fuseNavigationService.getComponent<FuseVerticalNavigationComponent>(name);
if ( navigation ) if ( navigation )
{ {

View File

@ -3,7 +3,7 @@ import { ActivatedRoute, Data, Router } from '@angular/router';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { FuseMediaWatcherService } from '@fuse/services/media-watcher'; import { FuseMediaWatcherService } from '@fuse/services/media-watcher';
import { FuseNavigationService } from '@fuse/components/navigation'; import { FuseNavigationService, FuseVerticalNavigationComponent } from '@fuse/components/navigation';
import { InitialData } from 'app/app.types'; import { InitialData } from 'app/app.types';
@Component({ @Component({
@ -87,7 +87,7 @@ export class ClassicLayoutComponent implements OnInit, OnDestroy
toggleNavigation(name: string): void toggleNavigation(name: string): void
{ {
// Get the navigation // Get the navigation
const navigation = this._fuseNavigationService.getComponent(name); const navigation = this._fuseNavigationService.getComponent<FuseVerticalNavigationComponent>(name);
if ( navigation ) if ( navigation )
{ {

View File

@ -3,7 +3,7 @@ import { ActivatedRoute, Data, Router } from '@angular/router';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { FuseMediaWatcherService } from '@fuse/services/media-watcher'; import { FuseMediaWatcherService } from '@fuse/services/media-watcher';
import { FuseNavigationService } from '@fuse/components/navigation'; import { FuseNavigationService, FuseVerticalNavigationComponent } from '@fuse/components/navigation';
import { InitialData } from 'app/app.types'; import { InitialData } from 'app/app.types';
@Component({ @Component({
@ -87,7 +87,7 @@ export class ClassyLayoutComponent implements OnInit, OnDestroy
toggleNavigation(name: string): void toggleNavigation(name: string): void
{ {
// Get the navigation // Get the navigation
const navigation = this._fuseNavigationService.getComponent(name); const navigation = this._fuseNavigationService.getComponent<FuseVerticalNavigationComponent>(name);
if ( navigation ) if ( navigation )
{ {

View File

@ -3,7 +3,7 @@ import { ActivatedRoute, Data, Router } from '@angular/router';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { FuseMediaWatcherService } from '@fuse/services/media-watcher'; import { FuseMediaWatcherService } from '@fuse/services/media-watcher';
import { FuseNavigationService } from '@fuse/components/navigation'; import { FuseNavigationService, FuseVerticalNavigationComponent } from '@fuse/components/navigation';
import { InitialData } from 'app/app.types'; import { InitialData } from 'app/app.types';
@Component({ @Component({
@ -87,7 +87,7 @@ export class CompactLayoutComponent implements OnInit, OnDestroy
toggleNavigation(name: string): void toggleNavigation(name: string): void
{ {
// Get the navigation // Get the navigation
const navigation = this._fuseNavigationService.getComponent(name); const navigation = this._fuseNavigationService.getComponent<FuseVerticalNavigationComponent>(name);
if ( navigation ) if ( navigation )
{ {

View File

@ -3,7 +3,7 @@ import { ActivatedRoute, Data, Router } from '@angular/router';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { FuseMediaWatcherService } from '@fuse/services/media-watcher'; import { FuseMediaWatcherService } from '@fuse/services/media-watcher';
import { FuseNavigationService } from '@fuse/components/navigation'; import { FuseNavigationService, FuseVerticalNavigationComponent } from '@fuse/components/navigation';
import { InitialData } from 'app/app.types'; import { InitialData } from 'app/app.types';
@Component({ @Component({
@ -88,7 +88,7 @@ export class DenseLayoutComponent implements OnInit, OnDestroy
toggleNavigation(name: string): void toggleNavigation(name: string): void
{ {
// Get the navigation // Get the navigation
const navigation = this._fuseNavigationService.getComponent(name); const navigation = this._fuseNavigationService.getComponent<FuseVerticalNavigationComponent>(name);
if ( navigation ) if ( navigation )
{ {

View File

@ -3,7 +3,7 @@ import { ActivatedRoute, Data, Router } from '@angular/router';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { FuseMediaWatcherService } from '@fuse/services/media-watcher'; import { FuseMediaWatcherService } from '@fuse/services/media-watcher';
import { FuseNavigationService } from '@fuse/components/navigation'; import { FuseNavigationService, FuseVerticalNavigationComponent } from '@fuse/components/navigation';
import { InitialData } from 'app/app.types'; import { InitialData } from 'app/app.types';
@Component({ @Component({
@ -87,7 +87,7 @@ export class FuturisticLayoutComponent implements OnInit, OnDestroy
toggleNavigation(name: string): void toggleNavigation(name: string): void
{ {
// Get the navigation // Get the navigation
const navigation = this._fuseNavigationService.getComponent(name); const navigation = this._fuseNavigationService.getComponent<FuseVerticalNavigationComponent>(name);
if ( navigation ) if ( navigation )
{ {

View File

@ -3,7 +3,7 @@ import { ActivatedRoute, Data, Router } from '@angular/router';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { FuseMediaWatcherService } from '@fuse/services/media-watcher'; import { FuseMediaWatcherService } from '@fuse/services/media-watcher';
import { FuseNavigationService } from '@fuse/components/navigation'; import { FuseNavigationService, FuseVerticalNavigationComponent } from '@fuse/components/navigation';
import { InitialData } from 'app/app.types'; import { InitialData } from 'app/app.types';
@Component({ @Component({
@ -87,7 +87,7 @@ export class ThinLayoutComponent implements OnInit, OnDestroy
toggleNavigation(name: string): void toggleNavigation(name: string): void
{ {
// Get the navigation // Get the navigation
const navigation = this._fuseNavigationService.getComponent(name); const navigation = this._fuseNavigationService.getComponent<FuseVerticalNavigationComponent>(name);
if ( navigation ) if ( navigation )
{ {

View File

@ -2,7 +2,7 @@ import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { FuseNavigationItem, FuseNavigationService } from '@fuse/components/navigation'; import { FuseNavigationItem, FuseNavigationService, FuseVerticalNavigationComponent } from '@fuse/components/navigation';
import { MailboxService } from 'app/modules/admin/apps/mailbox/mailbox.service'; import { MailboxService } from 'app/modules/admin/apps/mailbox/mailbox.service';
import { MailboxComposeComponent } from 'app/modules/admin/apps/mailbox/compose/compose.component'; import { MailboxComposeComponent } from 'app/modules/admin/apps/mailbox/compose/compose.component';
import { labelColorDefs } from 'app/modules/admin/apps/mailbox/mailbox.constants'; import { labelColorDefs } from 'app/modules/admin/apps/mailbox/mailbox.constants';
@ -279,7 +279,7 @@ export class MailboxSidebarComponent implements OnInit, OnDestroy
const inboxFolder = this.folders.find(folder => folder.slug === 'inbox'); const inboxFolder = this.folders.find(folder => folder.slug === 'inbox');
// Get the component -> navigation mock-api -> item // Get the component -> navigation mock-api -> item
const mainNavigationComponent = this._fuseNavigationService.getComponent('mainNavigation'); const mainNavigationComponent = this._fuseNavigationService.getComponent<FuseVerticalNavigationComponent>('mainNavigation');
// If the main navigation component exists... // If the main navigation component exists...
if ( mainNavigationComponent ) if ( mainNavigationComponent )

View File

@ -6,7 +6,7 @@ import { MatDrawer } from '@angular/material/sidenav';
import { fromEvent, Subject } from 'rxjs'; import { fromEvent, Subject } from 'rxjs';
import { filter, takeUntil } from 'rxjs/operators'; import { filter, takeUntil } from 'rxjs/operators';
import { FuseMediaWatcherService } from '@fuse/services/media-watcher'; import { FuseMediaWatcherService } from '@fuse/services/media-watcher';
import { FuseNavigationService } from '@fuse/components/navigation'; import { FuseNavigationService, FuseVerticalNavigationComponent } from '@fuse/components/navigation';
import { Tag, Task } from 'app/modules/admin/apps/tasks/tasks.types'; import { Tag, Task } from 'app/modules/admin/apps/tasks/tasks.types';
import { TasksService } from 'app/modules/admin/apps/tasks/tasks.service'; import { TasksService } from 'app/modules/admin/apps/tasks/tasks.service';
@ -83,7 +83,7 @@ export class TasksListComponent implements OnInit, OnDestroy
setTimeout(() => { setTimeout(() => {
// Get the component -> navigation data -> item // Get the component -> navigation data -> item
const mainNavigationComponent = this._fuseNavigationService.getComponent('mainNavigation'); const mainNavigationComponent = this._fuseNavigationService.getComponent<FuseVerticalNavigationComponent>('mainNavigation');
// If the main navigation component exists... // If the main navigation component exists...
if ( mainNavigationComponent ) if ( mainNavigationComponent )

View File

@ -687,7 +687,7 @@
getNavItem(itemId, navigationName): FuseNavigationItem | null getNavItem(itemId, navigationName): FuseNavigationItem | null
{ {
// Get the component -> navigation data -> item // Get the component -> navigation data -> item
const navComponent = this._fuseNavigationService.getComponent(navigationName); const navComponent = this._fuseNavigationService.getComponent<FuseVerticalNavigationComponent>(navigationName);
// Return if the navigation component does not exist // Return if the navigation component does not exist
if ( !navComponent ) if ( !navComponent )
@ -772,7 +772,7 @@
updateBadgeTitle(itemId, navigationName, title): void updateBadgeTitle(itemId, navigationName, title): void
{ {
// Get the component -> navigation data -> item // Get the component -> navigation data -> item
const navComponent = this._fuseNavigationService.getComponent(navigationName); const navComponent = this._fuseNavigationService.getComponent<FuseVerticalNavigationComponent>(navigationName);
// Return if the navigation component does not exist // Return if the navigation component does not exist
if ( !navComponent ) if ( !navComponent )
@ -850,7 +850,7 @@
toggleDisabled(itemId, navigationName): void toggleDisabled(itemId, navigationName): void
{ {
// Get the component -> navigation data -> item // Get the component -> navigation data -> item
const navComponent = this._fuseNavigationService.getComponent(navigationName); const navComponent = this._fuseNavigationService.getComponent<FuseVerticalNavigationComponent>(navigationName);
// Return if the navigation component does not exist // Return if the navigation component does not exist
if ( !navComponent ) if ( !navComponent )
@ -940,7 +940,7 @@
swapNavigationData(navigationName): void swapNavigationData(navigationName): void
{ {
// Get the component -> navigation data -> item // Get the component -> navigation data -> item
const navComponent = this._fuseNavigationService.getComponent(navigationName); const navComponent = this._fuseNavigationService.getComponent<FuseVerticalNavigationComponent>(navigationName);
// Return if the navigation component does not exist // Return if the navigation component does not exist
if ( !navComponent ) if ( !navComponent )
@ -949,7 +949,7 @@
} }
// A navigation data to replace with // A navigation data to replace with
const newNavigation = [ const newNavigation: FuseNavigationItem[] = [
{ {
id : 'supported-components', id : 'supported-components',
title : 'Supported components', title : 'Supported components',

View File

@ -1,5 +1,5 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { FuseNavigationItem, FuseNavigationService } from '@fuse/components/navigation'; import { FuseNavigationItem, FuseNavigationService, FuseVerticalNavigationComponent } from '@fuse/components/navigation';
import { CoreFeaturesComponent } from 'app/modules/admin/docs/core-features/core-features.component'; import { CoreFeaturesComponent } from 'app/modules/admin/docs/core-features/core-features.component';
@Component({ @Component({
@ -32,8 +32,8 @@ export class NavigationComponent
*/ */
getNavItem(itemId, navigationName): FuseNavigationItem | null getNavItem(itemId, navigationName): FuseNavigationItem | null
{ {
// Get the component -> navigation mock-api -> item // Get the component -> navigation data -> item
const navComponent = this._fuseNavigationService.getComponent(navigationName); const navComponent = this._fuseNavigationService.getComponent<FuseVerticalNavigationComponent>(navigationName);
// Return if the navigation component does not exist // Return if the navigation component does not exist
if ( !navComponent ) if ( !navComponent )
@ -57,8 +57,8 @@ export class NavigationComponent
*/ */
updateBadgeTitle(itemId, navigationName, title): void updateBadgeTitle(itemId, navigationName, title): void
{ {
// Get the component -> navigation mock-api -> item // Get the component -> navigation data -> item
const navComponent = this._fuseNavigationService.getComponent(navigationName); const navComponent = this._fuseNavigationService.getComponent<FuseVerticalNavigationComponent>(navigationName);
// Return if the navigation component does not exist // Return if the navigation component does not exist
if ( !navComponent ) if ( !navComponent )
@ -81,8 +81,8 @@ export class NavigationComponent
*/ */
toggleDisabled(itemId, navigationName): void toggleDisabled(itemId, navigationName): void
{ {
// Get the component -> navigation mock-api -> item // Get the component -> navigation data -> item
const navComponent = this._fuseNavigationService.getComponent(navigationName); const navComponent = this._fuseNavigationService.getComponent<FuseVerticalNavigationComponent>(navigationName);
// Return if the navigation component does not exist // Return if the navigation component does not exist
if ( !navComponent ) if ( !navComponent )
@ -98,14 +98,14 @@ export class NavigationComponent
} }
/** /**
* Swap navigation mock-api * Swap navigation data
* *
* @param navigationName * @param navigationName
*/ */
swapNavigationData(navigationName): void swapNavigationData(navigationName): void
{ {
// Get the component -> navigation mock-api -> item // Get the component -> navigation data -> item
const navComponent = this._fuseNavigationService.getComponent(navigationName); const navComponent = this._fuseNavigationService.getComponent<FuseVerticalNavigationComponent>(navigationName);
// Return if the navigation component does not exist // Return if the navigation component does not exist
if ( !navComponent ) if ( !navComponent )
@ -113,8 +113,8 @@ export class NavigationComponent
return null; return null;
} }
// A navigation mock-api to replace with // A navigation data to replace with
const newNavigation = [ const newNavigation: FuseNavigationItem[] = [
{ {
id : 'supported-components', id : 'supported-components',
title : 'Supported components', title : 'Supported components',
@ -168,7 +168,7 @@ export class NavigationComponent
} }
]; ];
// Replace the navigation mock-api // Replace the navigation data
navComponent.navigation = newNavigation; navComponent.navigation = newNavigation;
navComponent.refresh(); navComponent.refresh();
} }