From a140421082e698e0f1dbb13bd95c83cc3fd76254 Mon Sep 17 00:00:00 2001 From: develite98 Date: Thu, 4 Jan 2024 18:14:38 +0700 Subject: [PATCH] feat(4ps): update --- .../src/bases/base-page-component.ts | 25 +++++++++++++++++++ libs/mix-share/src/bases/index.ts | 1 + .../src/modules/database/database.layout.html | 2 +- .../src/modules/database/database.layout.ts | 23 +++-------------- .../modules/layout/mix-layout.component.html | 2 +- 5 files changed, 31 insertions(+), 22 deletions(-) create mode 100644 libs/mix-share/src/bases/base-page-component.ts diff --git a/libs/mix-share/src/bases/base-page-component.ts b/libs/mix-share/src/bases/base-page-component.ts new file mode 100644 index 00000000..5c0bac79 --- /dev/null +++ b/libs/mix-share/src/bases/base-page-component.ts @@ -0,0 +1,25 @@ +import { + Directive, + TemplateRef, + ViewChild, + ViewContainerRef, + inject, +} from '@angular/core'; +import { ToolbarService } from '@mixcore/share/components'; +import { BaseComponent } from './base-component'; + +@Directive() +export class BasePageComponent extends BaseComponent { + @ViewChild('breadcrumb') public breadcrumb?: TemplateRef; + public toolbarService = inject(ToolbarService); + public viewRef = inject(ViewContainerRef); + + ngAfterViewInit() { + if (this.breadcrumb) this.toolbarService.add(this.breadcrumb, this.viewRef); + } + + override ngOnDestroy() { + super.ngOnDestroy(); + this.toolbarService.remove(); + } +} diff --git a/libs/mix-share/src/bases/index.ts b/libs/mix-share/src/bases/index.ts index 9bdbb66d..a3349a51 100644 --- a/libs/mix-share/src/bases/index.ts +++ b/libs/mix-share/src/bases/index.ts @@ -2,3 +2,4 @@ export * from './base-api.service'; export * from './base-appconfig'; export * from './base-component'; export * from './base-crud.store'; +export * from './base-page-component'; diff --git a/libs/mix-share/src/modules/database/database.layout.html b/libs/mix-share/src/modules/database/database.layout.html index c6b02278..8e8c7cef 100644 --- a/libs/mix-share/src/modules/database/database.layout.html +++ b/libs/mix-share/src/modules/database/database.layout.html @@ -1,6 +1,6 @@ - +