#967 custom stencil mapping demo

This commit is contained in:
Denys Vuika
2016-11-16 11:22:41 +00:00
committed by Mario Romano
parent be2a571608
commit 24daa074e0
2 changed files with 15 additions and 12 deletions

View File

@@ -31,7 +31,7 @@ import {
} from 'ng2-alfresco-datatable'; } from 'ng2-alfresco-datatable';
import { FormRenderingService } from 'ng2-activiti-form'; import { FormRenderingService } from 'ng2-activiti-form';
import { CustomEditorComponent } from './custom-editor/custom-editor.component'; import { /*CustomEditorComponent*/ CustomStencil01 } from './custom-editor/custom-editor.component';
declare let __moduleName: string; declare let __moduleName: string;
declare var componentHandler; declare var componentHandler;
@@ -111,6 +111,9 @@ export class ActivitiDemoComponent implements AfterViewChecked {
// Uncomment this line to replace all 'text' field editors with custom component // Uncomment this line to replace all 'text' field editors with custom component
// formRenderingService.setComponentTypeResolver('text', () => CustomEditorComponent, true); // formRenderingService.setComponentTypeResolver('text', () => CustomEditorComponent, true);
// Uncomment this line to map 'custom_stencil_01' to local editor component
formRenderingService.setComponentTypeResolver('custom_stencil_01', () => CustomStencil01, true);
} }
ngOnInit() { ngOnInit() {

View File

@@ -1,5 +1,5 @@
import { NgModule, Component, ElementRef } from '@angular/core'; import { NgModule, Component } from '@angular/core';
import { TextFieldWidgetComponent } from 'ng2-activiti-form'; import { WidgetComponent } from 'ng2-activiti-form';
@Component({ @Component({
selector: 'custom-editor', selector: 'custom-editor',
@@ -7,17 +7,17 @@ import { TextFieldWidgetComponent } from 'ng2-activiti-form';
<div style="color: red">Look, I'm a custom editor!</div> <div style="color: red">Look, I'm a custom editor!</div>
` `
}) })
export class CustomEditorComponent extends TextFieldWidgetComponent { export class CustomEditorComponent extends WidgetComponent {}
constructor(elementRef: ElementRef) { @Component({
super(elementRef); selector: 'custom-stencil-01',
} template: `<div style="color: green">ADF version of custom Activiti stencil</div>`
})
} export class CustomStencil01 extends WidgetComponent {}
@NgModule({ @NgModule({
declarations: [ CustomEditorComponent ], declarations: [ CustomEditorComponent, CustomStencil01 ],
exports: [ CustomEditorComponent ], exports: [ CustomEditorComponent, CustomStencil01 ],
entryComponents: [ CustomEditorComponent ] entryComponents: [ CustomEditorComponent, CustomStencil01 ]
}) })
export class CustomEditorsModule {} export class CustomEditorsModule {}