From fc624d1aabbb54bee8fb19c0d4a86c0da6642fda Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 1 Oct 2017 20:09:53 +0300 Subject: [PATCH] Working on the time tracker --- .../views/tasks/time_tracker_knockout.blade.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/resources/views/tasks/time_tracker_knockout.blade.php b/resources/views/tasks/time_tracker_knockout.blade.php index f4d96d64319a..c8a7b335c79e 100644 --- a/resources/views/tasks/time_tracker_knockout.blade.php +++ b/resources/views/tasks/time_tracker_knockout.blade.php @@ -983,7 +983,7 @@ duration = Math.floor(duration / 100) / 10; } else { self.time_log().forEach(function(time){ - duration += time.duration(); + duration += time.duration.running(); }); } @@ -1173,6 +1173,19 @@ }); self.duration = ko.computed({ + read: function () { + model.clock(); // bind to the clock + if (! self.startTime() || ! self.endTime()) { + return false; + } + return self.endTime() - self.startTime(); + }, + write: function(value) { + self.endTime(self.startTime() + value); + } + }); + + self.duration.running = ko.computed({ read: function () { model.clock(); // bind to the clock if (! self.startTime()) { @@ -1185,6 +1198,8 @@ self.endTime(self.startTime() + value); } }); + + }