diff --git a/app/Http/Controllers/TaskController.php b/app/Http/Controllers/TaskController.php index 87be5cfbe0..c15b711848 100644 --- a/app/Http/Controllers/TaskController.php +++ b/app/Http/Controllers/TaskController.php @@ -243,6 +243,7 @@ class TaskController extends BaseController } if (request()->wantsJson()) { + $task->time_log = json_decode($task->time_log); return $task->load(['client.contacts', 'project'])->toJson(); } else { return Redirect::to("tasks/{$task->public_id}/edit"); diff --git a/app/Ninja/Repositories/TaskRepository.php b/app/Ninja/Repositories/TaskRepository.php index 30ee6fd409..327164741e 100644 --- a/app/Ninja/Repositories/TaskRepository.php +++ b/app/Ninja/Repositories/TaskRepository.php @@ -156,14 +156,6 @@ class TaskRepository extends BaseRepository $task->is_running = $data['is_running'] ? 1 : 0; } - /* - if ($count = count($timeLog)) { - $lastTime = $timeLog[$count - 1]; - $task->is_running = count($lastTime) == 2 && intval($lastTime[1]); - \Log::info('is running: ' . $task->is_running); - } - */ - $task->time_log = json_encode($timeLog); $task->save(); diff --git a/resources/views/tasks/time_tracker_knockout.blade.php b/resources/views/tasks/time_tracker_knockout.blade.php index 5b07c2bbf7..c17d46995b 100644 --- a/resources/views/tasks/time_tracker_knockout.blade.php +++ b/resources/views/tasks/time_tracker_knockout.blade.php @@ -434,7 +434,6 @@ json: 'application/json' }, success: function(response) { - console.log(response); if (isSelected) { var clientId = $('input[name=client_id]').val(); if (clientId == -1 && response.client) { @@ -463,6 +462,7 @@ toastr.success("{{ trans('texts.updated_task') }}"); } } else { + self.update(response); if (self.isRunning()) { if (self.time_log().length == 1) { toastr.success("{{ trans('texts.started_task') }}"); @@ -485,8 +485,7 @@ self.update = function(data) { self.data = data; - var times = JSON.parse(data.time_log); - data.time_log = false; + var times = data.time_log instanceof Array ? data.time_log : JSON.parse(data.time_log); ko.mapping.fromJS(data, self.mapping, this); self.time_log.removeAll(); for (var i=0; i