Merge pull request #965 from Alfresco/dev-denys-964

#964 support currency symbols for amount column
This commit is contained in:
Mario Romano 2016-11-01 14:11:59 +00:00 committed by GitHub
commit 774ffd6a75
2 changed files with 33 additions and 0 deletions

View File

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

View File

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