diff --git a/frontend/src/components/filters/Filters.js b/frontend/src/components/filters/Filters.js index cb86e340650..0895e402b16 100644 --- a/frontend/src/components/filters/Filters.js +++ b/frontend/src/components/filters/Filters.js @@ -558,12 +558,12 @@ class Filters extends PureComponent { : parameter && parameter.widgetType; const captionValue = activeParameter - ? TableCell.fieldValueToString( - activeParameter.valueTo + ? TableCell.fieldValueToString({ + fieldValue: activeParameter.valueTo ? [activeParameter.value, activeParameter.valueTo] : activeParameter.value, - filterType - ) + fieldType: filterType, + }) : ''; return { diff --git a/frontend/src/components/table/Table.js b/frontend/src/components/table/Table.js index 0a13064db64..cc3b2d943b7 100644 --- a/frontend/src/components/table/Table.js +++ b/frontend/src/components/table/Table.js @@ -1036,6 +1036,7 @@ class Table extends Component { focusOnFieldName, modalVisible, isGerman, + activeLocale, } = this.props; const { @@ -1069,6 +1070,7 @@ class Table extends Component { {...{ page: this.props.page, entity, + activeLocale, cols, windowId, mainTable, @@ -1393,6 +1395,7 @@ const mapStateToProps = (state) => ({ allowShortcut: state.windowHandler.allowShortcut, allowOutsideClick: state.windowHandler.allowOutsideClick, modalVisible: state.windowHandler.modal.visible, + activeLocale: state.appHandler.me.language, isGerman: state.appHandler.me.language && state.appHandler.me.language.key ? state.appHandler.me.language.key.includes('de') diff --git a/frontend/src/components/table/TableCell.js b/frontend/src/components/table/TableCell.js index a0a705acfcc..49c6ef2e672 100644 --- a/frontend/src/components/table/TableCell.js +++ b/frontend/src/components/table/TableCell.js @@ -27,13 +27,16 @@ class TableCell extends PureComponent { static getDateFormat = (fieldType) => DATE_FIELD_FORMATS[fieldType]; - static createDate = (fieldValue, fieldType) => { + static createDate = ({ fieldValue, fieldType, activeLocale }) => { + const languageKey = activeLocale ? activeLocale.key : null; if (fieldValue) { return !Moment.isMoment(fieldValue) && fieldValue.match(TIME_REGEX_TEST) - ? Moment.utc(Moment.duration(fieldValue).asMilliseconds()).format( - TIME_FORMAT - ) - : Moment(fieldValue).format(TableCell.getDateFormat(fieldType)); + ? Moment.utc(Moment.duration(fieldValue).asMilliseconds()) + .locale(languageKey) + .format(TIME_FORMAT) + : Moment(fieldValue) + .locale(languageKey) + .format(TableCell.getDateFormat(fieldType)); } return ''; @@ -82,12 +85,13 @@ class TableCell extends PureComponent { // @TODO: THIS NEEDS URGENT REFACTORING, WHY THE HECK ARE WE RETURNING // SIX DIFFERENT TYPES OF VALUES HERE ? UBER-BAD DESIGN ! - static fieldValueToString = ( + static fieldValueToString = ({ fieldValue, fieldType = 'Text', precision = null, - isGerman - ) => { + isGerman, + activeLocale, + }) => { if (fieldValue === null) { return ''; } @@ -102,7 +106,7 @@ class TableCell extends PureComponent { return DATE_FIELD_TYPES.includes(fieldType) || TIME_FIELD_TYPES.includes(fieldType) - ? TableCell.createDate(fieldValue, fieldType) + ? TableCell.createDate({ fieldValue, fieldType, activeLocale }) : fieldValue.caption; } case 'boolean': { @@ -117,7 +121,7 @@ class TableCell extends PureComponent { DATE_FIELD_TYPES.includes(fieldType) || TIME_FIELD_TYPES.includes(fieldType) ) { - return TableCell.createDate(fieldValue, fieldType); + return TableCell.createDate({ fieldValue, fieldType, activeLocale }); } else if (AMOUNT_FIELD_TYPES.includes(fieldType)) { return TableCell.createAmount(fieldValue, precision, isGerman); } else if (SPECIAL_FIELD_TYPES.includes(fieldType)) { @@ -260,18 +264,19 @@ class TableCell extends PureComponent { modalVisible, onClickOutside, isGerman, + activeLocale, } = this.props; const widgetData = getWidgetData(item, isEditable, supportFieldEdit); - const docId = `${this.props.docId}`; const { tooltipToggled } = this.state; const tdValue = !isEdited - ? TableCell.fieldValueToString( - widgetData[0].value, - item.widgetType, - widgetData[0].precision, - isGerman - ) + ? TableCell.fieldValueToString({ + fieldValue: widgetData[0].value, + fieldType: item.widgetType, + precision: widgetData[0].precision, + isGerman, + activeLocale, + }) : null; const description = widgetData[0].value && widgetData[0].value.description @@ -431,6 +436,7 @@ TableCell.propTypes = { viewId: PropTypes.string, modalVisible: PropTypes.bool, docId: PropTypes.any, + activeLocale: PropTypes.object, }; export default TableCell; diff --git a/frontend/src/components/table/TableItem.js b/frontend/src/components/table/TableItem.js index 99bd029b1cc..10c94fc8a0e 100644 --- a/frontend/src/components/table/TableItem.js +++ b/frontend/src/components/table/TableItem.js @@ -406,6 +406,7 @@ class TableItem extends Component { isGerman, isSelected, focusOnFieldName, + activeLocale, } = this.props; const { edited, @@ -450,6 +451,7 @@ class TableItem extends Component { return (