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