items.blade.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. @extends('admin.index')
  2. @section('styles')
  3. @parent
  4. <link href="{{ asset('css/animated_modal_4.css') }}" rel="stylesheet">
  5. <link href="{{ asset('css/admin_items.css') }}" rel="stylesheet">
  6. {{--<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css" rel='stylesheet'>--}}
  7. @endsection
  8. @section('content')
  9. <div class="container">
  10. <div class="admin-items panel-default panel-table">
  11. <h4 class="panel-title mb-2 pb-2">Список предметов</h4>
  12. </div>
  13. <div class="panel-body">
  14. @if ($items->total() > 0)
  15. <table class="table table-striped table-hover table-bordered table-list">
  16. <thead class="thead-dark">
  17. <tr>
  18. <th style="width:50px"><em class="fa fa-cog"></em></th>
  19. <th>id</th>
  20. <th>user</th>
  21. <th>Заголовок</th>
  22. <th>Описание</th>
  23. <th>Категория</th>
  24. <th>Подкатегория</th>
  25. <th>Создан</th>
  26. </tr>
  27. </thead>
  28. <tbody>
  29. @foreach ( $items as $item)
  30. <tr class="table-hover" onclick="optionShow(this)" value="{{ $item->id }}">
  31. <td align="center">
  32. <a class="btn btn-default"><em class="fa fa-pencil"></em></a>
  33. </td>
  34. @foreach($item as $key => $value)
  35. <td height="50" title="{{ $key }}">
  36. @if ($key ==='description')
  37. <div class="td-descr" style="height: 50px;overflow: hidden">{{ $value }}</div>
  38. @else
  39. {{ $value }}
  40. @endif
  41. </td>
  42. @endforeach
  43. </tr>
  44. @endforeach
  45. </tbody>
  46. </table>
  47. @endif
  48. </div>
  49. <div class="card-footer" style="height:60px;position:relative;">
  50. <div class="row">
  51. <div class="col-md-offset-1 col-md-10">{{ $items->links() }}</div>
  52. </div>
  53. </div>
  54. </div>
  55. {{------------------ MODAL WINDOW -----------------------}}
  56. <div id="myModal" class="modal animate" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
  57. aria-hidden="true" data-backdrop="true">
  58. <div class="modal-dialog a-zoomRight" role="document">
  59. <div class="modal-content">
  60. <div class="modal-header">
  61. <h5 class="modal-title" id="exampleModalLabel">Редактирование итемки</h5>
  62. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  63. <span aria-hidden="true">×</span>
  64. </button>
  65. </div>
  66. <div class="modal-body text-center p-lg">
  67. <p style="font-size: 1.2em">Содержимое отсутствует!</p>
  68. </div>
  69. <div class="modal-footer">
  70. <button type="button" class="btn btn-danger" data-action="DELETE" onclick="changeMethod(this)">Удалить</button>
  71. <button type="button" class="btn btn-primary" data-action="PUT" onclick="changeMethod(this)">Изменить</button>
  72. <button type="button" class="btn btn-secondary" data-dismiss="modal">Закрыть</button>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. @endsection
  78. @section('scripts')
  79. @parent
  80. <script>
  81. function optionShow($element) {
  82. var $id = $element.getAttribute('value')
  83. $.ajax({
  84. headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
  85. url: '{{ route("admin.items.ajax", ["id"=> '0'])}}' + $id,
  86. type: 'POST',
  87. data: ( '{ "item": ' + $id + ' }' ),
  88. contentType: 'json',
  89. processData: false,
  90. success: function (response) {
  91. $("#myModal .modal-body").html(response);
  92. let item = document.querySelector('#myModal input[name="id"]');
  93. let title = document.querySelector('#myModal .modal-title');
  94. title.innerHTML = "Редактирование итемки № <b>" + item.value + "</b>";
  95. }
  96. });
  97. $("#myModal").modal('show');
  98. $("#myModal").attr('style', 'margin-top: 5%; transition: all 600ms ease-in-out;');
  99. }
  100. function changeMethod(element) {
  101. let method = $(element).data('action');
  102. $('#item-form').find('[name="_method"]').val(method);
  103. $('#item-form').submit();
  104. }
  105. $(function () {
  106. $('#myModal').on('shown.bs.modal', function () {
  107. $(this).find('[role="document"]').$('#myModal').focus();
  108. })
  109. })
  110. </script>
  111. @endsection
  112. @section('footer')
  113. @endsection