Browse Source

update ABP.Root interface and core module providers

pull/19850/head
Sinan997 2 years ago
parent
commit
71d43495c6
  1. 4
      docs/en/UI/Angular/Title-Strategy-Service.md
  2. 17
      npm/ng-packs/packages/core/src/lib/core.module.ts
  3. 1
      npm/ng-packs/packages/core/src/lib/models/common.ts
  4. 3
      npm/ng-packs/packages/core/src/lib/services/title-strategy.service.ts

4
docs/en/UI/Angular/Title-Strategy-Service.md

@ -4,7 +4,7 @@
This strategy is based on the title property. Provide a title property when setting a new route. This strategy is based on the title property. Provide a title property when setting a new route.
**Example:** **Example**
```ts ```ts
{ {
@ -14,8 +14,6 @@ This strategy is based on the title property. Provide a title property when sett
}, },
``` ```
**`Note:`**
- It is better to use localized text in the title property. It will be translated by **LocalizationService**. - It is better to use localized text in the title property. It will be translated by **LocalizationService**.
- The **`title`** property is already set in **ABP internal packages**. - The **`title`** property is already set in **ABP internal packages**.

17
npm/ng-packs/packages/core/src/lib/core.module.ts

@ -24,7 +24,7 @@ import { ToInjectorPipe } from './pipes/to-injector.pipe';
import { CookieLanguageProvider } from './providers/cookie-language.provider'; import { CookieLanguageProvider } from './providers/cookie-language.provider';
import { LocaleProvider } from './providers/locale.provider'; import { LocaleProvider } from './providers/locale.provider';
import { LocalizationService } from './services/localization.service'; import { LocalizationService } from './services/localization.service';
import { OTHERS_GROUP } from './tokens'; import { DISABLE_PROJECT_NAME, OTHERS_GROUP } from './tokens';
import { localizationContributor, LOCALIZATIONS } from './tokens/localization.token'; import { localizationContributor, LOCALIZATIONS } from './tokens/localization.token';
import { CORE_OPTIONS, coreOptionsFactory } from './tokens/options.token'; import { CORE_OPTIONS, coreOptionsFactory } from './tokens/options.token';
import { TENANT_KEY } from './tokens/tenant-key.token'; import { TENANT_KEY } from './tokens/tenant-key.token';
@ -40,12 +40,11 @@ import { DefaultQueueManager } from './utils/queue';
import { IncludeLocalizationResourcesProvider } from './providers/include-localization-resources.provider'; import { IncludeLocalizationResourcesProvider } from './providers/include-localization-resources.provider';
import { SORT_COMPARE_FUNC, compareFuncFactory } from './tokens/compare-func.token'; import { SORT_COMPARE_FUNC, compareFuncFactory } from './tokens/compare-func.token';
import { AuthErrorFilterService } from './abstracts'; import { AuthErrorFilterService } from './abstracts';
import { DYNAMIC_LAYOUTS_TOKEN } from "./tokens/dynamic-layout.token"; import { DYNAMIC_LAYOUTS_TOKEN } from './tokens/dynamic-layout.token';
import { DEFAULT_DYNAMIC_LAYOUTS } from "./constants"; import { DEFAULT_DYNAMIC_LAYOUTS } from './constants';
import { AbpTitleStrategy } from './services/title-strategy.service'; import { AbpTitleStrategy } from './services/title-strategy.service';
import { LocalStorageListenerService } from './services/local-storage-listener.service'; import { LocalStorageListenerService } from './services/local-storage-listener.service';
const standaloneDirectives = [ const standaloneDirectives = [
AutofocusDirective, AutofocusDirective,
InputEventDebounceDirective, InputEventDebounceDirective,
@ -201,12 +200,16 @@ export class CoreModule {
IncludeLocalizationResourcesProvider, IncludeLocalizationResourcesProvider,
{ {
provide: DYNAMIC_LAYOUTS_TOKEN, provide: DYNAMIC_LAYOUTS_TOKEN,
useValue: options.dynamicLayouts || DEFAULT_DYNAMIC_LAYOUTS useValue: options.dynamicLayouts || DEFAULT_DYNAMIC_LAYOUTS,
}, },
{ {
provide: TitleStrategy, provide: TitleStrategy,
useExisting: AbpTitleStrategy useExisting: AbpTitleStrategy,
} },
{
provide: DISABLE_PROJECT_NAME,
useValue: options.disableProjectNameInTitle || false,
},
], ],
}; };
} }

1
npm/ng-packs/packages/core/src/lib/models/common.ts

@ -15,6 +15,7 @@ export namespace ABP {
localizations?: Localization[]; localizations?: Localization[];
othersGroup?: string; othersGroup?: string;
dynamicLayouts?: Map<string, string>; dynamicLayouts?: Map<string, string>;
disableProjectNameInTitle?: boolean;
} }
export interface Child { export interface Child {

3
npm/ng-packs/packages/core/src/lib/services/title-strategy.service.ts

@ -11,7 +11,7 @@ import { DISABLE_PROJECT_NAME } from '../tokens';
export class AbpTitleStrategy extends TitleStrategy { export class AbpTitleStrategy extends TitleStrategy {
protected readonly title = inject(Title); protected readonly title = inject(Title);
protected readonly localizationService = inject(LocalizationService); protected readonly localizationService = inject(LocalizationService);
protected readonly disableProjectName = inject(DISABLE_PROJECT_NAME, { optional: true }) || false; protected readonly disableProjectName = inject(DISABLE_PROJECT_NAME, { optional: true });
protected routerState: RouterStateSnapshot; protected routerState: RouterStateSnapshot;
langugageChange = toSignal(this.localizationService.languageChange$); langugageChange = toSignal(this.localizationService.languageChange$);
@ -26,7 +26,6 @@ export class AbpTitleStrategy extends TitleStrategy {
} }
override updateTitle(routerState: RouterStateSnapshot) { override updateTitle(routerState: RouterStateSnapshot) {
// routerState assignment is necessary for the language change
this.routerState = routerState; this.routerState = routerState;
const title = this.buildTitle(routerState); const title = this.buildTitle(routerState);

Loading…
Cancel
Save