#964 improve amount editor rendering

- fixed: showing currently symbol for the rows (non-complete forms)
- new: currency symbol for the editor label (row editor)
This commit is contained in:
Denys Vuika
2016-11-02 14:32:31 +00:00
parent 736d57cc2e
commit 52b0ae65e8
4 changed files with 23 additions and 4 deletions

View File

@@ -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 {

View File

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

View File

@@ -7,5 +7,5 @@
[required]="column.required"
[disabled]="!column.editable"
[attr.id]="column.id">
<label class="mdl-textfield__label" [attr.for]="column.id">{{column.name}}</label>
<label class="mdl-textfield__label" [attr.for]="column.id">{{displayName}}</label>
</div>

View File

@@ -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 = (<HTMLInputElement>event.target).value;