Prevent all bugs from strings

This commit is contained in:
soupette 2018-11-09 14:36:17 +01:00
parent 93b190eada
commit 69ae95726f

View File

@ -7,7 +7,7 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import moment from 'moment'; import moment from 'moment';
import { isEmpty, isNull, isObject, toString } from 'lodash'; import { isEmpty, isNull, isObject, toLower, toString } from 'lodash';
import cn from 'classnames'; import cn from 'classnames';
import CustomInputCheckbox from 'components/CustomInputCheckbox'; import CustomInputCheckbox from 'components/CustomInputCheckbox';
@ -31,21 +31,17 @@ class TableRow extends React.Component {
* @returns {*} * @returns {*}
*/ */
getDisplayedValue(type, value, name) { getDisplayedValue(type, value, name) {
if (!value) { switch (toLower(type)) {
return '-';
}
switch (type.toLowerCase()) {
case 'string': case 'string':
case 'text': case 'text':
case 'email': case 'email':
case 'enumeration': case 'enumeration':
return (value && !isEmpty(value.toString())) || name === 'id' ? value.toString() : '-'; return (value && !isEmpty(toString(value))) || name === 'id' ? toString(value) : '-';
case 'float': case 'float':
case 'integer': case 'integer':
case 'biginteger': case 'biginteger':
case 'decimal': case 'decimal':
return !isNull(value) ? value.toString() : '-'; return !isNull(value) ? toString(value) : '-';
case 'boolean': case 'boolean':
return value !== null ? toString(value) : '-'; return value !== null ? toString(value) : '-';
case 'date': case 'date':