++ hoursweeky_plannedtowork, endwork_estimate, totalphases , actualphase
This commit is contained in:
@@ -79,11 +79,12 @@ router.patch('/:id', authenticate, (req, res) => {
|
||||
|
||||
|
||||
Project.findByIdAndUpdate(id, { $set: body }, { new: true }).then((project) => {
|
||||
tools.mylogshow(' PROJECT TO MODIFY: ', project.descr, body);
|
||||
tools.mylogshow(' PROJECT TO MODIFY: ', project.descr);
|
||||
if (!project) {
|
||||
return res.status(404).send();
|
||||
}
|
||||
|
||||
|
||||
if (project.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 });
|
||||
@@ -91,9 +92,17 @@ router.patch('/:id', authenticate, (req, res) => {
|
||||
|
||||
project.modified = false;
|
||||
|
||||
tools.mylog('PATCH ', project.descr, project._id);
|
||||
// Recalculate
|
||||
return calcSingleProject('', project)
|
||||
.then(objout => {
|
||||
tools.mylog('PATCH ', project.descr, project._id, project.progressCalc);
|
||||
|
||||
return Project.findById(id).then((projectris) => {
|
||||
// console.log('projectris progressCalc', projectris.progressCalc);
|
||||
res.send({ projectris });
|
||||
});
|
||||
});
|
||||
|
||||
res.send({ project });
|
||||
}).catch((e) => {
|
||||
tools.mylogserr('Error patch PROJECT: ', e);
|
||||
res.status(400).send();
|
||||
@@ -153,7 +162,7 @@ async function calcProjects(userId, obj) {
|
||||
promiseChain = promiseChain.then(() => {
|
||||
// Find the todos for this project
|
||||
// Calculate the Progression of the Project // sum the progression
|
||||
return Todo.calculateTreeTodo(userId, rec._id, false, rec._id, false)
|
||||
return Todo.calculateTreeTodo(userId, rec._id)
|
||||
})
|
||||
}
|
||||
return promiseChain
|
||||
@@ -165,6 +174,13 @@ async function calcProjects(userId, obj) {
|
||||
|
||||
}
|
||||
|
||||
// USATO SOLO LE PRIME VOLTE! O A RICHIESTA!
|
||||
async function calcSingleProject(userId, myproj) {
|
||||
|
||||
return await Todo.calculateTreeTodo(myproj.actualphase, userId, myproj._id, false, myproj._id, false)
|
||||
|
||||
}
|
||||
|
||||
router.delete('/:id', authenticate, (req, res) => {
|
||||
var id = req.params.id;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user