Models attributes list

This commit is contained in:
Virginie Ky 2019-07-09 08:57:39 +02:00
parent b6a5ae5644
commit d0d2198ad2

View File

@ -32,6 +32,7 @@ import Block from '../../components/Block';
import Flex from '../../components/Flex'; import Flex from '../../components/Flex';
import ListTitle from '../../components/ListTitle'; import ListTitle from '../../components/ListTitle';
import Ul from '../../components/Ul'; import Ul from '../../components/Ul';
import ListRow from '../../components/ListRow';
import AttributeForm from '../AttributeForm'; import AttributeForm from '../AttributeForm';
import AttributesModalPicker from '../AttributesPickerModal'; import AttributesModalPicker from '../AttributesPickerModal';
@ -363,9 +364,8 @@ export class ModelPage extends React.Component {
} }
}; };
handleDeleteAttribute = () => { handleDeleteAttribute = attrToDelete => {
const { deleteModelAttribute } = this.props; const { deleteModelAttribute } = this.props;
const { attrToDelete } = this.state;
/* istanbul ignore if */ /* istanbul ignore if */
const keys = this.isUpdatingTemporaryContentType() const keys = this.isUpdatingTemporaryContentType()
@ -373,7 +373,6 @@ export class ModelPage extends React.Component {
: ['modifiedData', this.getModelName(), 'attributes', attrToDelete]; : ['modifiedData', this.getModelName(), 'attributes', attrToDelete];
deleteModelAttribute(keys); deleteModelAttribute(keys);
this.setState({ attrToDelete: null, showWarning: false });
}; };
handleGoBack = () => { handleGoBack = () => {
@ -512,9 +511,29 @@ export class ModelPage extends React.Component {
); );
}; };
renderListRow = attribute => {
const { canOpenModal } = this.props;
const attributeInfos = get(this.getModelAttributes(), attribute, {});
return (
<ListRow
key={attribute}
attributeId={attribute}
{...attributeInfos}
canOpenModal={canOpenModal}
context={this.context}
deleteAttribute={this.handleDeleteAttribute}
isTemporary={false}
name={attribute}
type={attributeInfos.type}
/>
);
};
render() { render() {
const listTitleMessageIdBasePrefix = `${pluginId}.modelPage.contentType.list.title`; const listTitleMessageIdBasePrefix = `${pluginId}.modelPage.contentType.list.title`;
const { const {
canOpenModal,
clearTemporaryAttribute, clearTemporaryAttribute,
clearTemporaryAttributeRelation, clearTemporaryAttributeRelation,
history: { push }, history: { push },
@ -542,7 +561,6 @@ export class ModelPage extends React.Component {
const attributeType = this.getAttributeType(); const attributeType = this.getAttributeType();
const actionType = this.getActionType(); const actionType = this.getActionType();
// const attributes = this.getModelAttributes();
const attributesNumber = this.getModelAttributesLength(); const attributesNumber = this.getModelAttributesLength();
const relationsNumber = this.getModelRelationShipsLength(); const relationsNumber = this.getModelRelationShipsLength();
@ -601,23 +619,15 @@ export class ModelPage extends React.Component {
) : ( ) : (
<ListWrapper> <ListWrapper>
<ListHeader title={title} button={{ ...buttonProps }} /> <ListHeader title={title} button={{ ...buttonProps }} />
{/* <List> <List>
<table> <table>
<tbody> <tbody>
{attributes.map(attribute => ( {Object.keys(this.getModelAttributes()).map(
<ListRow this.renderListRow
key={attribute.name} )}
{...attribute}
canOpenModal={canOpenModal}
context={this.context}
deleteAttribute={this.handleDeleteGroupAttribute}
isTemporary={false}
type={attribute.type}
/>
))}
</tbody> </tbody>
</table> </table>
</List> */} </List>
<div className="list-button"> <div className="list-button">
<Button {...buttonProps} /> <Button {...buttonProps} />
</div> </div>