- Projects: Shared / Personal

This commit is contained in:
Paolo Arena
2019-04-25 00:30:19 +02:00
parent f3964b0ff0
commit d44c0f3769
2 changed files with 49 additions and 15 deletions

View File

@@ -245,7 +245,7 @@ function logtodo(myarr) {
function getarrlog(myarr) {
let mystr = "";
for (const indcat in myarr){
for (const indcat in myarr) {
mystr += indcat + ': \n';
for (const indelem in myarr[indcat]) {
mystr += ' [' + indelem + '] ' + getelem(myarr[indcat][indelem]) + '\n';
@@ -274,7 +274,7 @@ class CalcTodo {
addDataProj(datain) {
if (!!datain) {
if (datain.actualphase === this.mydata.phase) {
CalcTodo.addFields(this.mydata, datain);
CalcTodo.addFields(this.mydata, datain, true);
}
}
}
@@ -282,19 +282,20 @@ class CalcTodo {
addDataTodo(datain) {
if (!!datain) {
if (datain.phase === this.mydata.phase) {
CalcTodo.addFields(this.mydata, datain);
CalcTodo.addFields(this.mydata, datain, false);
}
}
}
static addFields(recout, recin) {
static addFields(recout, recin, isproj) {
// console.log('addFields', recin);
recout.hoursworked += recin.hoursworked;
recout.hoursplanned += recin.hoursplanned;
if (!!recin.progressCalc)
if (recin.progress === undefined) {
recout.progressCalc += recin.progressCalc;
else
} else {
recout.progressCalc += recin.progress;
}
recout.numitem++;
}
@@ -302,10 +303,15 @@ class CalcTodo {
static copyFields(recout, recin) {
recout.hoursworked = recin.hoursworked;
recout.hoursplanned = recin.hoursplanned;
if (!!recin.progressCalc)
if (recin.progress === undefined)
recout.progressCalc = recin.progressCalc;
else
recout.progressCalc = 0;
else {
if (!!recin.progressCalc)
recout.progressCalc = recin.progressCalc;
else
recout.progressCalc = 0;
}
}
setValuesToRecord(objout) {
@@ -316,6 +322,7 @@ class CalcTodo {
if (this.mydata.numitem > 0) {
this.mydata.progressCalc = Math.round(this.mydata.progressCalc / this.mydata.numitem);
}
console.log('this.mydata.progressCalc', this.mydata.progressCalc)
}
getData() {
@@ -420,6 +427,7 @@ TodoSchema.statics.calculateTodoHoursAndProgress = async function (userId, idpro
objdata.endDataCalc();
return objdata.getData();
})
.catch(e => {