mirror of
https://github.com/strapi/strapi.git
synced 2025-12-25 14:14:10 +00:00
Merge pull request #1342 from strapi/fix-1269
Fix bug when deleting a relation that has the same field on both sides
This commit is contained in:
commit
e62c7c2a11
@ -144,6 +144,7 @@ InputSelectWithErrors.defaultProps = {
|
||||
labelStyle: {},
|
||||
onBlur: false,
|
||||
onFocus: () => {},
|
||||
selectOptions: [],
|
||||
style: {},
|
||||
tabIndex: '0',
|
||||
validations: {},
|
||||
@ -198,7 +199,7 @@ InputSelectWithErrors.propTypes = {
|
||||
}),
|
||||
PropTypes.string,
|
||||
]),
|
||||
).isRequired,
|
||||
),
|
||||
style: PropTypes.object,
|
||||
tabIndex: PropTypes.string,
|
||||
validations: PropTypes.object,
|
||||
|
||||
@ -146,9 +146,12 @@ export class ModelPage extends React.Component { // eslint-disable-line react/pr
|
||||
}
|
||||
|
||||
handleDelete = (attributeName) => {
|
||||
const index = findIndex(this.props.modelPage.model.attributes, ['name', attributeName]);
|
||||
const parallelAttributeIndex = findIndex(this.props.modelPage.model.attributes, (attr) => attr.params.key === attributeName);
|
||||
|
||||
const { modelPage: { model } } = this.props;
|
||||
const index = findIndex(model.attributes, ['name', attributeName]);
|
||||
const attributeToRemove = get(model, ['attributes', index]);
|
||||
const parallelAttributeIndex = attributeToRemove.name === attributeToRemove.params.key ?
|
||||
-1 : findIndex(model.attributes, (attr) => attr.params.key === attributeName);
|
||||
|
||||
this.props.deleteAttribute(index, this.props.match.params.modelName, parallelAttributeIndex !== -1);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user