mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
ACS-8198 add injection to component data
This commit is contained in:
committed by
Darya Blavanovich
parent
d8634c901a
commit
f1fab8700a
@@ -35,6 +35,7 @@ export interface DialogData {
|
||||
descriptionTemplate?: TemplateRef<any>;
|
||||
headerIcon?: string;
|
||||
additionalActionButtons?: AdditionalDialogActionButton[];
|
||||
componentData: any;
|
||||
}
|
||||
|
||||
export interface AdditionalDialogActionButton {
|
||||
|
@@ -37,7 +37,7 @@
|
||||
|
||||
<mat-dialog-content *ngIf="data.contentTemplate || data.contentComponent || data.contentText" class="adf-dialog-content">
|
||||
<ng-container [ngTemplateOutlet]="data.contentTemplate"></ng-container>
|
||||
<ng-container [ngComponentOutlet]="data.contentComponent"></ng-container>
|
||||
<ng-container *ngComponentOutlet="data.contentComponent; injector: dataInjector"></ng-container>
|
||||
<ng-container>{{ data.contentText }}</ng-container>
|
||||
</mat-dialog-content>
|
||||
|
||||
|
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Inject, OnDestroy, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, Inject, InjectionToken, Injector, OnDestroy, ViewEncapsulation } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { AdditionalDialogActionButton, DialogData } from './dialog-data.interface';
|
||||
import { BehaviorSubject, Subject } from 'rxjs';
|
||||
@@ -25,6 +25,8 @@ import { CommonModule } from '@angular/common';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
|
||||
export const DIALOG_COMPONENT_DATA = new InjectionToken<any>('dialog component data');
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
selector: 'adf-dialog',
|
||||
@@ -42,6 +44,8 @@ export class DialogComponent implements OnDestroy {
|
||||
dialogSize: DialogSizes;
|
||||
additionalActionButtons: AdditionalDialogActionButton[];
|
||||
|
||||
dataInjector: Injector;
|
||||
|
||||
private onDestroy$ = new Subject<void>();
|
||||
|
||||
constructor(
|
||||
@@ -57,6 +61,9 @@ export class DialogComponent implements OnDestroy {
|
||||
this.cancelButtonTitle = data.cancelButtonTitle || 'COMMON.CANCEL';
|
||||
this.additionalActionButtons = data.additionalActionButtons;
|
||||
this.dialogRef.addPanelClass(`${this.dialogSize}-dialog-panel`);
|
||||
this.dataInjector = Injector.create({
|
||||
providers: [{ provide: DIALOG_COMPONENT_DATA, useValue: data.componentData }]
|
||||
});
|
||||
|
||||
if (data.isConfirmButtonDisabled$) {
|
||||
data.isConfirmButtonDisabled$.pipe(takeUntil(this.onDestroy$)).subscribe((value) => this.isConfirmButtonDisabled$.next(value));
|
||||
|
Reference in New Issue
Block a user