From 24daa074e0ffd10efacbdca7930c3d7aee9fc364 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Wed, 16 Nov 2016 11:22:41 +0000 Subject: [PATCH] #967 custom stencil mapping demo --- .../activiti/activiti-demo.component.ts | 5 ++++- .../custom-editor/custom-editor.component.ts | 22 +++++++++---------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts b/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts index ba84820db7..62c1e1f039 100644 --- a/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts +++ b/demo-shell-ng2/app/components/activiti/activiti-demo.component.ts @@ -31,7 +31,7 @@ import { } from 'ng2-alfresco-datatable'; 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 var componentHandler; @@ -111,6 +111,9 @@ export class ActivitiDemoComponent implements AfterViewChecked { // Uncomment this line to replace all 'text' field editors with custom component // 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() { diff --git a/demo-shell-ng2/app/components/activiti/custom-editor/custom-editor.component.ts b/demo-shell-ng2/app/components/activiti/custom-editor/custom-editor.component.ts index 549df2da29..b71a11ae3c 100644 --- a/demo-shell-ng2/app/components/activiti/custom-editor/custom-editor.component.ts +++ b/demo-shell-ng2/app/components/activiti/custom-editor/custom-editor.component.ts @@ -1,5 +1,5 @@ -import { NgModule, Component, ElementRef } from '@angular/core'; -import { TextFieldWidgetComponent } from 'ng2-activiti-form'; +import { NgModule, Component } from '@angular/core'; +import { WidgetComponent } from 'ng2-activiti-form'; @Component({ selector: 'custom-editor', @@ -7,17 +7,17 @@ import { TextFieldWidgetComponent } from 'ng2-activiti-form';
Look, I'm a custom editor!
` }) -export class CustomEditorComponent extends TextFieldWidgetComponent { +export class CustomEditorComponent extends WidgetComponent {} - constructor(elementRef: ElementRef) { - super(elementRef); - } - -} +@Component({ + selector: 'custom-stencil-01', + template: `
ADF version of custom Activiti stencil
` +}) +export class CustomStencil01 extends WidgetComponent {} @NgModule({ - declarations: [ CustomEditorComponent ], - exports: [ CustomEditorComponent ], - entryComponents: [ CustomEditorComponent ] + declarations: [ CustomEditorComponent, CustomStencil01 ], + exports: [ CustomEditorComponent, CustomStencil01 ], + entryComponents: [ CustomEditorComponent, CustomStencil01 ] }) export class CustomEditorsModule {}