allegati-modal.blade.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <div wire:ignore.self class="modal fade" id="allegatiModal" tabindex="-1" aria-labelledby="allegatiModalLabel" aria-hidden="true" data-keyboard="false" data-backdrop="static">
  2. <div class="modal-dialog modal-xl">
  3. <div class="modal-content">
  4. <div class="modal-header">
  5. <h5 class="modal-title" id="allegatiModalLabel">
  6. @if($allegatoId > 0)
  7. Modifica allegato
  8. @else
  9. Nuovo allegato
  10. @endif
  11. </h5>
  12. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  13. <span aria-hidden="true">&times;</span>
  14. </button>
  15. </div>
  16. <div class="modal-body">
  17. <div class="row mt-3">
  18. <div class="col-md-4">
  19. <label for="allegatoName" class="form-label">Nome</label>
  20. </div>
  21. <div class="col-md-8">
  22. <input class="form-control @error('allegatoName') is-invalid @enderror" type="text" id="allegatoName" placeholder="Nome" wire:model="allegatoName">
  23. @error('allegatoName')
  24. <div class="invalid-feedback">{{ $message }}</div>
  25. @enderror
  26. </div>
  27. </div>
  28. <div class="row mt-3">
  29. <div class="col-md-4">
  30. <label for="allegatoGallery" class="form-label">Tipologia</label>
  31. </div>
  32. <div class="col-md-8">
  33. <select class="form-control @error('allegatoGallery') is-invalid @enderror" style="width:100%" wire:model="allegatoGallery" id="allegatoGallery">
  34. <option value="">Seleziona...</option>
  35. @foreach ($allegatiType as $t)
  36. <option value="{{ $t->id }}">{{ $t->name }}</option>
  37. @endforeach
  38. </select>
  39. @error('allegatoGallery')
  40. <div class="invalid-feedback">{{ $message }}</div>
  41. @enderror
  42. </div>
  43. </div>
  44. <div class="row mt-3">
  45. <div class="col-md-4">
  46. <label for="allegatoFotoSinistri" class="form-label">Foto sinistri</label>
  47. </div>
  48. <div class="col-md-8">
  49. <select class="form-control @error('allegatoFotoSinistri') is-invalid @enderror" style="width:100%" wire:model="allegatoFotoSinistri" id="allegatoFotoSinistri">
  50. <option value="">Seleziona...</option>
  51. <option value="1">Valore 1</option>
  52. <option value="2">Valore 2</option>
  53. </select>
  54. @error('allegatoFotoSinistri')
  55. <div class="invalid-feedback">{{ $message }}</div>
  56. @enderror
  57. </div>
  58. </div>
  59. <div class="row mt-3">
  60. <div class="col-md-4">
  61. <label for="allegatoDidascalia" class="form-label">Didascalia</label>
  62. </div>
  63. <div class="col-md-8">
  64. <input class="form-control" type="text" id="allegatoDidascalia" placeholder="Didascalia" wire:model="allegatoDidascalia">
  65. </div>
  66. </div>
  67. <div class="row mt-3">
  68. <div class="col-md-4">
  69. <label for="allegati" class="form-label">Files</label>
  70. </div>
  71. <div class="col-md-8">
  72. <div class="form-group">
  73. <input wire:model="allegati" type="file" class="form-control-file" id="allegati" multiple>
  74. <span id="fileSize" style="color:red"></span>
  75. </div>
  76. <div id="files-container" class="mt-2">
  77. @if(!empty($allegatiFiles) && count($allegatiFiles) > 0)
  78. <div class="card">
  79. <div class="card-header bg-light d-flex justify-content-between align-items-center">
  80. <strong>File caricati ({{ count($allegatiFiles) }})</strong>
  81. </div>
  82. <div class="card-body p-2">
  83. <ul class="list-group list-group-flush">
  84. @foreach ($allegatiFiles as $a)
  85. <li class="list-group-item d-flex justify-content-between align-items-center py-2">
  86. <span>{{ $a }}</span>
  87. <button class="btn btn-sm btn-outline-danger"
  88. wire:click.prevent="removeFile('{{ $a }}')">
  89. <i class="fa fa-times"></i>
  90. </button>
  91. </li>
  92. @endforeach
  93. </ul>
  94. </div>
  95. </div>
  96. @endif
  97. </div>
  98. </div>
  99. </div>
  100. <div class="row mt-3">
  101. <div class="col-md-4">
  102. <label for="allegatoVisible" class="form-label">Visibile in stampa</label>
  103. </div>
  104. <div class="col-md-8">
  105. <div class="custom-control custom-switch custom-switch-md">
  106. <input type="checkbox" class="custom-control-input" id="allegatoVisible" wire:model="allegatoVisible">
  107. <label class="custom-control-label" for="allegatoVisible">&nbsp;</label>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. <div class="modal-footer">
  113. <button type="button" class="btn btn-secondary" data-dismiss="modal">Annulla</button>
  114. @if (!$this->validated)
  115. <button type="button" class="btn btn-primary" wire:click.prevent="saveAllegato()" id="btSaveAllegato">Salva</button>
  116. @endif
  117. </div>
  118. </div>
  119. </div>
  120. </div>
  121. @push('scripts')
  122. <script>
  123. document.addEventListener('livewire:load', function () {
  124. window.livewire.on('open-allegati-modal', function () {
  125. $('#allegatiModal').modal('show');
  126. console.log('Modal opened');
  127. });
  128. window.livewire.on('close-modal', function () {
  129. $('#allegatiModal').modal('hide');
  130. });
  131. window.livewire.on('attachments', function (files) {
  132. console.log('Attachments updated:', files);
  133. setTimeout(function() {
  134. window.livewire.emit('refresh');
  135. }, 200);
  136. });
  137. window.livewire.on('fileSize', function (txt) {
  138. setTimeout(function() {
  139. if (txt == "")
  140. {
  141. $("#btSaveAllegato").show();
  142. }
  143. else
  144. {
  145. $("#btSaveAllegato").hide();
  146. $("#fileSize").html(txt);
  147. }
  148. }, 200);
  149. });
  150. });
  151. </script>
  152. @endpush