mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 16:29:34 +00:00
Handle edit attribute
This commit is contained in:
parent
20beac0993
commit
e30dcefe37
@ -71,7 +71,7 @@ class Input extends React.Component { // eslint-disable-line react/prefer-statel
|
|||||||
<FormattedMessage id={this.props.name}>
|
<FormattedMessage id={this.props.name}>
|
||||||
{(message) => (
|
{(message) => (
|
||||||
<label className={`${styles.checkboxLabel} form-check-label`} htmlFor={this.props.name}>
|
<label className={`${styles.checkboxLabel} form-check-label`} htmlFor={this.props.name}>
|
||||||
<input className="form-check-input" type="checkbox" checked={this.props.value} onChange={this.handleChangeCheckbox} name={this.props.target} />
|
<input className="form-check-input" type="checkbox" defaultChecked={this.props.value} onChange={this.handleChangeCheckbox} name={this.props.target} />
|
||||||
{message}
|
{message}
|
||||||
</label>
|
</label>
|
||||||
)}
|
)}
|
||||||
|
@ -23,6 +23,7 @@ import {
|
|||||||
RESET_DID_FETCH_MODEL_PROP,
|
RESET_DID_FETCH_MODEL_PROP,
|
||||||
RESET_IS_FORM_SET,
|
RESET_IS_FORM_SET,
|
||||||
SET_ATTRIBUTE_FORM,
|
SET_ATTRIBUTE_FORM,
|
||||||
|
SET_ATTRIBUTE_FORM_EDIT,
|
||||||
SET_FORM,
|
SET_FORM,
|
||||||
} from './constants';
|
} from './constants';
|
||||||
|
|
||||||
@ -120,6 +121,46 @@ export function resetIsFormSet() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function setAttributeForm(hash) {
|
export function setAttributeForm(hash) {
|
||||||
|
// const hashArray = hash.split('::');
|
||||||
|
// const formType = replace(hashArray[1], 'attribute', '');
|
||||||
|
// const settingsType = hashArray[2];
|
||||||
|
// const form = forms.attribute[formType][settingsType];
|
||||||
|
//
|
||||||
|
// const attribute = Map({
|
||||||
|
// name: '',
|
||||||
|
// params: Map({
|
||||||
|
// type: formType,
|
||||||
|
// required: false,
|
||||||
|
// maxLength: false,
|
||||||
|
// minLength: false,
|
||||||
|
// }),
|
||||||
|
// });
|
||||||
|
const data = setAttributeFormData(hash);
|
||||||
|
|
||||||
|
return {
|
||||||
|
type: SET_ATTRIBUTE_FORM,
|
||||||
|
form: data.form,
|
||||||
|
attribute: data.attribute,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setAttributeFormEdit(hash, contentType) {
|
||||||
|
const form = setAttributeFormData(hash).form;
|
||||||
|
const contentTypeAttribute = contentType.attributes[hash.split('::')[3]];
|
||||||
|
const attribute = Map({
|
||||||
|
name: contentTypeAttribute.name,
|
||||||
|
params: Map(contentTypeAttribute.params),
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
type: SET_ATTRIBUTE_FORM_EDIT,
|
||||||
|
form,
|
||||||
|
attribute,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function setAttributeFormData(hash) {
|
||||||
const hashArray = hash.split('::');
|
const hashArray = hash.split('::');
|
||||||
const formType = replace(hashArray[1], 'attribute', '');
|
const formType = replace(hashArray[1], 'attribute', '');
|
||||||
const settingsType = hashArray[2];
|
const settingsType = hashArray[2];
|
||||||
@ -136,7 +177,6 @@ export function setAttributeForm(hash) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: SET_ATTRIBUTE_FORM,
|
|
||||||
form,
|
form,
|
||||||
attribute,
|
attribute,
|
||||||
}
|
}
|
||||||
|
@ -16,4 +16,5 @@ export const CONTENT_TYPE_FETCH_SUCCEEDED = 'ContentTypeBuilder/Form/CONTENT_TYP
|
|||||||
export const RESET_DID_FETCH_MODEL_PROP = 'ContentTypeBuilder/Form/RESET_DID_FETCH_MODEL_PROP';
|
export const RESET_DID_FETCH_MODEL_PROP = 'ContentTypeBuilder/Form/RESET_DID_FETCH_MODEL_PROP';
|
||||||
export const RESET_IS_FORM_SET = 'ContentTypeBuilder/Form/RESET_IS_FORM_SET';
|
export const RESET_IS_FORM_SET = 'ContentTypeBuilder/Form/RESET_IS_FORM_SET';
|
||||||
export const SET_ATTRIBUTE_FORM = 'ContentTypeBuilder/Form/SET_ATTRIBUTE_FORM';
|
export const SET_ATTRIBUTE_FORM = 'ContentTypeBuilder/Form/SET_ATTRIBUTE_FORM';
|
||||||
|
export const SET_ATTRIBUTE_FORM_EDIT = 'ContentTypeBuilder/Form/SET_ATTRIBUTE_FORM_EDIT';
|
||||||
export const SET_FORM = 'ContentTypeBuilder/Form/SET_FORM';
|
export const SET_FORM = 'ContentTypeBuilder/Form/SET_FORM';
|
||||||
|
@ -23,7 +23,7 @@ import {
|
|||||||
import { router, store } from 'app';
|
import { router, store } from 'app';
|
||||||
|
|
||||||
import { temporaryContentTypeFieldsUpdated, storeTemporaryMenu } from 'containers/App/actions';
|
import { temporaryContentTypeFieldsUpdated, storeTemporaryMenu } from 'containers/App/actions';
|
||||||
import { addAttributeToContentType, updateContentType } from 'containers/ModelPage/actions';
|
import { addAttributeToContentType, editContentTypeAttribute, updateContentType } from 'containers/ModelPage/actions';
|
||||||
import AttributeCard from 'components/AttributeCard';
|
import AttributeCard from 'components/AttributeCard';
|
||||||
import InputCheckboxWithNestedInputs from 'components/InputCheckboxWithNestedInputs';
|
import InputCheckboxWithNestedInputs from 'components/InputCheckboxWithNestedInputs';
|
||||||
import PopUpForm from 'components/PopUpForm';
|
import PopUpForm from 'components/PopUpForm';
|
||||||
@ -45,6 +45,7 @@ import {
|
|||||||
contentTypeFetchSucceeded,
|
contentTypeFetchSucceeded,
|
||||||
resetIsFormSet,
|
resetIsFormSet,
|
||||||
setAttributeForm,
|
setAttributeForm,
|
||||||
|
setAttributeFormEdit,
|
||||||
setForm,
|
setForm,
|
||||||
} from './actions';
|
} from './actions';
|
||||||
|
|
||||||
@ -106,6 +107,13 @@ export class Form extends React.Component { // eslint-disable-line react/prefer-
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
componentDidUpdate(prevProps) {
|
||||||
|
if (prevProps.modelLoading !== this.props.modelLoading && !isEmpty(this.props.hash)) {
|
||||||
|
this.initComponent(this.props, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
addAttributeToContentType = () => {
|
addAttributeToContentType = () => {
|
||||||
// Update the parent container (ModelPage)
|
// Update the parent container (ModelPage)
|
||||||
this.props.addAttributeToContentType(this.props.modifiedDataAttribute);
|
this.props.addAttributeToContentType(this.props.modifiedDataAttribute);
|
||||||
@ -115,6 +123,15 @@ export class Form extends React.Component { // eslint-disable-line react/prefer-
|
|||||||
router.push(`${this.props.redirectRoute}/${replace(this.props.hash.split('::')[0], '#create', '')}`);
|
router.push(`${this.props.redirectRoute}/${replace(this.props.hash.split('::')[0], '#create', '')}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
editContentTypeAttribute = () => {
|
||||||
|
// Update the parent container (ModelPage)
|
||||||
|
this.props.editContentTypeAttribute(this.props.modifiedDataAttribute, this.props.hash.split('::')[3]);
|
||||||
|
// Empty the store
|
||||||
|
this.props.resetIsFormSet();
|
||||||
|
// Close modal
|
||||||
|
router.push(`${this.props.redirectRoute}/${replace(this.props.hash.split('::')[0], '#edit', '')}`);
|
||||||
|
}
|
||||||
|
|
||||||
addAttributeToTempContentType = () => {
|
addAttributeToTempContentType = () => {
|
||||||
// Get the entire content type from the reducer
|
// Get the entire content type from the reducer
|
||||||
const contentType = this.props.modifiedDataEdit;
|
const contentType = this.props.modifiedDataEdit;
|
||||||
@ -191,7 +208,7 @@ export class Form extends React.Component { // eslint-disable-line react/prefer-
|
|||||||
// Three kinds of values are available modifiedData and modifiedDataEdit
|
// Three kinds of values are available modifiedData and modifiedDataEdit
|
||||||
// Allows the user to start creating a contentType and modifying an existing one at the same time
|
// Allows the user to start creating a contentType and modifying an existing one at the same time
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case includes(this.props.hash, 'edit'):
|
case includes(this.props.hash, 'edit') && !includes(this.props.hash, 'attributes'):
|
||||||
values = this.props.modifiedDataEdit;
|
values = this.props.modifiedDataEdit;
|
||||||
break;
|
break;
|
||||||
case includes(this.props.hash.split('::')[1], 'attribute'):
|
case includes(this.props.hash.split('::')[1], 'attribute'):
|
||||||
@ -225,7 +242,7 @@ export class Form extends React.Component { // eslint-disable-line react/prefer-
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleSubmit = () => {
|
handleSubmit = () => {
|
||||||
if (includes(this.props.hash, 'edit')) {
|
if (includes(this.props.hash, 'edit') && !includes(this.props.hash, 'attribute')) {
|
||||||
this.testContentType(
|
this.testContentType(
|
||||||
replace(split(this.props.hash, '::')[0], '#edit', ''),
|
replace(split(this.props.hash, '::')[0], '#edit', ''),
|
||||||
this.createContentType,
|
this.createContentType,
|
||||||
@ -233,13 +250,21 @@ export class Form extends React.Component { // eslint-disable-line react/prefer-
|
|||||||
// this.props.contentTypeEdit,
|
// this.props.contentTypeEdit,
|
||||||
this.props.contentTypeEdit,
|
this.props.contentTypeEdit,
|
||||||
);
|
);
|
||||||
} else if (includes(this.props.hash.split('::')[1], 'attribute')) {
|
} else if (includes(this.props.hash.split('::')[1], 'attribute') && includes(this.props.hash, '#create')) {
|
||||||
this.testContentType(
|
this.testContentType(
|
||||||
replace(split(this.props.hash, '::')[0], '#create', ''),
|
replace(split(this.props.hash, '::')[0], '#create', ''),
|
||||||
this.addAttributeToTempContentType,
|
this.addAttributeToTempContentType,
|
||||||
null,
|
null,
|
||||||
this.addAttributeToContentType,
|
this.addAttributeToContentType,
|
||||||
);
|
);
|
||||||
|
} else if (includes(this.props.hash.split('::')[1], 'attribute') && includes(this.props.hash, '#edit')) {
|
||||||
|
this.testContentType(
|
||||||
|
replace(split(this.props.hash, '::')[0], '#create', ''),
|
||||||
|
// TODO check
|
||||||
|
this.addAttributeToTempContentType,
|
||||||
|
null,
|
||||||
|
this.editContentTypeAttribute,
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
this.createContentType(this.props.modifiedData);
|
this.createContentType(this.props.modifiedData);
|
||||||
}
|
}
|
||||||
@ -263,6 +288,10 @@ export class Form extends React.Component { // eslint-disable-line react/prefer-
|
|||||||
if (includes(props.hash, '#create') && includes(props.hash, 'attribute')) {
|
if (includes(props.hash, '#create') && includes(props.hash, 'attribute')) {
|
||||||
this.props.setAttributeForm(props.hash);
|
this.props.setAttributeForm(props.hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (get(props.contentTypeData, 'name') && includes(props.hash, '#edit') && includes(props.hash, 'attribute')) {
|
||||||
|
this.props.setAttributeFormEdit(props.hash, props.contentTypeData);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.setState({ showModal: false });
|
this.setState({ showModal: false });
|
||||||
}
|
}
|
||||||
@ -359,6 +388,7 @@ function mapDispatchToProps(dispatch) {
|
|||||||
return bindActionCreators(
|
return bindActionCreators(
|
||||||
{
|
{
|
||||||
addAttributeToContentType,
|
addAttributeToContentType,
|
||||||
|
editContentTypeAttribute,
|
||||||
changeInput,
|
changeInput,
|
||||||
changeInputAttribute,
|
changeInputAttribute,
|
||||||
connectionsFetch,
|
connectionsFetch,
|
||||||
@ -368,6 +398,7 @@ function mapDispatchToProps(dispatch) {
|
|||||||
contentTypeFetchSucceeded,
|
contentTypeFetchSucceeded,
|
||||||
resetIsFormSet,
|
resetIsFormSet,
|
||||||
setAttributeForm,
|
setAttributeForm,
|
||||||
|
setAttributeFormEdit,
|
||||||
setForm,
|
setForm,
|
||||||
storeTemporaryMenu,
|
storeTemporaryMenu,
|
||||||
temporaryContentTypeFieldsUpdated,
|
temporaryContentTypeFieldsUpdated,
|
||||||
@ -386,6 +417,7 @@ Form.propTypes = {
|
|||||||
contentTypeEdit: React.PropTypes.func,
|
contentTypeEdit: React.PropTypes.func,
|
||||||
contentTypeFetch: React.PropTypes.func,
|
contentTypeFetch: React.PropTypes.func,
|
||||||
contentTypeFetchSucceeded: React.PropTypes.func,
|
contentTypeFetchSucceeded: React.PropTypes.func,
|
||||||
|
editContentTypeAttribute: React.PropTypes.func,
|
||||||
form: React.PropTypes.oneOfType([
|
form: React.PropTypes.oneOfType([
|
||||||
React.PropTypes.array.isRequired,
|
React.PropTypes.array.isRequired,
|
||||||
React.PropTypes.object.isRequired,
|
React.PropTypes.object.isRequired,
|
||||||
@ -393,6 +425,7 @@ Form.propTypes = {
|
|||||||
hash: React.PropTypes.string.isRequired,
|
hash: React.PropTypes.string.isRequired,
|
||||||
isModelPage: React.PropTypes.bool,
|
isModelPage: React.PropTypes.bool,
|
||||||
menuData: React.PropTypes.array.isRequired,
|
menuData: React.PropTypes.array.isRequired,
|
||||||
|
modelLoading: React.PropTypes.bool,
|
||||||
modelName: React.PropTypes.string,
|
modelName: React.PropTypes.string,
|
||||||
modifiedData: React.PropTypes.object,
|
modifiedData: React.PropTypes.object,
|
||||||
modifiedDataAttribute: React.PropTypes.object,
|
modifiedDataAttribute: React.PropTypes.object,
|
||||||
@ -405,6 +438,7 @@ Form.propTypes = {
|
|||||||
selectOptions: React.PropTypes.array,
|
selectOptions: React.PropTypes.array,
|
||||||
selectOptionsFetchSucceeded: React.PropTypes.bool,
|
selectOptionsFetchSucceeded: React.PropTypes.bool,
|
||||||
setAttributeForm: React.PropTypes.func,
|
setAttributeForm: React.PropTypes.func,
|
||||||
|
setAttributeFormEdit: React.PropTypes.func,
|
||||||
setForm: React.PropTypes.func.isRequired,
|
setForm: React.PropTypes.func.isRequired,
|
||||||
shouldRefetchContentType: React.PropTypes.bool,
|
shouldRefetchContentType: React.PropTypes.bool,
|
||||||
storeTemporaryMenu: React.PropTypes.func,
|
storeTemporaryMenu: React.PropTypes.func,
|
||||||
|
@ -14,6 +14,7 @@ import {
|
|||||||
CONTENT_TYPE_FETCH_SUCCEEDED,
|
CONTENT_TYPE_FETCH_SUCCEEDED,
|
||||||
RESET_IS_FORM_SET,
|
RESET_IS_FORM_SET,
|
||||||
SET_ATTRIBUTE_FORM,
|
SET_ATTRIBUTE_FORM,
|
||||||
|
SET_ATTRIBUTE_FORM_EDIT,
|
||||||
SET_FORM,
|
SET_FORM,
|
||||||
} from './constants';
|
} from './constants';
|
||||||
|
|
||||||
@ -29,7 +30,6 @@ const initialState = fromJS({
|
|||||||
modifiedData: Map(),
|
modifiedData: Map(),
|
||||||
modifiedDataEdit: Map(),
|
modifiedDataEdit: Map(),
|
||||||
isFormSet: false,
|
isFormSet: false,
|
||||||
// didFetchModel: true,
|
|
||||||
shouldRefetchContentType: false,
|
shouldRefetchContentType: false,
|
||||||
updatedContentType: false,
|
updatedContentType: false,
|
||||||
});
|
});
|
||||||
@ -59,11 +59,9 @@ function formReducer(state = initialState, action) {
|
|||||||
case CONTENT_TYPE_CREATE:
|
case CONTENT_TYPE_CREATE:
|
||||||
return state
|
return state
|
||||||
.set('isFormSet', false)
|
.set('isFormSet', false)
|
||||||
// .set('didFetchModel', true)
|
|
||||||
.set('updatedContentType', !state.get('updatedContentType'));
|
.set('updatedContentType', !state.get('updatedContentType'));
|
||||||
case CONTENT_TYPE_FETCH_SUCCEEDED:
|
case CONTENT_TYPE_FETCH_SUCCEEDED:
|
||||||
return state
|
return state
|
||||||
// .set('didFetchModel', false)
|
|
||||||
.set('initialDataEdit', action.data)
|
.set('initialDataEdit', action.data)
|
||||||
.set('modifiedDataEdit', action.data);
|
.set('modifiedDataEdit', action.data);
|
||||||
case RESET_IS_FORM_SET:
|
case RESET_IS_FORM_SET:
|
||||||
@ -78,10 +76,21 @@ function formReducer(state = initialState, action) {
|
|||||||
.set('form', Map(action.form))
|
.set('form', Map(action.form))
|
||||||
.set('modifiedDataAttribute', action.attribute);
|
.set('modifiedDataAttribute', action.attribute);
|
||||||
}
|
}
|
||||||
|
case SET_ATTRIBUTE_FORM_EDIT: {
|
||||||
|
if (state.get('isFormSet')) {
|
||||||
|
return state.set('form', Map(action.form));
|
||||||
|
}
|
||||||
|
|
||||||
|
return state
|
||||||
|
.set('isFormSet', true)
|
||||||
|
.set('form', Map(action.form))
|
||||||
|
.set('modifiedDataAttribute', action.attribute);
|
||||||
|
}
|
||||||
case SET_FORM: {
|
case SET_FORM: {
|
||||||
if (state.get('isFormSet')) {
|
if (state.get('isFormSet')) {
|
||||||
return state.set('form', Map(action.form));
|
return state.set('form', Map(action.form));
|
||||||
}
|
}
|
||||||
|
|
||||||
return state
|
return state
|
||||||
.set('isFormSet', true)
|
.set('isFormSet', true)
|
||||||
.set('form', Map(action.form))
|
.set('form', Map(action.form))
|
||||||
|
@ -8,6 +8,7 @@ import { storeData } from '../../utils/storeData';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
ADD_ATTRIBUTE_TO_CONTENT_TYPE,
|
ADD_ATTRIBUTE_TO_CONTENT_TYPE,
|
||||||
|
EDIT_CONTENT_TYPE_ATTRIBUTE,
|
||||||
CANCEL_CHANGES,
|
CANCEL_CHANGES,
|
||||||
DEFAULT_ACTION,
|
DEFAULT_ACTION,
|
||||||
DELETE_ATTRIBUTE,
|
DELETE_ATTRIBUTE,
|
||||||
@ -26,6 +27,14 @@ export function addAttributeToContentType(newAttribute) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function editContentTypeAttribute(modifiedAttribute, attributePosition) {
|
||||||
|
return {
|
||||||
|
type: EDIT_CONTENT_TYPE_ATTRIBUTE,
|
||||||
|
modifiedAttribute,
|
||||||
|
attributePosition,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function cancelChanges() {
|
export function cancelChanges() {
|
||||||
return {
|
return {
|
||||||
type: CANCEL_CHANGES,
|
type: CANCEL_CHANGES,
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export const ADD_ATTRIBUTE_TO_CONTENT_TYPE = 'ContentTypeBuilder/ModelPage/ADD_ATTRIBUTE_TO_CONTENT_TYPE';
|
export const ADD_ATTRIBUTE_TO_CONTENT_TYPE = 'ContentTypeBuilder/ModelPage/ADD_ATTRIBUTE_TO_CONTENT_TYPE';
|
||||||
|
export const EDIT_CONTENT_TYPE_ATTRIBUTE = 'ContentTypeBuilder/ModelPage/EDIT_CONTENT_TYPE_ATTRIBUTE';
|
||||||
export const CANCEL_CHANGES = 'ContentTypeBuilder/ModelPage/CANCEL_CHANGES';
|
export const CANCEL_CHANGES = 'ContentTypeBuilder/ModelPage/CANCEL_CHANGES';
|
||||||
export const DEFAULT_ACTION = 'ContentTypeBuilder/ModelPage/DEFAULT_ACTION';
|
export const DEFAULT_ACTION = 'ContentTypeBuilder/ModelPage/DEFAULT_ACTION';
|
||||||
export const DELETE_ATTRIBUTE = 'ContentTypeBuilder/ModelPage/DELETE_ATTRIBUTE';
|
export const DELETE_ATTRIBUTE = 'ContentTypeBuilder/ModelPage/DELETE_ATTRIBUTE';
|
||||||
|
@ -119,7 +119,9 @@ export class ModelPage extends React.Component { // eslint-disable-line react/pr
|
|||||||
|
|
||||||
handleEditAttribute = (attributeName) => {
|
handleEditAttribute = (attributeName) => {
|
||||||
const index = findIndex(this.props.modelPage.model.attributes, ['name', attributeName]);
|
const index = findIndex(this.props.modelPage.model.attributes, ['name', attributeName]);
|
||||||
console.log(index);
|
const attribute = this.props.modelPage.model.attributes[index];
|
||||||
|
router.push(`plugins/content-type-builder/models/${this.props.params.modelName}#edit${this.props.params.modelName}::attribute${attribute.params.type}::baseSettings::${index}`);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -235,7 +237,9 @@ export class ModelPage extends React.Component { // eslint-disable-line react/pr
|
|||||||
menuData={this.props.menu}
|
menuData={this.props.menu}
|
||||||
redirectRoute={redirectRoute}
|
redirectRoute={redirectRoute}
|
||||||
modelName={this.props.params.modelName}
|
modelName={this.props.params.modelName}
|
||||||
|
contentTypeData={this.props.modelPage.model}
|
||||||
isModelPage
|
isModelPage
|
||||||
|
modelLoading={this.props.modelPage.modelLoading}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -10,6 +10,7 @@ import { storeData } from '../../utils/storeData';
|
|||||||
/* eslint-disable new-cap */
|
/* eslint-disable new-cap */
|
||||||
import {
|
import {
|
||||||
ADD_ATTRIBUTE_TO_CONTENT_TYPE,
|
ADD_ATTRIBUTE_TO_CONTENT_TYPE,
|
||||||
|
EDIT_CONTENT_TYPE_ATTRIBUTE,
|
||||||
CANCEL_CHANGES,
|
CANCEL_CHANGES,
|
||||||
DELETE_ATTRIBUTE,
|
DELETE_ATTRIBUTE,
|
||||||
MODEL_FETCH_SUCCEEDED,
|
MODEL_FETCH_SUCCEEDED,
|
||||||
@ -27,6 +28,7 @@ const initialState = fromJS({
|
|||||||
}),
|
}),
|
||||||
postContentTypeSuccess: false,
|
postContentTypeSuccess: false,
|
||||||
showButtons: false,
|
showButtons: false,
|
||||||
|
modelLoading: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
function modelPageReducer(state = initialState, action) {
|
function modelPageReducer(state = initialState, action) {
|
||||||
@ -35,6 +37,10 @@ function modelPageReducer(state = initialState, action) {
|
|||||||
return state
|
return state
|
||||||
.updateIn(['model', 'attributes'], (list) => list.push(action.newAttribute))
|
.updateIn(['model', 'attributes'], (list) => list.push(action.newAttribute))
|
||||||
.set('showButtons', true);
|
.set('showButtons', true);
|
||||||
|
case EDIT_CONTENT_TYPE_ATTRIBUTE:
|
||||||
|
return state
|
||||||
|
.set('showButtons', true)
|
||||||
|
.updateIn(['model', 'attributes', action.attributePosition], () => action.modifiedAttribute);
|
||||||
case CANCEL_CHANGES:
|
case CANCEL_CHANGES:
|
||||||
return state
|
return state
|
||||||
.set('showButtons', false)
|
.set('showButtons', false)
|
||||||
@ -57,6 +63,7 @@ function modelPageReducer(state = initialState, action) {
|
|||||||
}
|
}
|
||||||
case MODEL_FETCH_SUCCEEDED:
|
case MODEL_FETCH_SUCCEEDED:
|
||||||
return state
|
return state
|
||||||
|
.set('modelLoading', false)
|
||||||
.set('model', Map(action.model.model))
|
.set('model', Map(action.model.model))
|
||||||
.set('initialModel', Map(action.model.model))
|
.set('initialModel', Map(action.model.model))
|
||||||
.setIn(['model', 'attributes'], List(action.model.model.attributes))
|
.setIn(['model', 'attributes'], List(action.model.model.attributes))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user