- Enable Edit Event into dialog form ... (and save to the db)

- Event: enabled drag and drop (date)
- Q-Select components in every table field external: Where, Operators, etc...
- CMyEditor: Add HTML Editor to the details field !
- Added button Color for change font color to the text.
- Complete insert Events Site
This commit is contained in:
Paolo Arena
2019-10-23 23:47:21 +02:00
parent 570bbf3744
commit 51ca2da45f
8 changed files with 386 additions and 49 deletions

View File

@@ -10,6 +10,7 @@ const { Booking } = require('../models/booking');
const { MyEvent } = require('../models/myevent');
const { Operator } = require('../models/operator');
const { Where } = require('../models/where');
const { Contribtype } = require('../models/contribtype');
const { ObjectID } = require('mongodb');
@@ -97,45 +98,41 @@ router.delete('/:id/:notify/:idapp', authenticate, (req, res) => {
});
router.get('/:userId/:idapp/:sall', authenticate, (req, res) => {
const userId = req.params.userId;
const idapp = req.params.idapp;
const sall = req.params.sall;
// var category = req.params.category;
// tools.mylog('GET BOOKINGS : ', req.params);
if (!ObjectID.isValid(userId)) {
return res.status(404).send();
}
if (userId !== String(req.user._id)) {
// I'm trying to write something not mine!
return res.status(404).send({ code: server_constants.RIS_CODE_TODO_CREATING_NOTMYUSER });
}
// Extract all the todos of the userId only
Booking.findAllByUserIdAndIdApp(userId, idapp, sall).then((bookedevent) => {
return MyEvent.findAllIdApp(idapp)
.then((eventlist) => {
return Operator.findAllIdApp(idapp)
.then((operators) => {
return Where.findAllIdApp(idapp)
.then((wheres) => {
res.send({ bookedevent, eventlist, operators, wheres });
})
})
})
}).catch((e) => {
console.log(e);
res.status(400).send(e);
});
});
// router.get('/:userId/:idapp/:sall', authenticate, (req, res) => {
// const userId = req.params.userId;
// const idapp = req.params.idapp;
// const sall = req.params.sall;
// // var category = req.params.category;
//
// // tools.mylog('GET BOOKINGS : ', req.params);
//
// if (!ObjectID.isValid(userId)) {
// return res.status(404).send();
// }
//
// if (userId !== String(req.user._id)) {
// // I'm trying to write something not mine!
// return res.status(404).send({ code: server_constants.RIS_CODE_TODO_CREATING_NOTMYUSER });
// }
//
// // Extract all the todos of the userId only
// const bookedevent = Booking.findAllByUserIdAndIdApp(userId, idapp, sall);
// const eventlist = MyEvent.findAllIdApp(idapp);
// const operators = Operator.findAllIdApp(idapp);
// const wheres = Where.findAllIdApp(idapp);
// const contribtype = Contribtype.findAllIdApp(idapp);
//
// return Promise.all([bookedevent, eventlist, operators, wheres, contribtype])
// .then((arrdata) => {
// console.table(arrdata);
// res.send({ bookedevent: arrdata[0], eventlist: arrdata[1], operators: arrdata[2], wheres: arrdata[3], contribtype: arrdata[4] });
// })
// .catch((e) => {
// console.log(e);
// res.status(400).send(e);
// });
//
// });
//
module.exports = router;

View File

@@ -1,7 +1,7 @@
const express = require('express');
const router = express.Router();
const { authenticate } = require('../middleware/authenticate');
const { authenticate, authenticate_noerror } = require('../middleware/authenticate');
const { ObjectID } = require('mongodb');
@@ -15,6 +15,7 @@ const { Booking } = require('../models/booking');
const { Operator } = require('../models/operator');
const { Where } = require('../models/where');
const { MyEvent } = require('../models/myevent');
const { Contribtype } = require('../models/contribtype');
const tools = require('../tools/general');
@@ -59,9 +60,9 @@ router.post(process.env.LINKVERIF_REG, (req, res) => {
// Faccio richiesta di una Nuova Password
router.post(process.env.LINK_REQUEST_NEWPASSWORD, (req, res) => {
var body = _.pick(req.body, ['idapp', 'email']);
var idapp = body.idapp;
var email = body.email;
const body = _.pick(req.body, ['idapp', 'email']);
const idapp = body.idapp;
const email = body.email;
console.log("POST " + process.env.LINK_REQUEST_NEWPASSWORD + " idapp= " + idapp + " email = " + email);
User.findByEmail(idapp, email).then((user) => {
@@ -84,6 +85,7 @@ router.post(process.env.LINK_REQUEST_NEWPASSWORD, (req, res) => {
});
router.get(process.env.LINK_CHECK_UPDATES, authenticate, (req, res) => {
const userId = req.user._id;
@@ -167,6 +169,8 @@ function getTableByTableName(tablename) {
mytable = Where;
else if (tablename === 'myevents')
mytable = MyEvent;
else if (tablename === 'contribtype')
mytable = Contribtype;
return mytable
}
@@ -325,5 +329,38 @@ function doOtherThingsAfterDeleted() {
}
router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) => {
const userId = req.params.userId;
const idapp = req.params.idapp;
const sall = req.params.sall;
// var category = req.params.category;
tools.mylog('loadsite : ', req.params);
let bookedevent = [];
if (userId !== '0') {
// LOGGED WITH USERID
bookedevent = Booking.findAllByUserIdAndIdApp(userId, idapp, sall);
}
// Extract all the todos of the userId only
const eventlist = MyEvent.findAllIdApp(idapp);
const operators = Operator.findAllIdApp(idapp);
const wheres = Where.findAllIdApp(idapp);
const contribtype = Contribtype.findAllIdApp(idapp);
return Promise.all([bookedevent, eventlist, operators, wheres, contribtype])
.then((arrdata) => {
console.table(arrdata);
res.send({ bookedevent: arrdata[0], eventlist: arrdata[1], operators: arrdata[2], wheres: arrdata[3], contribtype: arrdata[4] });
})
.catch((e) => {
console.log(e);
res.status(400).send(e);
});
});
module.exports = router;