From ef0c77a1628e9c252c6f0d9ba0e9d7452603c511 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Tue, 26 Jul 2016 11:04:31 +0100 Subject: [PATCH] #469 Plain Header widget --- .../widgets/container/container.widget.css | 9 ++++ .../widgets/container/container.widget.html | 49 ++++++++++--------- .../widgets/container/container.widget.ts | 1 + .../widgets/dropdown/dropdown.widget.ts | 5 +- .../src/components/widgets/widget.model.ts | 21 ++++++-- 5 files changed, 57 insertions(+), 28 deletions(-) create mode 100644 ng2-components/ng2-activiti-form/src/components/widgets/container/container.widget.css diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/container/container.widget.css b/ng2-components/ng2-activiti-form/src/components/widgets/container/container.widget.css new file mode 100644 index 0000000000..2973977f9a --- /dev/null +++ b/ng2-components/ng2-activiti-form/src/components/widgets/container/container.widget.css @@ -0,0 +1,9 @@ +.container-widget {} + +.container-widget__header {} + +.container-widget__header-text { + border-bottom: 1px solid rgba(0,0,0,.87); + margin-left: 10px; + margin-right: 10px; +} diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/container/container.widget.html b/ng2-components/ng2-activiti-form/src/components/widgets/container/container.widget.html index 7fb027bd54..a190e528b8 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/container/container.widget.html +++ b/ng2-components/ng2-activiti-form/src/components/widgets/container/container.widget.html @@ -1,25 +1,30 @@ -
-
-
-
-
-
- -
-
- -
-
- -
-
- -
-
- -
-
- UNKNOWN WIDGET TYPE: {{field.type}} +
+
+

{{content.name}}

+
+
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ UNKNOWN WIDGET TYPE: {{field.type}} +
diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/container/container.widget.ts b/ng2-components/ng2-activiti-form/src/components/widgets/container/container.widget.ts index 1d41214674..6e0b3b88ad 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/container/container.widget.ts +++ b/ng2-components/ng2-activiti-form/src/components/widgets/container/container.widget.ts @@ -31,6 +31,7 @@ declare var componentHandler; moduleId: __moduleName, selector: 'container-widget', templateUrl: './container.widget.html', + styleUrls: ['./container.widget.css'], directives: [ TextWidget, NumberWidget, diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/dropdown/dropdown.widget.ts b/ng2-components/ng2-activiti-form/src/components/widgets/dropdown/dropdown.widget.ts index c098b801e2..c5d61526e5 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/dropdown/dropdown.widget.ts +++ b/ng2-components/ng2-activiti-form/src/components/widgets/dropdown/dropdown.widget.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { Component, OnInit, NgZone } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { Observable } from 'rxjs/Rx'; import { Http } from '@angular/http'; import { ObjectUtils } from 'ng2-alfresco-core'; @@ -32,8 +32,7 @@ declare var componentHandler; }) export class DropdownWidget extends WidgetComponent implements OnInit { - constructor(private http: Http, - private zone: NgZone) { + constructor(private http: Http) { super(); } diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/widget.model.ts b/ng2-components/ng2-activiti-form/src/components/widgets/widget.model.ts index 363efbb0c9..d1c85baa7a 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/widget.model.ts +++ b/ng2-components/ng2-activiti-form/src/components/widgets/widget.model.ts @@ -15,10 +15,19 @@ * limitations under the License. */ -export interface FormValues { +export interface FormFieldMetadata { [key: string]: any; } +export interface FormValues extends FormFieldMetadata { +} + +export class FormFieldTypes { + static CONTAINER: string = 'container'; + static GROUP: string = 'group'; + static DROPDOWN: string = 'dropdown'; +} + export class FormWidgetModel { private _form: FormModel; @@ -64,6 +73,7 @@ export class FormFieldModel extends FormWidgetModel { hasEmptyValue: boolean; className: string; optionType: string; + params: FormFieldMetadata = {}; get value(): any { return this._value; @@ -95,6 +105,7 @@ export class FormFieldModel extends FormWidgetModel { this.hasEmptyValue = json.hasEmptyValue; this.className = json.className; this.optionType = json.optionType; + this.params = json.params || {}; this._value = this.parseValue(json); this.updateForm(); @@ -109,7 +120,7 @@ export class FormFieldModel extends FormWidgetModel { but saving back as object: { id: , name: } */ // TODO: needs review - if (json.fieldType === 'RestFieldRepresentation') { + if (json.type === FormFieldTypes.DROPDOWN) { if (value === '') { value = 'empty'; } @@ -123,7 +134,7 @@ export class FormFieldModel extends FormWidgetModel { This is needed due to Activiti reading dropdown values as string but saving back as object: { id: , name: } */ - if (this.fieldType === 'RestFieldRepresentation') { + if (this.type === FormFieldTypes.DROPDOWN) { if (this.value === 'empty' || this.value === '') { this.form.values[this.id] = {}; } else { @@ -159,6 +170,10 @@ export class ContainerModel extends FormWidgetModel { columns: ContainerColumnModel[] = []; + isGroup(): boolean { + return this.type == FormFieldTypes.GROUP; + } + constructor(form: FormModel, json?: any) { super(form, json);