mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
#469 Plain Header widget
This commit is contained in:
@@ -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;
|
||||
}
|
@@ -1,4 +1,8 @@
|
||||
<div class="mdl-grid">
|
||||
<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">
|
||||
@@ -25,4 +29,5 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -31,6 +31,7 @@ declare var componentHandler;
|
||||
moduleId: __moduleName,
|
||||
selector: 'container-widget',
|
||||
templateUrl: './container.widget.html',
|
||||
styleUrls: ['./container.widget.css'],
|
||||
directives: [
|
||||
TextWidget,
|
||||
NumberWidget,
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user