Browse Source

refactoring

fix/#23795
erdemcaygor 4 months ago
parent
commit
25f229dd8f
  1. 12
      npm/ng-packs/packages/core/src/lib/components/dynamic-layout.component.ts
  2. 4
      npm/ng-packs/packages/core/src/lib/tokens/default-layout.token.ts
  3. 1
      npm/ng-packs/packages/core/src/lib/tokens/index.ts

12
npm/ng-packs/packages/core/src/lib/components/dynamic-layout.component.ts

@ -1,4 +1,4 @@
import { Component, inject, isDevMode, Type } from '@angular/core'; import { Component, inject, input, isDevMode, Type } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { eLayoutType } from '../enums/common'; import { eLayoutType } from '../enums/common';
import { ABP } from '../models'; import { ABP } from '../models';
@ -14,7 +14,6 @@ import { DYNAMIC_LAYOUTS_TOKEN } from '../tokens/dynamic-layout.token';
import { EnvironmentService } from '../services'; import { EnvironmentService } from '../services';
import { NgComponentOutlet } from '@angular/common'; import { NgComponentOutlet } from '@angular/common';
import { filter, take } from 'rxjs'; import { filter, take } from 'rxjs';
import { DEFAULT_LAYOUT } from '../tokens';
@Component({ @Component({
selector: 'abp-dynamic-layout', selector: 'abp-dynamic-layout',
@ -40,10 +39,13 @@ export class DynamicLayoutComponent {
protected readonly subscription = inject(SubscriptionService); protected readonly subscription = inject(SubscriptionService);
protected readonly routerEvents = inject(RouterEvents); protected readonly routerEvents = inject(RouterEvents);
protected readonly environment = inject(EnvironmentService); protected readonly environment = inject(EnvironmentService);
protected readonly defaultLayout = inject(DEFAULT_LAYOUT, { optional: true }); readonly defaultLayout = input<eLayoutType>(undefined);
constructor() { constructor() {
const dynamicLayoutComponent = inject(DynamicLayoutComponent, { optional: true, skipSelf: true }); const dynamicLayoutComponent = inject(DynamicLayoutComponent, {
optional: true,
skipSelf: true,
});
if (dynamicLayoutComponent) { if (dynamicLayoutComponent) {
if (isDevMode()) console.warn('DynamicLayoutComponent must be used only in AppComponent.'); if (isDevMode()) console.warn('DynamicLayoutComponent must be used only in AppComponent.');
@ -91,7 +93,7 @@ export class DynamicLayoutComponent {
break; break;
} }
} }
return expectedLayout ?? this.defaultLayout; return expectedLayout ?? this.defaultLayout();
} }
showLayoutNotFoundError(layoutName: string) { showLayoutNotFoundError(layoutName: string) {

4
npm/ng-packs/packages/core/src/lib/tokens/default-layout.token.ts

@ -1,4 +0,0 @@
import { InjectionToken } from '@angular/core';
import { eLayoutType } from '@abp/ng.core';
export const DEFAULT_LAYOUT = new InjectionToken<eLayoutType>('');

1
npm/ng-packs/packages/core/src/lib/tokens/index.ts

@ -18,4 +18,3 @@ export * from './compare-func.token';
export * from './dynamic-layout.token'; export * from './dynamic-layout.token';
export * from './title-strategy-disable-project-name.token'; export * from './title-strategy-disable-project-name.token';
export * from './ssr-state.token'; export * from './ssr-state.token';
export * from './default-layout.token';

Loading…
Cancel
Save