{{-- Basic table view --}}

@extends('layouts.app')

@php
/** @var \App\Models\Table $table */

if (!isset($tab) || $tab == '') $tab = 'edit-rows';
@endphp

@section('content')
<div class="row justify-content-start px-3">
  <div class="d-flex w-100 align-items-center">
    <small class="flex-grow-1" style="font-size: 120%;">
      <a href="{{ route('profile.view', $table->owner->name) }}" class="link-no-color">{{ $table->owner->handle }}</a>{{--
      --}}<span class="px-1">/</span>{{--
      --}}<b><a href="{{ $table->viewRoute }}" class="link-no-color">{{ $table->name }}</a></b>
    </small>

    <h1 class="mx-3">
      <a href="{{ $table->viewRoute }}" class="link-no-color">{{ $table->title }}</a>
    </h1>
    <a href="{{$table->draftDiscardRoute}}" class="btn btn-outline-danger mr-2 py-1 btn-sm">
      @icon(fa-trash-o fa-pr, sr:Discard){{--
      --}}Clear Changes
    </a>
    <a href="{{ $table->viewRoute }}" class="btn btn-outline-primary py-1 btn-sm" @tooltip(Back to Table)>
      @icon(fa-reply, sr:Back to Table)
    </a>
  </div>
</div>

<ul class="nav nav-tabs">
  <li class="nav-item">
    <a class="nav-link {{ $tab=='edit-rows' ? 'active' : '' }}" href="{{ $table->getDraftRoute('edit-rows') }}">
      Edit Rows
    </a>
  </li>
  <li class="nav-item">
    <a class="nav-link {{ $tab=='add-rows' ? 'active' : '' }}" href="{{ $table->getDraftRoute('add-rows') }}">
      Add Rows
    </a>
  </li>
  <li class="nav-item">
    <a class="nav-link {{ $tab=='manage-columns' ? 'active' : '' }}" href="{{ $table->getDraftRoute('manage-columns') }}">
      Change Columns
    </a>
  </li>
  <li class="nav-item">
    <a class="text-success nav-link {{ $tab=='review' ? 'active' : '' }}" href="{{ $table->getDraftRoute('review') }}">
      @icon(fa-save fa-pr)Review & Confirm
    </a>
  </li>
  <li class="nav-item pt-2 pr-2 opacity-fade ml-auto" style="opacity:0" id="draft-busy">
    @icon(fa-spinner fa-spin, Working...)
  </li>
</ul>

<div class="row justify-content-center mb-2">
  @yield('tab-content')
</div>{{-- End of row --}}

@endsection