- added fields: longdescr, hoursworked, hoursplanned
This commit is contained in:
@@ -24,6 +24,18 @@ var ProjectSchema = new mongoose.Schema({
|
||||
descr: {
|
||||
type: String,
|
||||
},
|
||||
longdescr: {
|
||||
type: String,
|
||||
},
|
||||
hoursplanned: {
|
||||
type: Number,
|
||||
},
|
||||
hoursworked: {
|
||||
type: Number,
|
||||
},
|
||||
id_parent: {
|
||||
type: String,
|
||||
},
|
||||
priority: {
|
||||
type: Number,
|
||||
},
|
||||
@@ -65,7 +77,7 @@ ProjectSchema.methods.toJSON = function () {
|
||||
|
||||
// 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;
|
||||
|
||||
if (category === '') {
|
||||
return Project.find({
|
||||
'userId': userId,
|
||||
}).then(ris => {
|
||||
return tools.mapSort(ris)
|
||||
return ris
|
||||
})
|
||||
|
||||
} else {
|
||||
return Project.find({
|
||||
'userId': userId,
|
||||
'category': category,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
ProjectSchema.statics.getArrCategoryInTable = function (userId) {
|
||||
@@ -111,7 +116,7 @@ ProjectSchema.statics.getAllProjects = async function (userId) {
|
||||
|
||||
let obj = [];
|
||||
|
||||
obj.arrproj = await Project.findAllByUserIdAndCat(userId);
|
||||
obj.arrproj = await Project.findAllByUserId(userId);
|
||||
|
||||
return obj;
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ router.patch('/:id', authenticate, (req, res) => {
|
||||
|
||||
|
||||
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) {
|
||||
return res.status(404).send();
|
||||
}
|
||||
@@ -146,7 +146,7 @@ function calcProjects(obj) {
|
||||
|
||||
// sum the progression
|
||||
|
||||
myarr[indrec].progressCalc = 1;
|
||||
myarr[indrec].progressCalc = Math.round(Math.random() * 100);
|
||||
}
|
||||
return myarr
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ module.exports = {
|
||||
|
||||
// #TODO Projects++ Add fields ...
|
||||
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']
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user