keystone
Version:
Web Application Framework and Admin GUI / Content Management System built on Express.js and Mongoose
32 lines (27 loc) • 813 B
JavaScript
import React from 'react';
import numeral from 'numeral';
import ItemsTableCell from '../../components/ItemsTableCell';
import ItemsTableValue from '../../components/ItemsTableValue';
var NumberColumn = React.createClass({
displayName: 'NumberColumn',
propTypes: {
col: React.PropTypes.object,
data: React.PropTypes.object,
},
renderValue () {
const value = this.props.data.fields[this.props.col.path];
if (value === undefined || isNaN(value)) return null;
const formattedValue = (this.props.col.type === 'money') ? numeral(value).format('$0,0.00') : value;
return formattedValue;
},
render () {
return (
<ItemsTableCell>
<ItemsTableValue field={this.props.col.type}>
{this.renderValue()}
</ItemsTableValue>
</ItemsTableCell>
);
},
});
module.exports = NumberColumn;