edit.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. @extends('layouts.app')
  2. @section('content')
  3. <div class="px-3">
  4. <div class="row mb-3">
  5. <div class="col-md-7 d-flex align-items-center">
  6. <h3 class="mb-0">
  7. {{ $item ? 'Позиция '.$item->article : 'Новая позиция общего каталога' }}
  8. </h3>
  9. </div>
  10. @if($item)
  11. <div class="col-md-5 d-flex flex-wrap align-items-center justify-content-end gap-2 action-toolbar">
  12. @if(hasPermission('common-catalog.image.upload'))
  13. <button type="button" class="btn btn-sm btn-outline-success"
  14. onclick="document.getElementById('common-catalog-image-input').click()">
  15. <i class="bi bi-image"></i> Загрузить фото
  16. </button>
  17. <form action="{{ route('common-catalog.image.upload', ['commonCatalogItem' => $item, 'nav' => $nav ?? null]) }}"
  18. method="POST" enctype="multipart/form-data" class="visually-hidden">
  19. @csrf
  20. <input id="common-catalog-image-input" type="file" name="image"
  21. accept=".jpg,.jpeg,.png,.webp" required onchange="this.form.submit()">
  22. </form>
  23. @endif
  24. <button type="button" class="btn btn-sm btn-outline-secondary" disabled
  25. title="Будет подключено после получения контракта API">
  26. <i class="bi bi-calculator"></i> Калькуляция
  27. </button>
  28. </div>
  29. @endif
  30. </div>
  31. @if($item?->imageFile)
  32. <div class="card mb-3">
  33. <div class="card-body d-flex align-items-start gap-3">
  34. <a href="{{ $item->imageFile->link }}" data-toggle="lightbox" data-gallery="common-catalog">
  35. <img src="{{ $item->imageFile->thumbnail_link }}" alt="{{ $item->article }}"
  36. class="img-thumbnail" style="max-width: 180px; max-height: 180px">
  37. </a>
  38. @if(hasPermission('common-catalog.image.delete'))
  39. <form action="{{ route('common-catalog.image.delete', ['commonCatalogItem' => $item, 'nav' => $nav ?? null]) }}"
  40. method="POST" onsubmit="return confirm('Удалить изображение?')">
  41. @csrf
  42. @method('DELETE')
  43. <button type="submit" class="btn btn-sm btn-outline-danger">Удалить фото</button>
  44. </form>
  45. @endif
  46. </div>
  47. </div>
  48. @endif
  49. <form action="{{ $item ? route('common-catalog.update', $item) : route('common-catalog.store') }}" method="POST">
  50. @csrf
  51. @if($item) @method('PUT') @endif
  52. <input type="hidden" name="nav" value="{{ $nav ?? '' }}">
  53. <div class="row">
  54. <div class="col-xl-6">
  55. @include('partials.input', ['name' => 'article', 'title' => 'Артикул', 'required' => true, 'value' => $item?->article])
  56. <div class="row mb-2">
  57. <label for="calculator_name" class="col-form-label small col-md-4 text-md-end">
  58. Наименование по калькулятору <sup>*</sup>
  59. </label>
  60. <div class="col-md-8">
  61. <textarea name="calculator_name" id="calculator_name" rows="4" required
  62. class="form-control form-control-sm @error('calculator_name') is-invalid @enderror">{{ old('calculator_name', $item?->calculator_name) }}</textarea>
  63. @error('calculator_name')
  64. <div class="invalid-feedback"><strong>{{ $message }}</strong></div>
  65. @enderror
  66. </div>
  67. </div>
  68. @include('partials.input', ['name' => 'kind', 'title' => 'Вид', 'value' => $item?->kind])
  69. @include('partials.input', ['name' => 'dimensions', 'title' => 'Габаритные размеры', 'value' => $item?->dimensions])
  70. @include('partials.input', ['name' => 'fall_height', 'title' => 'Высота падения', 'type' => 'number', 'min' => 0, 'step' => '0.001', 'value' => $item?->fall_height])
  71. @include('partials.input', ['name' => 'dimension_unit', 'title' => 'Единица измерения габаритов', 'value' => $item?->dimension_unit])
  72. @include('partials.input', ['name' => 'weight', 'title' => 'Вес, кг.', 'type' => 'number', 'min' => 0, 'step' => '0.001', 'value' => $item?->weight])
  73. @include('partials.input', ['name' => 'volume', 'title' => 'Объем, м3', 'type' => 'number', 'min' => 0, 'step' => '0.001', 'value' => $item?->volume])
  74. @include('partials.input', ['name' => 'places', 'title' => 'Места', 'type' => 'number', 'min' => 0, 'step' => 1, 'value' => $item?->places])
  75. @include('partials.input', ['name' => 'max_users', 'title' => 'Макс. кол-во пользователей', 'type' => 'number', 'min' => 0, 'step' => 1, 'value' => $item?->max_users])
  76. </div>
  77. <div class="col-xl-6">
  78. @include('partials.input', ['name' => 'age_group', 'title' => 'Возрастная группа', 'value' => $item?->age_group])
  79. @include('partials.input', ['name' => 'unit', 'title' => 'Ед.', 'value' => $item?->unit])
  80. @include('partials.input', ['name' => 'series', 'title' => 'Серия', 'value' => $item?->series])
  81. @include('partials.input', ['name' => 'trademark', 'title' => 'ТМ', 'value' => $item?->trademark])
  82. @foreach([
  83. 'additional_info' => 'Дополнительные сведения',
  84. 'composition' => 'Состав',
  85. 'note' => 'Примечание',
  86. ] as $field => $label)
  87. <div class="row mb-2">
  88. <label for="{{ $field }}" class="col-form-label small col-md-4 text-md-end">{{ $label }}</label>
  89. <div class="col-md-8">
  90. <textarea name="{{ $field }}" id="{{ $field }}" rows="4"
  91. class="form-control form-control-sm @error($field) is-invalid @enderror">{{ old($field, $item?->{$field}) }}</textarea>
  92. @error($field)
  93. <div class="invalid-feedback"><strong>{{ $message }}</strong></div>
  94. @enderror
  95. </div>
  96. </div>
  97. @endforeach
  98. </div>
  99. </div>
  100. <div class="d-flex flex-wrap gap-2 mt-3">
  101. @if(($item && hasPermission('common-catalog.update')) || (!$item && hasPermission('common-catalog.create')))
  102. <button type="submit" class="btn btn-sm btn-primary">Сохранить</button>
  103. @endif
  104. <a href="{{ $back_url ?? route('common-catalog.index') }}" class="btn btn-sm btn-outline-secondary">Назад</a>
  105. </div>
  106. </form>
  107. @if($item)
  108. <div class="card mt-4">
  109. <div class="card-header d-flex justify-content-between align-items-center">
  110. <strong>Документы</strong>
  111. @if(hasPermission('common-catalog.documents.upload'))
  112. <form action="{{ route('common-catalog.documents.upload', ['commonCatalogItem' => $item, 'nav' => $nav ?? null]) }}"
  113. method="POST" enctype="multipart/form-data" class="d-flex gap-2">
  114. @csrf
  115. <input type="file" name="document" class="form-control form-control-sm" required>
  116. <button type="submit" class="btn btn-sm btn-outline-primary">Загрузить</button>
  117. </form>
  118. @endif
  119. </div>
  120. <div class="card-body">
  121. @forelse($item->documents as $document)
  122. <div class="d-flex justify-content-between align-items-center border-bottom py-2">
  123. <a href="{{ $document->link }}" target="_blank" rel="noopener">{{ $document->original_name }}</a>
  124. @if(hasPermission('common-catalog.documents.delete'))
  125. <form action="{{ route('common-catalog.documents.delete', ['commonCatalogItem' => $item, 'file' => $document, 'nav' => $nav ?? null]) }}"
  126. method="POST" onsubmit="return confirm('Удалить документ?')">
  127. @csrf
  128. @method('DELETE')
  129. <button type="submit" class="btn btn-sm btn-outline-danger">Удалить</button>
  130. </form>
  131. @endif
  132. </div>
  133. @empty
  134. <span class="text-muted">Документы не загружены.</span>
  135. @endforelse
  136. </div>
  137. </div>
  138. <div class="card mt-4">
  139. <div class="card-header"><strong>Техническое описание</strong></div>
  140. <div class="card-body text-muted">
  141. Блок подготовлен к подключению данных и выгрузок из готового Laravel-модуля технических описаний.
  142. </div>
  143. </div>
  144. @if(hasPermission('common-catalog.delete'))
  145. <form action="{{ route('common-catalog.destroy', $item) }}" method="POST" class="mt-4"
  146. onsubmit="return confirm('Удалить позицию общего каталога?')">
  147. @csrf
  148. @method('DELETE')
  149. <button type="submit" class="btn btn-sm btn-danger">Удалить позицию</button>
  150. </form>
  151. @endif
  152. @endif
  153. </div>
  154. @endsection