From d0d2198ad2191d8d8ac6bfc47eaef70af36ed454 Mon Sep 17 00:00:00 2001 From: Virginie Ky Date: Tue, 9 Jul 2019 08:57:39 +0200 Subject: [PATCH] Models attributes list --- .../admin/src/containers/ModelPage/index.js | 44 ++++++++++++------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/ModelPage/index.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/ModelPage/index.js index af32009141..a9703814fb 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/ModelPage/index.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/ModelPage/index.js @@ -32,6 +32,7 @@ import Block from '../../components/Block'; import Flex from '../../components/Flex'; import ListTitle from '../../components/ListTitle'; import Ul from '../../components/Ul'; +import ListRow from '../../components/ListRow'; import AttributeForm from '../AttributeForm'; import AttributesModalPicker from '../AttributesPickerModal'; @@ -363,9 +364,8 @@ export class ModelPage extends React.Component { } }; - handleDeleteAttribute = () => { + handleDeleteAttribute = attrToDelete => { const { deleteModelAttribute } = this.props; - const { attrToDelete } = this.state; /* istanbul ignore if */ const keys = this.isUpdatingTemporaryContentType() @@ -373,7 +373,6 @@ export class ModelPage extends React.Component { : ['modifiedData', this.getModelName(), 'attributes', attrToDelete]; deleteModelAttribute(keys); - this.setState({ attrToDelete: null, showWarning: false }); }; handleGoBack = () => { @@ -512,9 +511,29 @@ export class ModelPage extends React.Component { ); }; + renderListRow = attribute => { + const { canOpenModal } = this.props; + const attributeInfos = get(this.getModelAttributes(), attribute, {}); + + return ( + + ); + }; + render() { const listTitleMessageIdBasePrefix = `${pluginId}.modelPage.contentType.list.title`; const { + canOpenModal, clearTemporaryAttribute, clearTemporaryAttributeRelation, history: { push }, @@ -542,7 +561,6 @@ export class ModelPage extends React.Component { const attributeType = this.getAttributeType(); const actionType = this.getActionType(); - // const attributes = this.getModelAttributes(); const attributesNumber = this.getModelAttributesLength(); const relationsNumber = this.getModelRelationShipsLength(); @@ -601,23 +619,15 @@ export class ModelPage extends React.Component { ) : ( - {/* + - {attributes.map(attribute => ( - - ))} + {Object.keys(this.getModelAttributes()).map( + this.renderListRow + )}
-
*/} +