diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/PopUpRelations/index.js b/packages/strapi-plugin-content-type-builder/admin/src/components/PopUpRelations/index.js index d1610880ea..d9053c7686 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/components/PopUpRelations/index.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/components/PopUpRelations/index.js @@ -161,7 +161,7 @@ class PopUpRelations extends React.Component { // eslint-disable-line react/pref const modalBody = this.props.showRelation ? this.renderModalBodyRelations(): this.renderModalBodyAdvanced(); const handleToggle = this.props.toggle; - + return (
diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/index.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/index.js index e6a9289aa2..9b5f5e8348 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/index.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/Form/index.js @@ -530,6 +530,9 @@ export class Form extends React.Component { // eslint-disable-line react/prefer- const selectOptions = includes(this.props.hash, 'attributenumber') ? get(this.props.form, ['items', '1', 'items']) : this.props.selectOptions; if (includes(popUpFormType, 'relation')) { + const contentType = this.props.modelName.split('&source='); + const contentTypeIndex = contentType.length === 2 ? { name: contentType[0], source: contentType[1] } : { name: contentType[0] }; + return ( { - this.props.submit(this.context); + this.props.submit(this.context, this.props.match.params.modelName); } toggleModal = () => { diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/ModelPage/sagas.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/ModelPage/sagas.js index 531542316c..41799949e3 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/ModelPage/sagas.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/ModelPage/sagas.js @@ -1,6 +1,7 @@ import { LOCATION_CHANGE } from 'react-router-redux'; import { capitalize, + cloneDeep, forEach, get, includes, @@ -75,8 +76,8 @@ export function* submitChanges(action) { yield put(setButtonLoader()); const modelName = get(storeData.getContentType(), 'name'); - - const body = yield select(makeSelectModel()); + const data = yield select(makeSelectModel()); + const body = cloneDeep(data); map(body.attributes, (attribute, index) => { // Remove the connection key from attributes @@ -89,18 +90,27 @@ export function* submitChanges(action) { delete body.attributes[index].params.dominant; } - if (includes(key, 'Value')) { + if (includes(key, 'Value') && key !== 'pluginValue') { // Remove and set needed keys for params set(body.attributes[index].params, replace(key, 'Value', ''), value); unset(body.attributes[index].params, key); } + if (key === 'pluginValue' && value) { + set(body.attributes[index].params, 'plugin', true); + } + if (!value) { const paramsKey = includes(key, 'Value') ? replace(key,'Value', '') : key; unset(body.attributes[index].params, paramsKey); } }); }); + const pluginModel = action.modelName.split('&source=')[1]; + + if (pluginModel) { + set(body, 'plugin', pluginModel); + } const method = modelName === body.name ? 'POST' : 'PUT'; const baseUrl = '/content-type-builder/models/';