#964 support currency symbols for amount column

This commit is contained in:
Denys Vuika
2016-11-01 11:53:43 +00:00
parent 6d2186d0ef
commit da2208090b
2 changed files with 33 additions and 0 deletions

View File

@@ -641,4 +641,33 @@ describe('DisplayValueWidget', () => {
expect(widget.getCellValue(row, column)).toBe(''); expect(widget.getCellValue(row, column)).toBe('');
}); });
it('should prepend default amount currency', () => {
const value = '10';
let row = <DynamicTableRow> { value: { key: value } };
let column = <DynamicTableColumn> { id: 'key', type: 'Amount' };
const expected = `$ ${value}`;
expect(widget.getCellValue(row, column)).toBe(expected);
});
it('should prepend custom amount currency', () => {
const value = '10';
const currency = 'GBP';
let row = <DynamicTableRow> { value: { key: value } };
let column = <DynamicTableColumn> { id: 'key', type: 'Amount', amountCurrency: currency };
const expected = `${currency} ${value}`;
expect(widget.getCellValue(row, column)).toBe(expected);
});
it('should use zero for missing amount', () => {
const value = null;
const currency = 'GBP';
let row = <DynamicTableRow> { value: { key: value } };
let column = <DynamicTableColumn> { id: 'key', type: 'Amount', amountCurrency: currency };
const expected = `${currency} 0`;
expect(widget.getCellValue(row, column)).toBe(expected);
});
}); });

View File

@@ -180,6 +180,10 @@ export class DisplayValueWidget extends WidgetComponent implements OnInit {
} }
} }
if (column.type === 'Amount') {
return (column.amountCurrency || '$') + ' ' + (result || 0);
}
return result || ''; return result || '';
} }
} }