mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
Merge pull request #965 from Alfresco/dev-denys-964
#964 support currency symbols for amount column
This commit is contained in:
commit
774ffd6a75
@ -641,4 +641,33 @@ describe('DisplayValueWidget', () => {
|
||||
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);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -180,6 +180,10 @@ export class DisplayValueWidget extends WidgetComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
if (column.type === 'Amount') {
|
||||
return (column.amountCurrency || '$') + ' ' + (result || 0);
|
||||
}
|
||||
|
||||
return result || '';
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user