mirror of
https://github.com/Mintplex-Labs/express-admin.git
synced 2026-07-21 00:45:22 -04:00
Editview route fixes
This commit is contained in:
+11
-6
@@ -1,6 +1,7 @@
|
||||
|
||||
var dcopy = require('deep-copy');
|
||||
var editview = require('../lib/core/editview'),
|
||||
var upload = require('../lib/utils/upload'),
|
||||
editview = require('../lib/core/editview'),
|
||||
database = require('../lib/core/database');
|
||||
|
||||
|
||||
@@ -28,6 +29,10 @@ exports.get = function (req, res, next) {
|
||||
});
|
||||
}
|
||||
|
||||
exports.upload = function (req, res, next) {
|
||||
upload.files(req, next);
|
||||
}
|
||||
|
||||
exports.post = function (req, res, next) {
|
||||
var args = getArgs(req, res);
|
||||
// var fs = require('fs');
|
||||
@@ -40,7 +45,7 @@ exports.post = function (req, res, next) {
|
||||
action = req.body.action,
|
||||
table = Object.keys(view)[0];
|
||||
|
||||
if (action.hasOwnProperty('remove')) {
|
||||
if ({}.hasOwnProperty.call(action, 'remove')) {
|
||||
// should be based on constraints
|
||||
args.action = 'remove';
|
||||
|
||||
@@ -70,20 +75,20 @@ exports.post = function (req, res, next) {
|
||||
|
||||
// based on clicked button
|
||||
switch (true) {
|
||||
case action.hasOwnProperty('remove'):
|
||||
case {}.hasOwnProperty.call(action, 'remove'):
|
||||
// the message should be different for delete
|
||||
req.session.success = true;
|
||||
res.redirect(res.locals.root+'/'+args.slug);
|
||||
break;
|
||||
case action.hasOwnProperty('save'):
|
||||
case {}.hasOwnProperty.call(action, 'save'):
|
||||
req.session.success = true;
|
||||
res.redirect(res.locals.root+'/'+args.slug);
|
||||
break;
|
||||
case action.hasOwnProperty('another'):
|
||||
case {}.hasOwnProperty.call(action, 'another'):
|
||||
req.session.success = true;
|
||||
res.redirect(res.locals.root+'/'+args.slug+'/add');
|
||||
break;
|
||||
case action.hasOwnProperty('continue'):
|
||||
case {}.hasOwnProperty.call(action, 'continue'):
|
||||
req.session.success = true;
|
||||
if (args.debug) return render(req, res, next, data, args);
|
||||
res.redirect(res.locals.root+'/'+args.slug+'/'+args.id);
|
||||
|
||||
Reference in New Issue
Block a user