mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-852] Form style Material 2 (#2151)
* mdl2 transition part form 1 * hyperlink * radio buttons * label * people component * [ADF-852] moved textarea to new angular material * number widget * change error multiline * [ADF-852] added md desgin for dropdown * [ADF-852] removed unused css file * functional widget * error dropdown * [ADF-852] - changed to new md date * remove md-date-time-picker dependency in ng2-alfresco-from * [ADF-852] conversion dynamic table phase 1 * container widget * remove test unused * validation change * [ADF-852] convert dynamic table phase 2 * [ADF-852] improving style and fixing bugs * move custom style for form in form.scss * error footer refactor * fix models and test * [ADF-852]- fixed minor twitch on dynamic table * align fields and fix tests dropdown * disabling button in readonly clean mdl form start process form * align dropdown * [ADF-1048] Upload widget can manage multiple files. (#2134) * [ADF-1048] improving upload widget * [ADF-1048] added ability to upload multiple file on upload widget * [ADF-1048] added multiple upload elements on upload widget * [ADF-1048] - show all the files on the completed form * [ADF-1048] fixed wrong selecion on displya upload * [ADF-1048] removed fdescribe from upload widget * date validation and custom moment data adapter * move content widget in the widget folder * add style fields and theming * color primary radio and checkbox * fix amount widget and colors * change ViewEncapsulation and fix date style button issue * empty form customization 1736 * focus label style * [ADF-224] fix the rendering of custom stencils when form is opened in readonly state. (#2161) * [ADF-224] Fixed rendering of custom stencil in readonly mode * [ADF-224] improved variable name * test fix * container filter in form model creation * show display value correctly * fix change date and test * fix date editor and add some test coverage for date * style minor issue * fix new unused local import rule * fix test date * strict date check * fix analytics failing test * restore null as default in model * unify model diagrams and analytics
This commit is contained in:
committed by
Mario Romano
parent
47ea517ffb
commit
083c9da0d4
@@ -26,7 +26,8 @@ import {
|
||||
OnDestroy,
|
||||
OnInit,
|
||||
ViewChild,
|
||||
ViewContainerRef
|
||||
ViewContainerRef,
|
||||
ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
|
||||
import { CoreModule } from 'ng2-alfresco-core';
|
||||
@@ -41,10 +42,14 @@ declare var adf: any;
|
||||
@Component({
|
||||
selector: 'adf-form-field, form-field',
|
||||
template: `
|
||||
<div [hidden]="!field?.isVisible">
|
||||
<div [hidden]="!field?.isVisible"
|
||||
[class.adf-focus]="focus"
|
||||
(focusin)="focusToggle()"
|
||||
(focusout)="focusToggle()">
|
||||
<div #container></div>
|
||||
</div>
|
||||
`
|
||||
`,
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class FormFieldComponent implements OnInit, OnDestroy {
|
||||
|
||||
@@ -56,33 +61,35 @@ export class FormFieldComponent implements OnInit, OnDestroy {
|
||||
|
||||
componentRef: ComponentRef<{}>;
|
||||
|
||||
constructor(
|
||||
private formRenderingService: FormRenderingService,
|
||||
private componentFactoryResolver: ComponentFactoryResolver,
|
||||
private visibilityService: WidgetVisibilityService,
|
||||
private compiler: Compiler) {
|
||||
focus: boolean = false;
|
||||
|
||||
constructor(private formRenderingService: FormRenderingService,
|
||||
private componentFactoryResolver: ComponentFactoryResolver,
|
||||
private visibilityService: WidgetVisibilityService,
|
||||
private compiler: Compiler) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.field) {
|
||||
let customTemplate = this.field.form.customFieldTemplates[this.field.type];
|
||||
if (customTemplate && this.hasController(this.field.type)) {
|
||||
let factory = this.getComponentFactorySync(this.field.type, customTemplate);
|
||||
let originalField = this.getField();
|
||||
if (originalField) {
|
||||
let customTemplate = this.field.form.customFieldTemplates[originalField.type];
|
||||
if (customTemplate && this.hasController(originalField.type)) {
|
||||
let factory = this.getComponentFactorySync(originalField.type, customTemplate);
|
||||
this.componentRef = this.container.createComponent(factory);
|
||||
let instance: any = this.componentRef.instance;
|
||||
if (instance) {
|
||||
instance.field = this.field;
|
||||
instance.field = originalField;
|
||||
}
|
||||
} else {
|
||||
let componentType = this.formRenderingService.resolveComponentType(this.field);
|
||||
let componentType = this.formRenderingService.resolveComponentType(originalField);
|
||||
if (componentType) {
|
||||
let factory = this.componentFactoryResolver.resolveComponentFactory(componentType);
|
||||
this.componentRef = this.container.createComponent(factory);
|
||||
let instance = <WidgetComponent> this.componentRef.instance;
|
||||
instance.field = this.field;
|
||||
instance.fieldChanged.subscribe(field => {
|
||||
if (field && field.form) {
|
||||
this.visibilityService.refreshVisibility(field.form);
|
||||
if (field && this.field.form) {
|
||||
this.visibilityService.refreshVisibility(this.field.form);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -97,6 +104,10 @@ export class FormFieldComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
private getField() {
|
||||
return (this.field.params && this.field.params.field) ? this.field.params.field : this.field;
|
||||
}
|
||||
|
||||
private hasController(type: string): boolean {
|
||||
return (adf && adf.components && adf.components[type]);
|
||||
}
|
||||
@@ -119,14 +130,19 @@ export class FormFieldComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private createComponentFactorySync(compiler: Compiler, metadata: Component, componentClass: any): ComponentFactory<any> {
|
||||
const cmpClass = componentClass || class RuntimeComponent { };
|
||||
const cmpClass = componentClass || class RuntimeComponent {
|
||||
};
|
||||
const decoratedCmp = Component(metadata)(cmpClass);
|
||||
|
||||
@NgModule({ imports: [CoreModule], declarations: [decoratedCmp] })
|
||||
class RuntimeComponentModule { }
|
||||
class RuntimeComponentModule {
|
||||
}
|
||||
|
||||
let module: ModuleWithComponentFactories<any> = compiler.compileModuleAndAllComponentsSync(RuntimeComponentModule);
|
||||
return module.componentFactories.find(x => x.componentType === decoratedCmp);
|
||||
}
|
||||
|
||||
focusToggle() {
|
||||
this.focus = !this.focus;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user