From f5307c5608b2e71efe720a88a5467be83c8329ee Mon Sep 17 00:00:00 2001 From: Muhammad Irwan Andriawan Date: Sat, 14 Sep 2019 17:18:36 +0700 Subject: [PATCH] Add jquery implementation on selecting child task trigger selecting job for better logic --- .../projects/jobs/add-from-other-project.blade.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/resources/views/projects/jobs/add-from-other-project.blade.php b/resources/views/projects/jobs/add-from-other-project.blade.php index 55f63cb..c2d9290 100755 --- a/resources/views/projects/jobs/add-from-other-project.blade.php +++ b/resources/views/projects/jobs/add-from-other-project.blade.php @@ -75,9 +75,31 @@ @if ($selectedProject) @foreach ($selectedProject->jobs as $job) + $('#job_id_{{ $job->id }}').change(function () { $('.job_id_{{ $job->id }}_tasks').prop('checked', this.checked); }); + + @foreach($job->tasks as $task) + + $('#{{ $job->id }}_task_id_{{ $task->id }}').change(function () { + + var condition = false; + + $.each($(".job_id_{{ $job->id }}_tasks"), function( key, value ) { + if(value.checked == true){ + condition = true + } + }); + + + if(condition == true){ + $('#job_id_{{ $job->id }}').prop('checked', true); + } + }); + + @endforeach + @endforeach @endif })();