- added fields: longdescr, hoursworked, hoursplanned
This commit is contained in:
@@ -24,6 +24,18 @@ var ProjectSchema = new mongoose.Schema({
|
|||||||
descr: {
|
descr: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
|
longdescr: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
hoursplanned: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
hoursworked: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
id_parent: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
priority: {
|
priority: {
|
||||||
type: Number,
|
type: Number,
|
||||||
},
|
},
|
||||||
@@ -65,7 +77,7 @@ ProjectSchema.methods.toJSON = function () {
|
|||||||
|
|
||||||
// console.log(projObject);
|
// console.log(projObject);
|
||||||
|
|
||||||
return _.pick(projObject, tools.allfieldTodoWithId());
|
return _.pick(projObject, tools.allfieldProjectWithId());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -78,22 +90,15 @@ ProjectSchema.statics.findByUserIdAndCat = function (userId, category) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
ProjectSchema.statics.findAllByUserIdAndCat = function (userId, category = '') {
|
ProjectSchema.statics.findAllByUserId = function (userId) {
|
||||||
var Project = this;
|
var Project = this;
|
||||||
|
|
||||||
if (category === '') {
|
|
||||||
return Project.find({
|
return Project.find({
|
||||||
'userId': userId,
|
'userId': userId,
|
||||||
}).then(ris => {
|
}).then(ris => {
|
||||||
return tools.mapSort(ris)
|
return ris
|
||||||
})
|
})
|
||||||
|
|
||||||
} else {
|
|
||||||
return Project.find({
|
|
||||||
'userId': userId,
|
|
||||||
'category': category,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ProjectSchema.statics.getArrCategoryInTable = function (userId) {
|
ProjectSchema.statics.getArrCategoryInTable = function (userId) {
|
||||||
@@ -111,7 +116,7 @@ ProjectSchema.statics.getAllProjects = async function (userId) {
|
|||||||
|
|
||||||
let obj = [];
|
let obj = [];
|
||||||
|
|
||||||
obj.arrproj = await Project.findAllByUserIdAndCat(userId);
|
obj.arrproj = await Project.findAllByUserId(userId);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ router.patch('/:id', authenticate, (req, res) => {
|
|||||||
|
|
||||||
|
|
||||||
Project.findByIdAndUpdate(id, { $set: body }, { new: true }).then((project) => {
|
Project.findByIdAndUpdate(id, { $set: body }, { new: true }).then((project) => {
|
||||||
tools.mylogshow(' PROJECT TO MODIFY: ', project.descr, project.expiring_at);
|
tools.mylogshow(' PROJECT TO MODIFY: ', project.descr, body);
|
||||||
if (!project) {
|
if (!project) {
|
||||||
return res.status(404).send();
|
return res.status(404).send();
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ function calcProjects(obj) {
|
|||||||
|
|
||||||
// sum the progression
|
// sum the progression
|
||||||
|
|
||||||
myarr[indrec].progressCalc = 1;
|
myarr[indrec].progressCalc = Math.round(Math.random() * 100);
|
||||||
}
|
}
|
||||||
return myarr
|
return myarr
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ module.exports = {
|
|||||||
|
|
||||||
// #TODO Projects++ Add fields ...
|
// #TODO Projects++ Add fields ...
|
||||||
allfieldProject: function () {
|
allfieldProject: function () {
|
||||||
return ['userId', 'pos', 'descr', 'priority', 'completed', 'created_at', 'modify_at',
|
return ['userId', 'pos', 'id_parent', 'descr', 'longdescr', 'hoursplanned', 'hoursworked', 'priority', 'completed', 'created_at', 'modify_at',
|
||||||
'completed_at', 'expiring_at', 'enableExpiring', 'id_prev', 'progressCalc', 'modified']
|
'completed_at', 'expiring_at', 'enableExpiring', 'id_prev', 'progressCalc', 'modified']
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user