@extends('layouts.app')
@section('title', $s['title'])
@section('content')
<section class="content-header"><h1>{{ $s['title'] }}</h1></section>
<section class="content">
    @component('components.widget', ['class' => 'box-primary'])
        @can($s['permManage'])
            @slot('tool')
                <div class="box-tools">
                    <button class="btn btn-primary vrc-modal-btn" data-href="{{ route($s['route'].'.create') }}"><i class="fa fa-plus"></i> @lang('messages.add')</button>
                </div>
            @endslot
        @endcan
        <div class="table-responsive">
            <table class="table table-bordered table-striped" id="vrc_reg_{{ $s['key'] }}_table">
                <thead><tr>
                    @foreach($s['columns'] as $col)
                        <th>{{ $col['label'] }}</th>
                    @endforeach
                    <th>@lang('messages.action')</th>
                </tr></thead>
            </table>
        </div>
    @endcomponent
    <div class="modal fade vrc_modal" tabindex="-1" role="dialog"></div>
</section>
@endsection
@section('javascript')
<script>
$(function () {
    var table = $('#vrc_reg_{{ $s['key'] }}_table').DataTable({
        processing: true, serverSide: true, ajax: '{{ route($s['route'].'.index') }}',
        columns: [
            @foreach($s['columns'] as $col)
            { data: '{{ $col['key'] }}', name: '{{ $col['key'] }}', @if(!empty($col['noSort']))orderable:false,@endif },
            @endforeach
            { data: 'action', name: 'action', orderable: false, searchable: false },
        ],
        order: [],
    });
    window.__vrcTables = window.__vrcTables || []; window.__vrcTables.push(table);
});
</script>
@include('vrc::partials.crud_scripts')
@endsection
