mirror of
https://github.com/strapi/strapi.git
synced 2025-10-03 20:33:21 +00:00
Allow to create new entry for models that have only relational fields
This commit is contained in:
parent
c50a586418
commit
4cb3469bd3
@ -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} />;
|
||||
}
|
||||
|
||||
|
@ -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']);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user