From 52b0ae65e839d94a10f9f553641a7bc300f01912 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Wed, 2 Nov 2016 14:32:31 +0000 Subject: [PATCH] #964 improve amount editor rendering - fixed: showing currently symbol for the rows (non-complete forms) - new: currency symbol for the editor label (row editor) --- .../src/components/widgets/core/dynamic-table.model.ts | 9 +++++++++ .../widgets/dynamic-table/dynamic-table.widget.ts | 6 +++++- .../dynamic-table/editors/text/text.editor.html | 2 +- .../widgets/dynamic-table/editors/text/text.editor.ts | 10 ++++++++-- 4 files changed, 23 insertions(+), 4 deletions(-) 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 ccdfcf4508..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 @@ -161,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 { diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/dynamic-table/dynamic-table.widget.ts b/ng2-components/ng2-activiti-form/src/components/widgets/dynamic-table/dynamic-table.widget.ts index 47ff3e2a0f..fe017837f4 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/dynamic-table/dynamic-table.widget.ts +++ b/ng2-components/ng2-activiti-form/src/components/widgets/dynamic-table/dynamic-table.widget.ts @@ -97,7 +97,11 @@ export class DynamicTableWidget extends WidgetComponent { getCellValue(row: DynamicTableRow, column: DynamicTableColumn): any { if (this.content) { - return this.content.getCellValue(row, column); + let result = this.content.getCellValue(row, column); + if (column.type === 'Amount') { + return (column.amountCurrency || '$') + ' ' + (result || 0); + } + return result; } return null; } diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/dynamic-table/editors/text/text.editor.html b/ng2-components/ng2-activiti-form/src/components/widgets/dynamic-table/editors/text/text.editor.html index 69308bcd02..3e702fd673 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/dynamic-table/editors/text/text.editor.html +++ b/ng2-components/ng2-activiti-form/src/components/widgets/dynamic-table/editors/text/text.editor.html @@ -7,5 +7,5 @@ [required]="column.required" [disabled]="!column.editable" [attr.id]="column.id"> - + 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;