From 5e0f8382712a8763fe6c5537bf5fabcb4a76f46f Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 24 Sep 2017 21:44:37 +0300 Subject: [PATCH] Working on time tracker --- app/Ninja/Repositories/TaskRepository.php | 4 +++- resources/views/tasks/time_tracker_knockout.blade.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Ninja/Repositories/TaskRepository.php b/app/Ninja/Repositories/TaskRepository.php index 18fe77c50a..30ee6fd409 100644 --- a/app/Ninja/Repositories/TaskRepository.php +++ b/app/Ninja/Repositories/TaskRepository.php @@ -152,12 +152,14 @@ class TaskRepository extends BaseRepository } elseif ($data['action'] == 'offline'){ $task->is_running = $data['is_running'] ? 1 : 0; } + } elseif (isset($data['is_running'])) { + $task->is_running = $data['is_running'] ? 1 : 0; } /* if ($count = count($timeLog)) { $lastTime = $timeLog[$count - 1]; - $task->is_running = count($lastTime) == 2 && $lastTime[1]; + $task->is_running = count($lastTime) == 2 && intval($lastTime[1]); \Log::info('is running: ' . $task->is_running); } */ diff --git a/resources/views/tasks/time_tracker_knockout.blade.php b/resources/views/tasks/time_tracker_knockout.blade.php index 460798eca8..b692bcfedf 100644 --- a/resources/views/tasks/time_tracker_knockout.blade.php +++ b/resources/views/tasks/time_tracker_knockout.blade.php @@ -431,14 +431,16 @@ self.onStartClick = function() { if (self.isRunning()) { + var data = 'is_running=0&'; var time = self.lastTime(); time.endTime(moment().unix()); } else { + var data = 'is_running=1&'; var time = new TimeModel(); time.startTime(moment().unix()); self.addTime(time); } - self.save('time_log=' + JSON.stringify(self.times())); + self.save(data + 'time_log=' + JSON.stringify(self.times())); } self.listItemState = ko.computed(function() {