Skip to content

Commit

Permalink
Merge branch 'hotfix/2.6.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerome Bonini committed Jun 15, 2018
2 parents ed36bf6 + 55045f7 commit 1ccfd79
Show file tree
Hide file tree
Showing 10 changed files with 647 additions and 395 deletions.
19 changes: 12 additions & 7 deletions structure/pieces/administration/routes/e_user.js
Expand Up @@ -179,8 +179,8 @@ router.get('/create_form', block_access.actionAccessMiddleware("user", "create")
Promise.all(associationsFinder).then(function (found) {
for (var i = 0; i < found.length; i++)
data[found[i].model] = found[i].rows;

res.render('e_user/create', data);
var view = req.query.ajax ? 'e_user/create_fields' : 'e_user/create';
res.render(view, data);
}).catch(function (err) {
entity_helper.error500(err, req, res, "/");
});
Expand Down Expand Up @@ -292,7 +292,10 @@ router.get('/update_form', block_access.actionAccessMiddleware("user", "update")
}

req.session.toastr = [];
res.render('e_user/update', data);
if (req.query.ajax) {
res.render('e_user/update_fields', e_user.get({plain: true}));
} else
res.render('e_user/update', data);
}).catch(function (err) {
entity_helper.error500(err, req, res, "/");
});
Expand Down Expand Up @@ -540,14 +543,16 @@ router.post('/search', block_access.actionAccessMiddleware('user', 'read'), func
}
}

// /!\ DISABLED FOR USER /!\
// Possibility to add custom where in select2 ajax instanciation
if (typeof req.body.customWhere !== "undefined")
for (var param in req.body.customWhere)
where.where[param] = req.body.customWhere[param];
// if (typeof req.body.customWhere !== "undefined")
// for (var param in req.body.customWhere)
// where.where[param] = req.body.customWhere[param];

where.offset = offset;
where.limit = limit;

console.log(where);
where.include = [{model: models.E_role, as:'r_role'}, {model: models.E_group, as: 'r_group'}];
models.E_user.findAndCountAll(where).then(function (results) {
results.more = results.count > req.body.page * SELECT_PAGE_SIZE ? true : false;
res.json(results);
Expand Down
4 changes: 2 additions & 2 deletions structure/pieces/api/api_entity.js
Expand Up @@ -170,7 +170,7 @@ router.post('/', function(req, res) {
console.error("API: Couldn't set association.\nAPI: ENTITY_NAME.set"+entity_helper.capitalizeFirstLetter(prop)+"() is undefined.");
}

associationPromises.then(function() {
Promise.all(associationPromises).then(function() {
res.status(200).json(answer);
}).catch(function(err) {
answer.error = "Error with associations";
Expand Down Expand Up @@ -213,7 +213,7 @@ router.put('/:id', function(req, res) {
console.error("API: Couldn't set association.\nAPI: ENTITY_NAME.set"+entity_helper.capitalizeFirstLetter(prop)+"() is undefined.");
}

associationPromises.then(function() {
Promise.all(associationPromises).then(function() {
res.status(200).json(answer);
}).catch(function(err) {
answer.error = "Error with associations";
Expand Down

0 comments on commit 1ccfd79

Please sign in to comment.