diff --git a/app/react/Entities/components/EntityViewer.js b/app/react/Entities/components/EntityViewer.js index c2ec8b20c3..38d51872c3 100644 --- a/app/react/Entities/components/EntityViewer.js +++ b/app/react/Entities/components/EntityViewer.js @@ -6,6 +6,7 @@ import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import { Helmet } from 'react-helmet'; +import { sortBy } from 'lodash'; import PropTypes from 'prop-types'; import { Icon } from 'UI'; import { withContext, withRouter } from 'app/componentWrappers'; @@ -417,7 +418,7 @@ EntityViewer.propTypes = { const selectRelationTypes = createSelector( s => s.relationTypes, - r => r.toJS() + r => sortBy(r.toJS(), 'name') ); const mapStateToProps = state => { diff --git a/app/react/Relationships/actions/actions.js b/app/react/Relationships/actions/actions.js index 8828bbe834..0a48c8e713 100644 --- a/app/react/Relationships/actions/actions.js +++ b/app/react/Relationships/actions/actions.js @@ -1,3 +1,4 @@ +import { sortBy } from 'lodash'; import api from 'app/utils/api'; import { actions } from 'app/BasicReducer'; import debounce from 'app/utils/debounce'; @@ -248,7 +249,9 @@ const selectRelationTypes = createSelector( name, }; }); - return [{ _id: null, name: t('System', 'No Label', null, false) }].concat(relations); + return [{ _id: null, name: t('System', 'No Label', null, false) }].concat( + sortBy(relations, 'name') + ); } ); diff --git a/app/react/Templates/components/FormConfigRelationship.js b/app/react/Templates/components/FormConfigRelationship.js index 86afdada4e..6f01bcecef 100644 --- a/app/react/Templates/components/FormConfigRelationship.js +++ b/app/react/Templates/components/FormConfigRelationship.js @@ -5,7 +5,7 @@ import Immutable from 'immutable'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { createSelector } from 'reselect'; - +import { sortBy } from 'lodash'; import { Select } from 'app/ReactReduxForms'; import { Translate, t } from 'app/I18N'; import { Icon } from 'app/UI'; @@ -52,7 +52,10 @@ export class FormConfigRelationship extends Component { inheritSelectPropertyType, } = this.props; - const options = templates.toJS().filter(template => template._id !== templateId); + const options = sortBy( + templates.toJS().filter(template => template._id !== templateId), + 'name' + ); const labelClass = labelError ? 'form-group has-error' : 'form-group'; const canBeFilter = @@ -76,7 +79,7 @@ export class FormConfigRelationship extends Component {