diff --git a/packages/strapi-plugin-content-manager/admin/src/components/Block/index.js b/packages/strapi-plugin-content-manager/admin/src/components/Block/index.js
index 042ede09d0..d18691c850 100644
--- a/packages/strapi-plugin-content-manager/admin/src/components/Block/index.js
+++ b/packages/strapi-plugin-content-manager/admin/src/components/Block/index.js
@@ -9,9 +9,9 @@ import { FormattedMessage } from 'react-intl';
import styles from './styles.scss';
-const Block = ({ children, description, title }) => (
+const Block = ({ children, description, style, title }) => (
-
+
@@ -27,12 +27,14 @@ const Block = ({ children, description, title }) => (
Block.defaultProps = {
children: null,
description: 'app.utils.defaultMessage',
+ style: {},
title: 'app.utils.defaultMessage',
};
Block.propTypes = {
children: PropTypes.any,
description: PropTypes.string,
+ style: PropTypes.object,
title: PropTypes.string,
};
diff --git a/packages/strapi-plugin-content-manager/admin/src/containers/SettingPage/index.js b/packages/strapi-plugin-content-manager/admin/src/containers/SettingPage/index.js
index 87020c0fcc..7695e95191 100644
--- a/packages/strapi-plugin-content-manager/admin/src/containers/SettingPage/index.js
+++ b/packages/strapi-plugin-content-manager/admin/src/containers/SettingPage/index.js
@@ -88,6 +88,14 @@ class SettingPage extends React.PureComponent {
});
}
+ getEditPageDisplaySettings = () => {
+ return get(this.props.schema, 'models.'.concat(this.getPath().concat('.editDisplay')), { fields: [], relations: [] });
+ }
+
+ getEditPageFields = () => get(this.getEditPageDisplaySettings(), ['fields'], []);
+
+ getEditPageRelations = () => get(this.getEditPageDisplaySettings(), ['relations'], []);
+
getListDisplay = () => (
get(this.props.schema, `models.${this.getPath()}.listDisplay`, [])
);
@@ -207,6 +215,19 @@ class SettingPage extends React.PureComponent {
return index === -1 ? 0 : index;
}
+ hasRelations = () => {
+ const relations = get(this.props.schema, 'models.'.concat(this.getPath()).concat('.relations'), {});
+
+ return Object.keys(relations)
+ .filter(relation => {
+ const isUploadRelation = get(relations, [relation, 'plugin'], '') === 'upload';
+ const isMorphSide = get(relations, [relation, 'nature'], '').toLowerCase().includes('morph') && get(relations, [relation, relation]) !== undefined;
+
+ return !isUploadRelation && !isMorphSide;
+ })
+ .length > 0;
+ }
+
// We need to remove the Over state on the DraggableAttr component
updateSiblingHoverState = () => {
this.setState(prevState => ({ isDraggingSibling: !prevState.isDraggingSibling }));
@@ -234,7 +255,7 @@ class SettingPage extends React.PureComponent {
const namePath = this.getPath();
return (
-
+
+
);
}
}
diff --git a/packages/strapi-plugin-content-manager/admin/src/containers/SettingPage/styles.scss b/packages/strapi-plugin-content-manager/admin/src/containers/SettingPage/styles.scss
index f403c79e06..429aad3fca 100644
--- a/packages/strapi-plugin-content-manager/admin/src/containers/SettingPage/styles.scss
+++ b/packages/strapi-plugin-content-manager/admin/src/containers/SettingPage/styles.scss
@@ -125,4 +125,17 @@
}
}
}
+}
+
+.edit_settings {
+ padding-top: 25px;
+}
+
+.sort_wrapper {
+ margin-top: 7px;
+ padding-top: 10px;
+ border: 1px dashed #E3E9F3;
+ > div {
+ padding: 0 10px;
+ }
}
\ No newline at end of file
diff --git a/packages/strapi-plugin-content-manager/admin/src/translations/en.json b/packages/strapi-plugin-content-manager/admin/src/translations/en.json
index 7f96cbbd48..3fbf420690 100755
--- a/packages/strapi-plugin-content-manager/admin/src/translations/en.json
+++ b/packages/strapi-plugin-content-manager/admin/src/translations/en.json
@@ -18,6 +18,10 @@
"containers.SettingPage.addField": "Add new field",
"containers.SettingPage.attributes": "Attributes fields",
"containers.SettingPage.attributes.description": "Define the order of the attributes",
+ "containers.SettingPage.relations": "Relational fields",
+
+ "containers.SettingPage.editSettings.description": "Drag & drop the fields to build the layout",
+ "containers.SettingPage.editSettings.title": "Edit - Settings",
"containers.SettingPage.listSettings.title": "List — Settings",
"containers.SettingPage.listSettings.description": "Configure the options for this content type",
diff --git a/packages/strapi-plugin-content-manager/admin/src/translations/fr.json b/packages/strapi-plugin-content-manager/admin/src/translations/fr.json
index 8546d06e92..29d6ea2260 100755
--- a/packages/strapi-plugin-content-manager/admin/src/translations/fr.json
+++ b/packages/strapi-plugin-content-manager/admin/src/translations/fr.json
@@ -18,7 +18,13 @@
"containers.SettingPage.addField": "Ajouter un nouveau champs",
"containers.SettingPage.attributes": "Attributs",
"containers.SettingPage.attributes.description": "Organiser les attributs du modèle",
+ "containers.SettingPage.relations": "Champs relationnels",
+
"containers.SettingPage.pluginHeaderDescription": "Configurez les paramètres de ce modèle",
+
+ "containers.SettingPage.editSettings.description": "Glissez & déposez les champs pour construire le layout",
+ "containers.SettingPage.editSettings.title": "Edit - Paramètres",
+
"containers.SettingPage.listSettings.title": "Liste — Paramètres",
"containers.SettingPage.listSettings.description": "Configurez les options de ce modèle",
diff --git a/packages/strapi-plugin-content-manager/config/functions/bootstrap.js b/packages/strapi-plugin-content-manager/config/functions/bootstrap.js
index 0f5f3fdf3c..6c80763759 100644
--- a/packages/strapi-plugin-content-manager/config/functions/bootstrap.js
+++ b/packages/strapi-plugin-content-manager/config/functions/bootstrap.js
@@ -51,19 +51,26 @@ module.exports = async cb => {
pageEntries: 10,
defaultSort: model.primaryKey,
sort: 'ASC',
+ editDisplay: {
+ fields: [],
+ relations: [],
+ },
}, model);
// Fields (non relation)
- schemaModel.fields = _.mapValues(_.pickBy(model.attributes, attribute =>
+ const fields = _.mapValues(_.pickBy(model.attributes, attribute =>
!attribute.model && !attribute.collection
), (value, attribute) => ({
label: _.upperFirst(attribute),
description: '',
type: value.type || 'string',
}));
+
+ schemaModel.fields = fields;
+ schemaModel.editDisplay.fields = Object.keys(fields);
+
// Select fields displayed in list view
- // schemaModel.list = _.slice(_.keys(schemaModel.fields), 0, 4);
schemaModel.listDisplay = Object.keys(schemaModel.fields)
// Construct Array of attr ex { type: 'string', label: 'Foo', name: 'Foo', description: '' }
// NOTE: Do we allow sort on boolean?
@@ -103,6 +110,15 @@ module.exports = async cb => {
return acc;
}, {});
+ const relationsArray = Object.keys(schemaModel.relations).filter(relation => {
+ const isUploadRelation = _.get(schemaModel, ['relations', relation, 'plugin'], '') === 'upload';
+ const isMorphSide = _.get(schemaModel, ['relations', relation, 'nature'], '').toLowerCase().includes('morp') && _.get(schemaModel, ['relations', relation, relation]) !== undefined;
+
+ return !isUploadRelation && !isMorphSide;
+ });
+
+ schemaModel.editDisplay.relations = relationsArray;
+
}
if (plugin) {
diff --git a/packages/strapi-plugin-content-manager/config/layout.json b/packages/strapi-plugin-content-manager/config/layout.json
index 9e26dfeeb6..45416bc837 100644
--- a/packages/strapi-plugin-content-manager/config/layout.json
+++ b/packages/strapi-plugin-content-manager/config/layout.json
@@ -1 +1,25 @@
-{}
\ No newline at end of file
+{
+ "product": {
+ "attributes": {
+ "name": {
+ "appearance": ""
+ },
+ "price": {
+ "appearance": ""
+ },
+ "description": {
+ "appearance": ""
+ },
+ "description_long": {
+ "appearance": "WYSIWYG"
+ }
+ }
+ },
+ "tag": {
+ "attributes": {
+ "name": {
+ "appearance": ""
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/packages/strapi-plugin-content-manager/package.json b/packages/strapi-plugin-content-manager/package.json
index af4cfd290f..28bd99b5c4 100755
--- a/packages/strapi-plugin-content-manager/package.json
+++ b/packages/strapi-plugin-content-manager/package.json
@@ -51,4 +51,4 @@
"npm": ">= 5.0.0"
},
"license": "MIT"
-}
+}
\ No newline at end of file
diff --git a/packages/strapi-plugin-users-permissions/models/User.settings.json b/packages/strapi-plugin-users-permissions/models/User.settings.json
index da72db76e3..3299fa48f4 100644
--- a/packages/strapi-plugin-users-permissions/models/User.settings.json
+++ b/packages/strapi-plugin-users-permissions/models/User.settings.json
@@ -38,6 +38,10 @@
"via": "users",
"plugin": "users-permissions",
"configurable": false
+ },
+ "products": {
+ "collection": "product",
+ "via": "users"
}
}
}
\ No newline at end of file