Browse Source

merge minutes for pastDays the right way;

feature/tasks
stingl 4 years ago
parent
commit
8e0a48217a
  1. 38
      js/app.js

38
js/app.js

@ -487,12 +487,16 @@ const TimeTrack = { @@ -487,12 +487,16 @@ const TimeTrack = {
this.tickets.forEach((ticket) => {
ticket.history.forEach((historyEntry) => {
if (moment(historyEntry.trackingStarted).format("MMM Do YY") === day) {
historyEntry.ticket = ticket.number;
let newEntry = {};
Object.assign(newEntry, historyEntry);
newEntry.ticket = ticket.number;
if (collection[ticket.number]) {
collection[ticket.number] += historyEntry.minutes;
let existingEntry = this.getCollectionItemWithValue(collection, 'ticket', ticket.number);
if (existingEntry) {
existingEntry.minutes = Number(existingEntry.minutes) + Number(newEntry.minutes);
} else {
collection[ticket.number] = historyEntry;
collection.push(newEntry);
}
}
});
@ -501,15 +505,35 @@ const TimeTrack = { @@ -501,15 +505,35 @@ const TimeTrack = {
this.archive.forEach((ticket) => {
ticket.history.forEach((historyEntry) => {
if (moment(historyEntry.trackingStarted).format("MMM Do YY") === day) {
historyEntry.ticket = ticket.number;
historyEntry.archive = true;
collection.push(historyEntry);
let newEntry = {};
Object.assign(newEntry, historyEntry);
newEntry.ticket = ticket.number;
let existingEntry = this.getCollectionItemWithValue(collection, 'ticket', ticket.number);
if (existingEntry) {
existingEntry.minutes = Number(existingEntry.minutes) + Number(newEntry.minutes);
} else {
collection.push(newEntry);
}
}
});
});
console.log(collection);
return collection;
},
getCollectionItemWithValue(collection, property, value) {
let found = false;
collection.forEach((item) => {
if (item[property] === value) {
found = item;
}
})
return found;
},
sendPortalChangeRequest() {
let vue = this;
let publicDBParam = this.publicDB ? '&publicDB=1' : '';