From 4cb3469bd35f2bc784242a84a5911b82f1357e3f Mon Sep 17 00:00:00 2001 From: soupette Date: Wed, 20 Feb 2019 14:25:49 +0100 Subject: [PATCH] Allow to create new entry for models that have only relational fields --- .../admin/src/containers/App/index.js | 5 +++-- .../admin/src/containers/ListPage/index.js | 10 ++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/strapi-plugin-content-manager/admin/src/containers/App/index.js b/packages/strapi-plugin-content-manager/admin/src/containers/App/index.js index f31868dba4..e7ae5a68c5 100644 --- a/packages/strapi-plugin-content-manager/admin/src/containers/App/index.js +++ b/packages/strapi-plugin-content-manager/admin/src/containers/App/index.js @@ -40,12 +40,13 @@ class App extends React.Component { if (this.props.loading) { return ; } - + 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 ; } diff --git a/packages/strapi-plugin-content-manager/admin/src/containers/ListPage/index.js b/packages/strapi-plugin-content-manager/admin/src/containers/ListPage/index.js index 8fe49fe212..62c74b8f88 100644 --- a/packages/strapi-plugin-content-manager/admin/src/containers/ListPage/index.js +++ b/packages/strapi-plugin-content-manager/admin/src/containers/ListPage/index.js @@ -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']);