UNPKG

keystone

Version:

Web Application Framework and Admin GUI / Content Management System built on Express.js and Mongoose

32 lines (28 loc) 861 B
import React from 'react'; import ItemsTableCell from '../../components/ItemsTableCell'; import ItemsTableValue from '../../components/ItemsTableValue'; var SelectColumn = React.createClass({ displayName: 'SelectColumn', propTypes: { col: React.PropTypes.object, data: React.PropTypes.object, linkTo: React.PropTypes.string, }, getValue () { const value = this.props.data.fields[this.props.col.path]; const option = this.props.col.field.ops.filter(i => i.value === value)[0]; return option ? option.label : null; }, render () { const value = this.getValue(); const empty = !value && this.props.linkTo ? true : false; return ( <ItemsTableCell> <ItemsTableValue field={this.props.col.type} to={this.props.linkTo} empty={empty}> {value} </ItemsTableValue> </ItemsTableCell> ); }, }); module.exports = SelectColumn;