[ADF-1329] Fix grid style in the activiti form (#2223)

* Fix form grid style

* Tests
This commit is contained in:
Popovics András
2017-08-16 10:46:41 +02:00
committed by Mario Romano
parent f797e7df6a
commit 9e5b19e34c
5 changed files with 108 additions and 17 deletions

View File

@@ -19,6 +19,7 @@
import { AfterViewInit, Component, OnInit, ViewEncapsulation } from '@angular/core';
import { FormService } from './../../../services/form.service';
import { FormFieldModel } from './../core/form-field.model';
import { baseHost , WidgetComponent } from './../widget.component';
import { ContainerWidgetComponentModel } from './container.widget.model';
@@ -48,4 +49,39 @@ export class ContainerWidgetComponent extends WidgetComponent implements OnInit,
this.content = new ContainerWidgetComponentModel(this.field);
}
}
/**
* Serializes column fields
*/
get fields(): FormFieldModel[] {
const fields = [];
let rowContainsElement = true,
rowIndex = 0;
while (rowContainsElement) {
rowContainsElement = false;
for (let i = 0; i < this.content.columns.length; i++ ) {
let field = this.content.columns[i].fields[rowIndex];
if (field) {
rowContainsElement = true;
}
fields.push(field);
}
rowIndex++;
}
return fields;
}
/**
* Calculate the column width based on the numberOfColumns and current field's colspan property
*
* @param field
*/
getColumnWith(field: FormFieldModel): string {
const colspan = field ? field.colspan : 1;
return (100 / this.content.json.numberOfColumns) * colspan + '%';
}
}