values.blade.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. {{--
  2. Вьюха: Список значений раздела справочника
  3. Контроллер: Admin\ManualController::values()
  4. Переменные: $section (DictSection), $items (коллекция DictValue)
  5. Иерархический режим → admin/manuals/partials/_hierarchical_list (алфавит + аккордеон)
  6. Плоский режим → таблица inline
  7. --}}
  8. @extends('admin.layout')
  9. @section('title', $section->label)
  10. @section('content_header')
  11. <div class="d-flex justify-content-between align-items-center">
  12. <h1 class="m-0">{{ $section->label }}</h1>
  13. <div>
  14. <a href="{{ route('admin.manuals.value.create', $section) }}" class="btn btn-primary btn-sm">
  15. <i class="fas fa-plus"></i> Добавить
  16. </a>
  17. <a href="{{ route('admin.manuals.index') }}" class="btn btn-default btn-sm ml-1">
  18. <i class="fas fa-arrow-left"></i> Назад
  19. </a>
  20. </div>
  21. </div>
  22. @stop
  23. @section('breadcrumb')
  24. <li class="breadcrumb-item"><a href="{{ route('admin.dashboard') }}">Главная</a></li>
  25. <li class="breadcrumb-item"><a href="{{ route('admin.manuals.index') }}">Справочники</a></li>
  26. <li class="breadcrumb-item active">{{ $section->label }}</li>
  27. @stop
  28. @section('content')
  29. @if(session('success'))
  30. <div class="alert alert-success alert-dismissible">
  31. <button type="button" class="close" data-dismiss="alert">&times;</button>
  32. {{ session('success') }}
  33. </div>
  34. @endif
  35. @if($section->is_hierarchical)
  36. @include('admin.manuals.partials._hierarchical_list')
  37. @else
  38. <div class="card">
  39. <div class="card-body p-0">
  40. <table class="table table-hover mb-0">
  41. <thead>
  42. <tr>
  43. <th>#</th><th>Значение</th><th>Порядок</th><th style="width:100px">Действия</th>
  44. </tr>
  45. </thead>
  46. <tbody>
  47. @forelse($items as $item)
  48. <tr>
  49. <td class="text-muted">{{ $item->id }}</td>
  50. <td>{{ $item->value }}</td>
  51. <td>{{ $item->sort_order }}</td>
  52. <td>
  53. <a href="{{ route('admin.manuals.value.edit', [$section, $item]) }}"
  54. class="btn btn-xs btn-info"><i class="fas fa-edit"></i></a>
  55. <form action="{{ route('admin.manuals.value.destroy', [$section, $item]) }}"
  56. method="POST" class="d-inline" onsubmit="return confirm('Удалить?')">
  57. @csrf @method('DELETE')
  58. <button class="btn btn-xs btn-danger"><i class="fas fa-trash"></i></button>
  59. </form>
  60. </td>
  61. </tr>
  62. @empty
  63. <tr>
  64. <td colspan="4" class="text-center text-muted py-4">
  65. Значений нет.
  66. <a href="{{ route('admin.manuals.value.create', $section) }}">Добавить первое</a>
  67. </td>
  68. </tr>
  69. @endforelse
  70. </tbody>
  71. </table>
  72. </div>
  73. </div>
  74. @endif
  75. @stop
  76. @if($section->is_hierarchical)
  77. @push('css')
  78. <style>
  79. .alpha-nav-wrap {
  80. background: #fff;
  81. border: 1px solid #dee2e6;
  82. border-radius: 10px;
  83. padding: 14px 16px;
  84. box-shadow: 0 1px 4px rgba(0,0,0,.06);
  85. }
  86. .alpha-nav { display: flex; flex-wrap: wrap; gap: 6px; }
  87. .alpha-btn {
  88. display: inline-flex;
  89. align-items: center;
  90. justify-content: center;
  91. min-width: 38px;
  92. height: 38px;
  93. padding: 0 10px;
  94. border: 2px solid #dee2e6;
  95. border-radius: 8px;
  96. background: #fff;
  97. color: #495057;
  98. font-size: 14px;
  99. font-weight: 700;
  100. cursor: pointer;
  101. transition: all .15s ease;
  102. }
  103. .alpha-btn:hover { border-color: #007bff; color: #007bff; background: #f0f6ff; }
  104. .alpha-btn.active {
  105. background: linear-gradient(135deg, #007bff, #0056b3);
  106. border-color: #0056b3;
  107. color: #fff;
  108. box-shadow: 0 2px 8px rgba(0,123,255,.4);
  109. transform: translateY(-1px);
  110. }
  111. .alpha-btn[data-letter=""] { padding: 0 14px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
  112. .alpha-badge {
  113. display: inline-flex;
  114. align-items: center;
  115. justify-content: center;
  116. width: 28px;
  117. height: 28px;
  118. border-radius: 6px;
  119. background: linear-gradient(135deg, #007bff, #0056b3);
  120. color: #fff;
  121. font-size: 13px;
  122. font-weight: 700;
  123. flex-shrink: 0;
  124. }
  125. .make-card .card-header:hover { background: #f8f9fa; }
  126. </style>
  127. @endpush
  128. @push('js')
  129. <script>
  130. (function () {
  131. var $cards = $('.make-card');
  132. var $btns = $('.alpha-btn');
  133. var $counter = $('#visible-count');
  134. var $noRes = $('#no-results');
  135. // Аккордеон: при разворачивании одной марки схлопываем остальные видимые
  136. $(document).on('expanded.lte.cardwidget', '.make-card', function () {
  137. var $opened = $(this);
  138. $cards.filter(':visible').each(function () {
  139. if (!$(this).is($opened) && !$(this).hasClass('collapsed-card')) {
  140. $(this).find('[data-card-widget="collapse"]').trigger('click');
  141. }
  142. });
  143. });
  144. // Алфавитный фильтр
  145. $btns.on('click', function () {
  146. var letter = $(this).data('letter');
  147. $btns.removeClass('active');
  148. $(this).addClass('active');
  149. // Схлопываем все открытые (без анимации)
  150. $cards.each(function () {
  151. if (!$(this).hasClass('collapsed-card')) {
  152. $(this).addClass('collapsed-card');
  153. $(this).find('.btn-tool i').removeClass('fa-minus').addClass('fa-plus');
  154. $(this).find('.card-body').hide();
  155. }
  156. });
  157. // Фильтруем по букве
  158. var visible = 0;
  159. $cards.each(function () {
  160. var show = !letter || $(this).data('letter') === letter;
  161. $(this).toggle(show);
  162. if (show) visible++;
  163. });
  164. $counter.text(visible);
  165. $noRes.toggle(visible === 0);
  166. });
  167. })();
  168. </script>
  169. @endpush
  170. @endif