#469 Plain Header widget

This commit is contained in:
Denys Vuika
2016-07-26 11:04:31 +01:00
parent 9d34ea1d7f
commit ef0c77a162
5 changed files with 57 additions and 28 deletions

View File

@@ -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;
}

View File

@@ -1,25 +1,30 @@
<div class="mdl-grid">
<div *ngFor="let col of content.columns" class="mdl-cell mdl-cell--{{col.size}}-col">
<div class="mdl-grid" *ngIf="col.hasFields()">
<div *ngFor="let field of col.fields" class="mdl-cell mdl-cell--12-col">
<div [ngSwitch]="field.type">
<div *ngSwitchCase="'integer'">
<number-widget [field]="field"></number-widget>
</div>
<div *ngSwitchCase="'text'">
<text-widget [field]="field"></text-widget>
</div>
<div *ngSwitchCase="'multi-line-text'">
<multiline-text-widget [field]="field"></multiline-text-widget>
</div>
<div *ngSwitchCase="'boolean'">
<checkbox-widget [field]="field"></checkbox-widget>
</div>
<div *ngSwitchCase="'dropdown'">
<dropdown-widget [field]="field"></dropdown-widget>
</div>
<div *ngSwitchDefault>
<span>UNKNOWN WIDGET TYPE: {{field.type}}</span>
<div class="container-widget">
<div *ngIf="content?.isGroup()" class="container-widget__header">
<h3 class="container-widget__header-text">{{content.name}}</h3>
</div>
<div class="mdl-grid">
<div *ngFor="let col of content.columns" class="mdl-cell mdl-cell--{{col.size}}-col">
<div class="mdl-grid" *ngIf="col.hasFields()">
<div *ngFor="let field of col.fields" class="mdl-cell mdl-cell--12-col">
<div [ngSwitch]="field.type">
<div *ngSwitchCase="'integer'">
<number-widget [field]="field"></number-widget>
</div>
<div *ngSwitchCase="'text'">
<text-widget [field]="field"></text-widget>
</div>
<div *ngSwitchCase="'multi-line-text'">
<multiline-text-widget [field]="field"></multiline-text-widget>
</div>
<div *ngSwitchCase="'boolean'">
<checkbox-widget [field]="field"></checkbox-widget>
</div>
<div *ngSwitchCase="'dropdown'">
<dropdown-widget [field]="field"></dropdown-widget>
</div>
<div *ngSwitchDefault>
<span>UNKNOWN WIDGET TYPE: {{field.type}}</span>
</div>
</div>
</div>
</div>

View File

@@ -31,6 +31,7 @@ declare var componentHandler;
moduleId: __moduleName,
selector: 'container-widget',
templateUrl: './container.widget.html',
styleUrls: ['./container.widget.css'],
directives: [
TextWidget,
NumberWidget,

View File

@@ -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();
}

View File

@@ -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 = <boolean> json.hasEmptyValue;
this.className = json.className;
this.optionType = json.optionType;
this.params = <FormFieldMetadata> json.params || {};
this._value = this.parseValue(json);
this.updateForm();
@@ -109,7 +120,7 @@ export class FormFieldModel extends FormWidgetModel {
but saving back as object: { id: <id>, name: <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: <id>, name: <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);