;
}
const LimitedString = ({ string }) =>
{string.indexOf(' ') === -1 && string.length > 30 ?
{string.substr(0,30)}… :
{string}
}
const getFieldValue = (value, typeName) => {
if (!value) {
return ''
}
if (Array.isArray(value)) {
typeName = 'Array';
}
switch (typeName) {
case 'Boolean':
case 'boolean':
case 'Number':
case 'number':
case 'SimpleSchema.Integer':
return {value}
;
case 'Array':
return {value.map((item, index) => - {getFieldValue(item, typeof item)}
)}
case 'Object':
case 'object':
return (
{_.map(value, (value, key) =>
{key} |
{getFieldValue(value, typeof value)} |
)}
)
case 'Date':
return moment(new Date(value)).format('dddd, MMMM Do YYYY, h:mm:ss');
default:
return parseImageUrl(value);
}
}
const CardItem = ({label, value, typeName}) =>
{label} |
{getFieldValue(value, typeName)} |
const CardEdit = (props, context) =>
}>
|
CardEdit.contextTypes = { intl: intlShape };
const CardEditForm = ({ collection, document, closeModal }) =>
{
closeModal();
}}
/>
const Card = ({className, collection, document, currentUser, fields}, {intl}) => {
const fieldNames = fields ? fields : _.without(_.keys(document), '__typename');
const canEdit = currentUser && collection.options.mutations.edit.check(currentUser, document);
return (
{canEdit ? : null}
{fieldNames.map((fieldName, index) =>
)}
);
};
Card.displayName = "Card";
Card.propTypes = {
className: PropTypes.string,
collection: PropTypes.object,
document: PropTypes.object,
currentUser: PropTypes.object,
fields: PropTypes.array,
}
Card.contextTypes = {
intl: intlShape
}
registerComponent('Card', Card);