1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Working on the time tracker

This commit is contained in:
Hillel Coren 2017-10-01 16:31:19 +03:00
parent 6f76cb1686
commit 09ad1668a0
2 changed files with 20 additions and 11 deletions

View File

@ -112,8 +112,9 @@
bottom: 0; bottom: 0;
width: 6px; width: 6px;
content: ""; content: "";
background-color: #d9534f; /* red */
xbackground-color: #36c157; /* green */ xbackground-color: #36c157; /* green */
background-color: orange; /* orange */ xbackground-color: orange; /* orange */
} }
body { body {

View File

@ -49,6 +49,7 @@
ko.utils.registerEventHandler(element, 'change', function () { ko.utils.registerEventHandler(element, 'change', function () {
var value = valueAccessor(); var value = valueAccessor();
var seconds = $(element).timepicker('getSecondsFromMidnight'); var seconds = $(element).timepicker('getSecondsFromMidnight');
console.log('seconds:' + seconds);
value(seconds); value(seconds);
}); });
}, },
@ -303,10 +304,6 @@
if (self.selectedTask()) { if (self.selectedTask()) {
self.selectedTask().onStartClick(); self.selectedTask().onStartClick();
} else { } else {
if (! task.checkForOverlaps()) {
swal("{{ trans('texts.task_errors') }}");
return;
}
var time = new TimeModel(); var time = new TimeModel();
time.startTime(moment().unix()); time.startTime(moment().unix());
var task = new TaskModel(); var task = new TaskModel();
@ -675,7 +672,10 @@
var startValid = true; var startValid = true;
var endValid = true; var endValid = true;
if (!timeLog.isEmpty()) { if (!timeLog.isEmpty()) {
if (timeLog.startTime() < lastTime || (timeLog.endTime() && timeLog.startTime() > timeLog.endTime())) { console.log('1: ' + (lastTime && timeLog.startTime() < lastTime));
console.log('2: ' + (timeLog.endTime() && timeLog.startTime() > timeLog.endTime()));
console.log('end: ' + timeLog.endTime());
if ((lastTime && timeLog.startTime() < lastTime) || (timeLog.endTime() && timeLog.startTime() > timeLog.endTime())) {
startValid = false; startValid = false;
} }
if (timeLog.endTime() && timeLog.endTime() < Math.min(timeLog.startTime(), lastTime)) { if (timeLog.endTime() && timeLog.endTime() < Math.min(timeLog.startTime(), lastTime)) {
@ -1059,12 +1059,16 @@
return self.startTime(); return self.startTime();
}, },
write: function(value) { write: function(value) {
if (self.startTime()) { if (value === null) {
var orig = self.startDateMidnight().unix(); self.startTime('');
} else { } else {
var orig = moment().set('hours', 0).set('minutes', 0).set('seconds', 0).unix(); if (self.startTime()) {
var orig = self.startDateMidnight().unix();
} else {
var orig = moment().set('hours', 0).set('minutes', 0).set('seconds', 0).unix();
}
self.startTime(orig + value);
} }
self.startTime(orig + value);
} }
}); });
@ -1073,7 +1077,11 @@
return self.endTime(); return self.endTime();
}, },
write: function(value) { write: function(value) {
self.endTime(self.startDateMidnight().unix() + value); if (value === null) {
self.endTime('');
} else {
self.endTime(self.startDateMidnight().unix() + value);
}
} }
}); });