mirror of
https://github.com/strapi/strapi.git
synced 2025-09-20 05:52:08 +00:00
Add show buttons update content type delete dynamic
This commit is contained in:
parent
2068dc7703
commit
6bfc8475bf
@ -45,8 +45,8 @@ class AttributeRow extends React.Component { // eslint-disable-line react/prefer
|
|||||||
}
|
}
|
||||||
|
|
||||||
toggleModalWarning = (e) => {
|
toggleModalWarning = (e) => {
|
||||||
e.preventDefault();
|
// e.preventDefault();
|
||||||
e.stopPropagation()
|
// e.stopPropagation()
|
||||||
this.setState({ showWarning: !this.state.showWarning });
|
this.setState({ showWarning: !this.state.showWarning });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { fromJS, Map, List } from 'immutable';
|
import { fromJS, Map, List } from 'immutable';
|
||||||
// import { findIndex, differenceWith, isEqual, filter } from 'lodash';
|
import { size, differenceBy } from 'lodash';
|
||||||
/* eslint-disable new-cap */
|
/* eslint-disable new-cap */
|
||||||
import {
|
import {
|
||||||
ADD_ATTRIBUTE_TO_CONTENT_TYPE,
|
ADD_ATTRIBUTE_TO_CONTENT_TYPE,
|
||||||
@ -38,8 +38,14 @@ function modelPageReducer(state = initialState, action) {
|
|||||||
.set('showButtons', false)
|
.set('showButtons', false)
|
||||||
.set('model', state.get('initialModel'));
|
.set('model', state.get('initialModel'));
|
||||||
case DELETE_ATTRIBUTE: {
|
case DELETE_ATTRIBUTE: {
|
||||||
|
const contentTypeAttributes = state.getIn(['model', 'attributes']).toJS();
|
||||||
|
contentTypeAttributes.splice(action.position, 1);
|
||||||
|
const updatedContentTypeAttributes = contentTypeAttributes;
|
||||||
|
const showButtons = size(updatedContentTypeAttributes) !== size(state.getIn(['initialModel', 'attributes']).toJS())
|
||||||
|
|| size(differenceBy(state.getIn(['initialModel', 'attributes']).toJS(), updatedContentTypeAttributes, 'name')) > 0;
|
||||||
|
|
||||||
return state
|
return state
|
||||||
.set('showButtons', true)
|
.set('showButtons', showButtons)
|
||||||
.updateIn(['model', 'attributes'], (list) => list.splice(action.position, 1));
|
.updateIn(['model', 'attributes'], (list) => list.splice(action.position, 1));
|
||||||
}
|
}
|
||||||
case MODEL_FETCH_SUCCEEDED:
|
case MODEL_FETCH_SUCCEEDED:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user