@extends('Vzdelavanie::layout.integrated')

@section('content')
    @parent
    <section class="bg-white pb-4">
        <div class="container">
            <div class="row">
                <div class="col">
                    <h1 class="h2 mb-2">Zoznam odpovedí na otázku</h1>
                    <span>"{!! $otazka->znenie  !!}"</span>
                </div>
            </div>
        </div>
    </section>

    <section class="flush-with-above space-0">
        <div class="bg-white">
            <div class="container">
                <div class="row">
                    <div class="col">
                        <ul class="nav nav-tabs" id="myTab" role="tablist">
                            <li class="nav-item">
                                <a class="nav-link" href="{{ route('vzdelavanie.sprava.testovanie.testy.edit', $test) }}">Test</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" href="{{ route('vzdelavanie.sprava.testovanie.testy.otazky.edit', [$test, $otazka]) }}">Otázka</a>
                            </li>
                            <li class="nav-item">
                                <p class="nav-link active">
                                    Odpovede
                                    <span class="badge badge-light">{{ $odpovede->count() }}</span>
                                </p>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <section class="flush-with-above height-80 d-block">
        <div class="tab-content">
            <div class="tab-pane fade show active">
                <div class="container">
                    <div class="row mb-4">
                        <div class="col">
                            <h5>Zoznam odpovedí</h5>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col">
                            <div class="d-flex justify-content-between align-items-center mb-4">
                                <div>
                                    <span class="text-muted text-small">Počet položiek {{ $odpovede->count() }}</span>
                                </div>
                                <form class="d-flex align-items-center">
                                    <span class="mr-2 text-muted text-small text-nowrap">Zoradiť podľa:</span>
                                    <select class="custom-select">
                                        <option value="new-old" selected>Od najnovších</option>
                                        <option value="old-new">Od najstarších</option>
                                        <option value="status">Podľa stavu</option>
                                    </select>
                                </form>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col">
                            @if(!$otazka->odpovede->count())
                            <div class="card card-lg text-center">
                                <div class="card-body">
                                    <i class="icon-add-to-list display-4 opacity-20"></i>
                                    <h1 class="h5">Na otázku ešte neexistujú žiadne odpovede...</h1>
                                    <a href="{{ route('vzdelavanie.sprava.testovanie.testy.otazky.odpovede.create', [$test, $otazka]) }}" class="btn btn-lg btn-outline-primary">
                                        <i class="fa fa-plus"></i>
                                        &nbsp;Vytvoriť novú odpoveď
                                    </a>
                                </div>
                            </div>
                            @else
                            <div class="table-responsive">
                                <table class="table table-borderless align-items-center">
                                    <thead>
                                    <tr>
                                        <th scope="col">#</th>
                                        <th scope="col">Znenie odpovede</th>
                                        <th scope="col">Hodnotenie</th>
                                        <th scope="col">Stav</th>
                                        <th scope="col"></th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    @foreach($odpovede as $odpoved)
                                        <tr class="bg-white">
                                            <th scope="col" class="text-monospace">{{ ++$loop->index }}.</th>
                                            <td scope="row">{!! $odpoved->znenie !!}</td>
                                            <td>
                                                <span class="badge @if($odpoved->hodnotenie->equals(\Seka\Vzdelavanie\Models\Testovanie\HodnotenieOdpovedeEnum::SPRAVNA())) badge-success @else badge-danger @endif">{{ \Illuminate\Support\Str::upper($odpoved->hodnotenie->label) }}</span>
                                            </td>
                                            <td>
                                                <span class="badge @if($odpoved->stav->equals(\Seka\Vzdelavanie\Enums\ModelStatusEnum::PUBLIKOVANE())) badge-success @else badge-warning @endif">{{ \Illuminate\Support\Str::upper($odpoved->stav->label) }}</span>
                                            </td>
                                            <td>
                                                <div class="dropdown">
                                                    <button class="btn btn-sm btn-outline-primary dropdown-toggle dropdown-toggle-no-arrow" type="button" id="dropdownMenuButton-1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                                        <i class="icon-dots-three-horizontal"></i>
                                                    </button>
                                                    <div class="dropdown-menu dropdown-menu-sm">
                                                        <a class="dropdown-item" href="{{ route('vzdelavanie.sprava.testovanie.testy.otazky.odpovede.edit', [$test, $otazka, $odpoved]) }}">
                                                            <i class="fa fa-edit"></i>
                                                            &nbsp;Upraviť
                                                        </a>
                                                        <div class="dropdown-divider"></div>
                                                        <a class="dropdown-item" href="#" onclick="event.preventDefault();(confirm('Chystáte sa odstrániť odpoveď, prajete si pokračovať?')) ? document.getElementById('delete-odpoved-{{ $odpoved->hashId() }}-form').submit() : null;">
                                                            <i class="fa fa-trash"></i>
                                                            &nbsp;Odstrániť
                                                        </a>

                                                        <form id="delete-odpoved-{{ $odpoved->hashId() }}-form" action="{{ route('vzdelavanie.sprava.testovanie.testy.otazky.odpovede.destroy', [$test, $otazka, $odpoved]) }}" method="POST" style="display: none;">
                                                            @csrf
                                                            @method('DELETE')
                                                        </form>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr class="table-divider">
                                            <th></th>
                                            <td></td>
                                        </tr>
                                    @endforeach
                                    </tbody>
                                </table>
                            </div>
                            @endif
                        </div>
                    </div>

                    @if($otazka->odpovede->count())
                    <div class="row">
                        <div class="col text-center">
                            <a href="{{ route('vzdelavanie.sprava.testovanie.testy.otazky.odpovede.create', [$test, $otazka]) }}" class="btn btn-primary">
                                <i class="fa fa-plus"></i>
                                &nbsp;Vytvoriť novú odpoveď
                            </a>
                        </div>
                    </div>
                    @endif
                </div>
            </div>
        </div>
    </section>
@endsection