Complete funnel

This commit is contained in:
Aurélien Georget 2019-01-23 15:33:30 +01:00
parent e9db64cd89
commit 5f8b4ae667
4 changed files with 9 additions and 2 deletions

View File

@ -64,6 +64,8 @@ module.exports = {
try {
// Create an entry using `queries` system
ctx.body = await strapi.plugins['content-manager'].services['contentmanager'].add(ctx.params, ctx.request.body, source);
strapi.emit('didCreateFirstContentTypeEntry', ctx.params, source);
} catch(error) {
strapi.log.error(error);
ctx.badRequest(null, ctx.request.admin ? [{ messages: [{ id: error.message, field: error.field }] }] : error.message);

View File

@ -78,6 +78,10 @@ module.exports = {
try {
fs.writeFileSync(modelFilePath, JSON.stringify(modelJSON, null, 2), 'utf8');
if (_.isEmpty(strapi.api)) {
strapi.emit('didCreateFirstContentType');
}
ctx.send({ ok: true });
strapi.reload();

View File

@ -160,9 +160,11 @@ module.exports = {
try {
await strapi.plugins['users-permissions'].services.userspermissions.updateRole(roleID, ctx.request.body);
strapi.emit('didOpenAccessToFetchContentTypeEntries', ctx.request.body);
ctx.send({ ok: true });
} catch(error) {
} catch (error) {
ctx.badRequest(null, [{ messages: [{ id: 'An error occurred' }] }]);
}
},

View File

@ -420,7 +420,6 @@ module.exports = {
arrayOfPromises.push(this.updateUserRole(user, authenticated._id || authenticated.id));
});
return Promise.all(arrayOfPromises);
},