So here's a small snippet of the code that creates a list of active towers. Each tower has a checkbox and if you check it, a list will drop down with all the associated basestations on that tower. That's all fine and dandy. I was able to get the check All checkbox option added in the correct spot as well. (Easy enough, just put it in front of the basestation populating loop.)
So first I should probably make the label a variable as I want the checkbox to switch from uncheck all because all basestations start out checked. Then if you either click uncheck all or uncheck all the basestations manually then it should switch to check all. Now I guess I'm a little lost on how to do this correctly. Do I create a function that listens for that specific checkbox in the controller for this page? Do I add a function in the create.blade.php file? Also, how do I have it determine it's that specific checkbox and only check all checkboxes within the same sub-group.
<div class="row">
<div class="col-md-6 overflow-y mh60vh">
<div class="list-group" id="sites">
@foreach ($sites as $site_id => $basestation_id)
<ul class="list-group-item" id="{!! $site_id !!}">
{!! Form::checkbox($site_id, $site_id, false, [ 'class' => 'site' ]) !!}
{!! $site_id !!} - {!! $basestation_id["group_name"] !!}
<span class="badge">{!! $basestation_id["site_total"] !!}</span>
@if (array_key_exists('fiber', $basestation_id))
<span class="badge hasFiberNode">Fiber Node</span>
@endif
<div class="collapse" id="{!! $site_id !!}-collapse">
<li class="list-group-item">
{!! Form::checkbox(false) !!}
{!! "Check All" !!}
</li>
@foreach ($basestation_id as $type => $basestation)
@if (is_array($basestation))
@foreach ($basestation as $id => $info)
<li class="list-group-item {!! $type !!}" data-type="{!! $type !!}" data-customercount="{!! $info["customer_count_current"] !!}" data-description="{!! $info["description"] !!}">
{!! Form::checkbox($id, $id, false, [ 'class' => "basestation " . $site_id . "-toggle"]) !!}
{!! $info["description"] !!}
<span class="badge">
{!! $info["customer_count_current"] !!}
</span>
</li>
@endforeach
@endif
@endforeach
</div>
</ul>
@endforeach
</div>
</div>
Aucun commentaire:
Enregistrer un commentaire