Fix relations

This commit is contained in:
soupette 2019-03-25 19:08:17 +01:00
parent 618d8afa4d
commit d2f50f7bae
6 changed files with 11 additions and 13 deletions

View File

@ -329,7 +329,9 @@ export const formatModelAttributes = attributes =>
if ( if (
((curr.includes('max') || curr.includes('min')) && !value) || ((curr.includes('max') || curr.includes('min')) && !value) ||
curr === 'isVirtual' || curr === 'isVirtual' ||
(curr === 'dominant' && !value) (curr === 'dominant' && !value) ||
(curr === 'columnName' && value === '') ||
(curr === 'targetColumnName' && value === '')
) { ) {
return acc2; return acc2;
} }

View File

@ -54,16 +54,16 @@ export function* submitCT({
body.plugin = source; body.plugin = source;
} }
yield put(emitEvent('willSaveContentType')); emitEvent('willSaveContentType');
const opts = { method: 'PUT', body }; const opts = { method: 'PUT', body };
yield call(request, requestURL, opts, true); yield call(request, requestURL, opts, true);
yield put(emitEvent('didSaveContentType')); emitEvent('didSaveContentType');
yield put(submitContentTypeSucceeded(oldContentTypeName)); yield put(submitContentTypeSucceeded(oldContentTypeName));
if (name !== oldContentTypeName) { if (name !== oldContentTypeName) {
yield put(emitEvent('didEditNameOfContentType')); emitEvent('didEditNameOfContentType');
const appPlugins = plugins.toJS ? plugins.toJS() : plugins; const appPlugins = plugins.toJS ? plugins.toJS() : plugins;
const appMenu = get(appPlugins, ['content-manager', 'leftMenuSections'], []); const appMenu = get(appPlugins, ['content-manager', 'leftMenuSections'], []);
@ -86,14 +86,14 @@ export function* submitCT({
/* istanbul ignore-next */ /* istanbul ignore-next */
export function* submitTempCT({ body, context: { emitEvent, plugins, updatePlugin } }) { export function* submitTempCT({ body, context: { emitEvent, plugins, updatePlugin } }) {
try { try {
yield put(emitEvent('willSaveContentType')); emitEvent('willSaveContentType');
const requestURL = `/${pluginId}/models`; const requestURL = `/${pluginId}/models`;
const opts = { method: 'POST', body }; const opts = { method: 'POST', body };
yield call(request, requestURL, opts, true); yield call(request, requestURL, opts, true);
yield put(emitEvent('didSaveContentType')); emitEvent('didSaveContentType');
yield put(submitTempContentTypeSucceeded()); yield put(submitTempContentTypeSucceeded());
const { name } = body; const { name } = body;

View File

@ -140,7 +140,6 @@ describe('Content Type Builder Action utils', () => {
pluginValue: 'users-permissions', pluginValue: 'users-permissions',
plugin: true, plugin: true,
configurable: false, configurable: false,
targetColumnName: '',
target: 'role', target: 'role',
}, },
}, },
@ -152,7 +151,6 @@ describe('Content Type Builder Action utils', () => {
nature: 'manyToMany', nature: 'manyToMany',
pluginValue: 'users-permissions', pluginValue: 'users-permissions',
plugin: true, plugin: true,
targetColumnName: '',
target: 'role2', target: 'role2',
}, },
}, },
@ -740,7 +738,6 @@ describe('App actions', () => {
pluginValue: 'users-permissions', pluginValue: 'users-permissions',
plugin: true, plugin: true,
configurable: false, configurable: false,
targetColumnName: '',
target: 'role', target: 'role',
}, },
}, },
@ -833,7 +830,6 @@ describe('App actions', () => {
pluginValue: 'users-permissions', pluginValue: 'users-permissions',
plugin: true, plugin: true,
configurable: false, configurable: false,
targetColumnName: '',
target: 'role', target: 'role',
}, },
}, },

View File

@ -359,7 +359,6 @@
"type": "checkbox", "type": "checkbox",
"value": false, "value": false,
"validations": { "validations": {
"required": true
} }
} }
] ]

View File

@ -266,7 +266,7 @@ export class ModelPage extends React.Component {
} = this.props; } = this.props;
const attributeType = ['integer', 'biginteger', 'float', 'decimal'].includes(type) ? 'number' : type; const attributeType = ['integer', 'biginteger', 'float', 'decimal'].includes(type) ? 'number' : type;
if (canOpenModal) { if (canOpenModal || this.isUpdatingTemporaryContentType()) {
setTemporaryAttribute(attributeName, this.isUpdatingTemporaryContentType(), this.getModelName()); setTemporaryAttribute(attributeName, this.isUpdatingTemporaryContentType(), this.getModelName());
await this.wait(); await this.wait();

View File

@ -30,6 +30,7 @@
"users": { "users": {
"collection": "user", "collection": "user",
"via": "role", "via": "role",
"configurable": false,
"plugin": "users-permissions" "plugin": "users-permissions"
} }
}, },