diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/core/dynamic-table.model.ts b/ng2-components/ng2-activiti-form/src/components/widgets/core/dynamic-table.model.ts
index 175f0a2fdb..257beb93ae 100644
--- a/ng2-components/ng2-activiti-form/src/components/widgets/core/dynamic-table.model.ts
+++ b/ng2-components/ng2-activiti-form/src/components/widgets/core/dynamic-table.model.ts
@@ -69,6 +69,7 @@ export class DynamicTableModel extends FormWidgetModel {
this._validators = [
new RequiredCellValidator(),
+ new DateCellValidator(),
new NumberCellValidator()
];
}
@@ -160,6 +161,15 @@ export class DynamicTableModel extends FormWidgetModel {
return result || '';
}
+
+ getDisplayText(column: DynamicTableColumn): string {
+ let result = column.name;
+ if (column.type === 'Amount') {
+ let currency = column.amountCurrency || '$';
+ result = `${column.name} (${currency})`;
+ }
+ return result;
+ }
}
export interface DynamicRowValidationSummary {
@@ -206,7 +216,34 @@ export class RequiredCellValidator implements CellValidator {
return true;
}
+}
+export class DateCellValidator implements CellValidator {
+
+ private supportedTypes: string[] = [
+ 'Date'
+ ];
+
+ isSupported(column: DynamicTableColumn): boolean {
+ return column && column.editable && this.supportedTypes.indexOf(column.type) > -1;
+ }
+
+ validate(row: DynamicTableRow, column: DynamicTableColumn, summary?: DynamicRowValidationSummary): boolean {
+
+ if (this.isSupported(column)) {
+ let value = row.value[column.id];
+ let dateValue = moment(value, 'D-M-YYYY');
+ if (!dateValue.isValid()) {
+ if (summary) {
+ summary.isValid = false;
+ summary.text = `Invalid '${column.name}' format.`;
+ }
+ return false;
+ }
+ }
+
+ return true;
+ }
}
export class NumberCellValidator implements CellValidator {
diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/date/date.widget.ts b/ng2-components/ng2-activiti-form/src/components/widgets/date/date.widget.ts
index 84a414d7c1..297f0b5fc3 100644
--- a/ng2-components/ng2-activiti-form/src/components/widgets/date/date.widget.ts
+++ b/ng2-components/ng2-activiti-form/src/components/widgets/date/date.widget.ts
@@ -38,7 +38,8 @@ export class DateWidget extends TextFieldWidgetComponent implements OnInit, Afte
let settings: any = {
type: 'date',
- future: moment().add(21, 'years')
+ past: moment().subtract(100, 'years'),
+ future: moment().add(100, 'years')
};
if (this.field) {
diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/dynamic-table/dynamic-table.widget.css b/ng2-components/ng2-activiti-form/src/components/widgets/dynamic-table/dynamic-table.widget.css
index 7f133c4f0a..140696a06f 100644
--- a/ng2-components/ng2-activiti-form/src/components/widgets/dynamic-table/dynamic-table.widget.css
+++ b/ng2-components/ng2-activiti-form/src/components/widgets/dynamic-table/dynamic-table.widget.css
@@ -8,6 +8,11 @@
}
.dynamic-table-widget__table {
+ overflow-y: auto;
+ width: 100%;
+}
+
+.dynamic-table-widget__table > table {
width: 100%;
}
diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/dynamic-table/dynamic-table.widget.html b/ng2-components/ng2-activiti-form/src/components/widgets/dynamic-table/dynamic-table.widget.html
index dd39213e6c..3a1bfc2117 100644
--- a/ng2-components/ng2-activiti-form/src/components/widgets/dynamic-table/dynamic-table.widget.html
+++ b/ng2-components/ng2-activiti-form/src/components/widgets/dynamic-table/dynamic-table.widget.html
@@ -2,26 +2,28 @@
+
diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/dynamic-table/editors/text/text.editor.ts b/ng2-components/ng2-activiti-form/src/components/widgets/dynamic-table/editors/text/text.editor.ts
index 6435fb0fe5..8e0bdf35e3 100644
--- a/ng2-components/ng2-activiti-form/src/components/widgets/dynamic-table/editors/text/text.editor.ts
+++ b/ng2-components/ng2-activiti-form/src/components/widgets/dynamic-table/editors/text/text.editor.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { Component } from '@angular/core';
+import { Component, OnInit } from '@angular/core';
import { CellEditorComponent } from './../cell.editor';
import { DynamicTableRow, DynamicTableColumn } from './../../../core/index';
@@ -25,7 +25,13 @@ import { DynamicTableRow, DynamicTableColumn } from './../../../core/index';
templateUrl: './text.editor.html',
styleUrls: ['./text.editor.css']
})
-export class TextEditorComponent extends CellEditorComponent {
+export class TextEditorComponent extends CellEditorComponent implements OnInit {
+
+ displayName: string;
+
+ ngOnInit() {
+ this.displayName = this.table.getDisplayText(this.column);
+ }
onValueChanged(row: DynamicTableRow, column: DynamicTableColumn, event: any) {
let value: any = (
event.target).value;