Allow to create new entry for models that have only relational fields

This commit is contained in:
soupette 2019-02-20 14:25:49 +01:00
parent c50a586418
commit 4cb3469bd3
2 changed files with 11 additions and 4 deletions

View File

@ -40,12 +40,13 @@ class App extends React.Component {
if (this.props.loading) {
return <LoadingIndicatorPage />;
}
const { schema } = this.props;
const currentModelName = this.props.location.pathname.split('/')[3];
const source = getQueryParameters(this.props.location.search, 'source');
const attrPath = source === 'content-manager' ? ['models', currentModelName, 'editDisplay', 'availableFields'] : ['models', 'plugins', source, currentModelName, 'editDisplay', 'availableFields'];
const relationsPath = source === 'content-manager' ? ['models', currentModelName, 'editDisplay', 'relations'] : ['models', 'plugins', source, currentModelName, 'editDisplay', 'relations'];
if (currentModelName && source && isEmpty(get(this.props.schema, attrPath))) {
if (currentModelName && source && isEmpty(get(schema, attrPath)) && isEmpty(get(schema, relationsPath))) {
return <EmptyAttributesView currentModelName={currentModelName} history={this.props.history} modelEntries={this.props.modelEntries} />;
}

View File

@ -9,7 +9,7 @@ import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { bindActionCreators, compose } from 'redux';
import { createStructuredSelector } from 'reselect';
import { capitalize, findIndex, get, isUndefined, toInteger, upperFirst } from 'lodash';
import { capitalize, findIndex, get, isEmpty, isUndefined, toInteger, upperFirst } from 'lodash';
import { ButtonDropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
import { FormattedMessage } from 'react-intl';
import cn from 'classnames';
@ -365,7 +365,13 @@ export class ListPage extends React.Component {
showSearch = () => get(this.getCurrentModel(), ['search']);
showFilters = () => get(this.getCurrentModel(), ['filters']);
showFilters = () => {
if (isEmpty(get(this.getCurrentModel(), ['editDisplay', 'availableFields']))) {
return false;
}
return get(this.getCurrentModel(), ['filters']);
}
showBulkActions = () => get(this.getCurrentModel(), ['bulkActions']);