diff --git a/resources/views/time_tracker.blade.php b/resources/views/time_tracker.blade.php index 7d24768cdc..aa5732c4e0 100644 --- a/resources/views/time_tracker.blade.php +++ b/resources/views/time_tracker.blade.php @@ -98,8 +98,8 @@
   -
@@ -160,9 +160,8 @@ self.onStartClick = function() { if (self.selectedTask()) { - console.log('start w/selected...'); + self.selectedTask().onStartClick(); } else { - console.log('start w/o selected...'); var time = new TimeModel(); time.startTime(moment().unix()); var task = new TaskModel(); @@ -295,6 +294,18 @@ return false; } + self.onStartClick = function() { + if (self.isRunning()) { + var times = self.time_log(); + var time = times[times.length-1]; + time.endTime(moment().unix()); + } else { + var time = new TimeModel(); + time.startTime(moment().unix()); + self.addTime(time); + } + } + self.isRunning = ko.computed(function() { if (! self.time_log().length) { return false;