Lists list and CUD
Custom forms list Updated DB schema (not yet implemented in the server, which means that most of the server is not broken). - custom forms are independent of a list - order and visibility of fields is now in custom_fields - first_name and last_name has been turned to a regular custom field
This commit is contained in:
parent
216fe40b53
commit
f6e1938ff9
47 changed files with 1245 additions and 122 deletions
10
routes/lists-legacy-integration.js
Normal file
10
routes/lists-legacy-integration.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
'use strict';
|
||||
|
||||
const _ = require('../lib/translate')._;
|
||||
const clientHelpers = require('../lib/client-helpers');
|
||||
|
||||
const router = require('../lib/router-async').create();
|
||||
|
||||
clientHelpers.registerRootRoute(router, 'lists', _('Lists'));
|
||||
|
||||
module.exports = router;
|
|
@ -54,12 +54,15 @@ router.all('/*', (req, res, next) => {
|
|||
next();
|
||||
});
|
||||
|
||||
/* REPLACED
|
||||
router.get('/', (req, res) => {
|
||||
res.render('lists/lists', {
|
||||
title: _('Lists')
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
/* REPLACED
|
||||
router.get('/create', passport.csrfProtection, (req, res) => {
|
||||
let data = tools.convertKeys(req.query, {
|
||||
skip: ['layout']
|
||||
|
@ -75,7 +78,9 @@ router.get('/create', passport.csrfProtection, (req, res) => {
|
|||
|
||||
res.render('lists/create', data);
|
||||
});
|
||||
*/
|
||||
|
||||
/* REPLACED
|
||||
router.post('/create', passport.parseForm, passport.csrfProtection, (req, res) => {
|
||||
lists.create(req.body, (err, id) => {
|
||||
if (err || !id) {
|
||||
|
@ -86,7 +91,9 @@ router.post('/create', passport.parseForm, passport.csrfProtection, (req, res) =
|
|||
res.redirect('/lists/view/' + id);
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
/* REPLACED
|
||||
router.get('/edit/:id', passport.csrfProtection, (req, res) => {
|
||||
lists.get(req.params.id, (err, list) => {
|
||||
if (err || !list) {
|
||||
|
@ -112,7 +119,9 @@ router.get('/edit/:id', passport.csrfProtection, (req, res) => {
|
|||
});
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
/* REPLACED
|
||||
router.post('/edit', passport.parseForm, passport.csrfProtection, (req, res) => {
|
||||
lists.update(req.body.id, req.body, (err, updated) => {
|
||||
|
||||
|
@ -133,7 +142,9 @@ router.post('/edit', passport.parseForm, passport.csrfProtection, (req, res) =>
|
|||
}
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
/* REPLACED
|
||||
router.post('/delete', passport.parseForm, passport.csrfProtection, (req, res) => {
|
||||
lists.delete(req.body.id, (err, deleted) => {
|
||||
if (err) {
|
||||
|
@ -147,6 +158,7 @@ router.post('/delete', passport.parseForm, passport.csrfProtection, (req, res) =
|
|||
return res.redirect('/lists');
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
router.post('/ajax', (req, res) => {
|
||||
lists.filter(req.body, Number(req.query.parent) || false, (err, data, total, filteredTotal) => {
|
|
@ -5,13 +5,14 @@ const _ = require('../lib/translate')._;
|
|||
const reports = require('../models/reports');
|
||||
const fileHelpers = require('../lib/file-helpers');
|
||||
const shares = require('../models/shares');
|
||||
const contextHelpers = require('../lib/context-helpers');
|
||||
|
||||
const router = require('../lib/router-async').create();
|
||||
|
||||
router.getAsync('/download/:id', passport.loggedIn, async (req, res) => {
|
||||
await shares.enforceEntityPermission(req.context, 'report', req.params.id, 'viewContent');
|
||||
|
||||
const report = await reports.getByIdWithTemplate(null, req.params.id);
|
||||
const report = await reports.getByIdWithTemplate(contextHelpers.getAdminContext(), req.params.id);
|
||||
|
||||
if (report.state == reports.ReportState.FINISHED) {
|
||||
const headers = {
|
||||
|
|
|
@ -3,12 +3,13 @@
|
|||
const passport = require('../../lib/passport');
|
||||
const _ = require('../../lib/translate')._;
|
||||
const users = require('../../models/users');
|
||||
const contextHelpers = require('../../lib/context-helpers');
|
||||
|
||||
const router = require('../../lib/router-async').create();
|
||||
|
||||
|
||||
router.getAsync('/account', passport.loggedIn, async (req, res) => {
|
||||
const user = await users.getById(null, req.user.id);
|
||||
const user = await users.getById(contextHelpers.getAdminContext(), req.user.id);
|
||||
user.hash = users.hash(user);
|
||||
return res.json(user);
|
||||
});
|
||||
|
|
42
routes/rest/forms.js
Normal file
42
routes/rest/forms.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
'use strict';
|
||||
|
||||
const passport = require('../../lib/passport');
|
||||
const forms = require('../../models/forms');
|
||||
|
||||
const router = require('../../lib/router-async').create();
|
||||
|
||||
|
||||
router.postAsync('/forms-table', passport.loggedIn, async (req, res) => {
|
||||
return res.json(await forms.listDTAjax(req.context, req.body));
|
||||
});
|
||||
|
||||
router.getAsync('/forms/:formId', passport.loggedIn, async (req, res) => {
|
||||
const entity = await forms.getById(req.context, req.params.formId);
|
||||
entity.hash = forms.hash(entity);
|
||||
return res.json(entity);
|
||||
});
|
||||
|
||||
router.postAsync('/forms', passport.loggedIn, passport.csrfProtection, async (req, res) => {
|
||||
await forms.create(req.context, req.body);
|
||||
return res.json();
|
||||
});
|
||||
|
||||
router.putAsync('/forms/:formId', passport.loggedIn, passport.csrfProtection, async (req, res) => {
|
||||
const entity = req.body;
|
||||
entity.id = parseInt(req.params.formId);
|
||||
|
||||
await forms.updateWithConsistencyCheck(req.context, entity);
|
||||
return res.json();
|
||||
});
|
||||
|
||||
router.deleteAsync('/forms/:formId', passport.loggedIn, passport.csrfProtection, async (req, res) => {
|
||||
await forms.remove(req.context, req.params.formId);
|
||||
return res.json();
|
||||
});
|
||||
|
||||
router.postAsync('/forms-validate', passport.loggedIn, async (req, res) => {
|
||||
return res.json(await forms.serverValidate(req.context, req.body));
|
||||
});
|
||||
|
||||
|
||||
module.exports = router;
|
|
@ -7,7 +7,31 @@ const router = require('../../lib/router-async').create();
|
|||
|
||||
|
||||
router.postAsync('/lists-table', passport.loggedIn, async (req, res) => {
|
||||
return res.json(await lists.listDTAjax(req.body));
|
||||
return res.json(await lists.listDTAjax(req.context, req.body));
|
||||
});
|
||||
|
||||
router.getAsync('/lists/:listId', passport.loggedIn, async (req, res) => {
|
||||
const list = await lists.getById(req.context, req.params.listId);
|
||||
list.hash = lists.hash(list);
|
||||
return res.json(list);
|
||||
});
|
||||
|
||||
router.postAsync('/lists', passport.loggedIn, passport.csrfProtection, async (req, res) => {
|
||||
await lists.create(req.context, req.body);
|
||||
return res.json();
|
||||
});
|
||||
|
||||
router.putAsync('/lists/:listId', passport.loggedIn, passport.csrfProtection, async (req, res) => {
|
||||
const list = req.body;
|
||||
list.id = parseInt(req.params.listId);
|
||||
|
||||
await lists.updateWithConsistencyCheck(req.context, list);
|
||||
return res.json();
|
||||
});
|
||||
|
||||
router.deleteAsync('/lists/:listId', passport.loggedIn, passport.csrfProtection, async (req, res) => {
|
||||
await lists.remove(req.context, req.params.listId);
|
||||
return res.json();
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ const reports = require('../../models/reports');
|
|||
const reportProcessor = require('../../lib/report-processor');
|
||||
const fileHelpers = require('../../lib/file-helpers');
|
||||
const shares = require('../../models/shares');
|
||||
const contextHelpers = require('../../lib/context-helpers');
|
||||
|
||||
const router = require('../../lib/router-async').create();
|
||||
|
||||
|
@ -41,7 +42,7 @@ router.postAsync('/reports-table', passport.loggedIn, async (req, res) => {
|
|||
router.postAsync('/report-start/:id', passport.loggedIn, passport.csrfProtection, async (req, res) => {
|
||||
await shares.enforceEntityPermission(req.context, 'report', req.params.id, 'execute');
|
||||
|
||||
const report = await reports.getByIdWithTemplate(null, req.params.id);
|
||||
const report = await reports.getByIdWithTemplate(contextHelpers.getAdminContext(), req.params.id);
|
||||
await shares.enforceEntityPermission(req.context, 'reportTemplate', report.report_template, 'execute');
|
||||
|
||||
await reportProcessor.start(req.params.id);
|
||||
|
@ -51,7 +52,7 @@ router.postAsync('/report-start/:id', passport.loggedIn, passport.csrfProtection
|
|||
router.postAsync('/report-stop/:id', async (req, res) => {
|
||||
await shares.enforceEntityPermission(req.context, 'report', req.params.id, 'execute');
|
||||
|
||||
const report = await reports.getByIdWithTemplate(null, req.params.id);
|
||||
const report = await reports.getByIdWithTemplate(contextHelpers.getAdminContext(), req.params.id);
|
||||
await shares.enforceEntityPermission(req.context, 'reportTemplate', report.report_template, 'execute');
|
||||
|
||||
await reportProcessor.stop(req.params.id);
|
||||
|
@ -61,14 +62,14 @@ router.postAsync('/report-stop/:id', async (req, res) => {
|
|||
router.getAsync('/report-content/:id', async (req, res) => {
|
||||
await shares.enforceEntityPermission(req.context, 'report', req.params.id, 'viewContent');
|
||||
|
||||
const report = await reports.getByIdWithTemplate(null, req.params.id);
|
||||
const report = await reports.getByIdWithTemplate(contextHelpers.getAdminContext(), req.params.id);
|
||||
res.sendFile(fileHelpers.getReportContentFile(report));
|
||||
});
|
||||
|
||||
router.getAsync('/report-output/:id', async (req, res) => {
|
||||
await shares.enforceEntityPermission(req.context, 'report', req.params.id, 'viewOutput');
|
||||
|
||||
const report = await reports.getByIdWithTemplate(null, req.params.id);
|
||||
const report = await reports.getByIdWithTemplate(contextHelpers.getAdminContext(), req.params.id);
|
||||
res.sendFile(fileHelpers.getReportOutputFile(report));
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue