index.blade.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. @extends('layouts.admin')
  2. @section('title')
  3. Calendari
  4. @stop
  5. @section('content')
  6. <p>Trascina le righe per ordinare gli elementi</p>
  7. <div class="row">
  8. <div class="col-xs-12">
  9. <div class="box">
  10. <div class="box-body table-responsive no-padding">
  11. <table class="table table-striped table-hover">
  12. <tr>
  13. <th>Tipologia</th>
  14. <th>Categoria</th>
  15. <th>Girone</th>
  16. <th>Stagione</th>
  17. <th width="50"></th>
  18. <th width="50"></th>
  19. <th width="50"></th>
  20. </tr>
  21. <tbody>
  22. @foreach($calendars as $calendar)
  23. <tr class="calendar_row" data-id="{{$calendar->id}}" style="cursor:move">
  24. <td>{{$calendar->type == 'nation' ? 'Nazionale' : 'Regionale'}}</td>
  25. <td>{{isset($calendar->category) ? $calendar->category->name : ''}}</td>
  26. <td>{{isset($calendar->group) ? $calendar->group->name : ''}}</td>
  27. <td>{{isset($calendar->season) ? $calendar->season->name : ''}}</td>
  28. <td>
  29. <a href="{{ route('calendars.games', array($calendar->id)) }}" type="button" class="btn btn-w-m btn-primary">Risultati</a>
  30. </td>
  31. <td>
  32. <a href="{{ route('calendars.edit', array($calendar->id)) }}" type="button" class="btn btn-w-m btn-primary">Importa calendario</a>
  33. </td>
  34. <td>
  35. @if($calendar->archived)
  36. <a href="{{ route('calendars.restore', array($calendar->id)) }}" type="button" class="btn btn-w-m btn-success">Ripristina</a>
  37. @else
  38. <a href="{{ route('calendars.archive', array($calendar->id)) }}" type="button" class="btn btn-w-m btn-warning">Archivia</a>
  39. @endif
  40. </td>
  41. <td>
  42. <form class="form-inline" method="POST" action="{{ route('calendars.destroy', $calendar->id) }}">
  43. @csrf
  44. @method('DELETE')
  45. <button type="submit" class="btn btn-w-m btn-danger" onclick="return confirm('Sei sicuro?')">Elimina</button>
  46. </form>
  47. </td>
  48. </tr>
  49. @endforeach
  50. </tbody>
  51. </table>
  52. </div>
  53. </div>
  54. </div>
  55. <div class="col-xs-2">
  56. <a href="{{ route('calendars.create') }}" class="btn btn-success">Aggiungi</a>
  57. </div>
  58. </div>
  59. @stop
  60. @section('extra_js')
  61. <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
  62. <script>
  63. $(function () {
  64. $('tbody').sortable({
  65. cursor: "move",
  66. stop: function( ) {
  67. var ids = '';
  68. $(".calendar_row").each(function()
  69. {
  70. var id = $(this).attr("data-id");
  71. ids += (ids != '' ? ',' : '') + id;
  72. });
  73. $.ajax('/admin/calendars/sort/' + ids,
  74. {
  75. success: function (data, status, xhr) {// success callback function
  76. $('p').append(data);
  77. }
  78. });
  79. }
  80. });
  81. });
  82. </script>
  83. @stop