Просмотр исходного кода

Fix Calendar - Aggiunto tasto ripristina lezione

ferrari 4 месяцев назад
Родитель
Сommit
5f20d37294
2 измененных файлов с 22 добавлено и 4 удалено
  1. 9 0
      app/Http/Livewire/Calendar.php
  2. 13 4
      resources/views/livewire/calendar.blade.php

+ 9 - 0
app/Http/Livewire/Calendar.php

@@ -152,4 +152,13 @@ class Calendar extends Component
         return redirect()->to('/calendar');
     }
 
+    public function revertCalendarDeletion($id)
+    {
+        $calendar = \App\Models\Calendar::findOrFail($id);
+        $calendar->motivation_id = null;
+        $calendar->status = 0;
+        $calendar->save();
+        return redirect()->to('/calendar');
+    }
+
 }

+ 13 - 4
resources/views/livewire/calendar.blade.php

@@ -73,9 +73,11 @@
                     </div>                
                 </div>
                 <div class="modal-footer mt-2 justify-content-between">
-                    <button class="btn--ui lightGrey hideDelete hideDeleteButton" onclick="showDelete()">Annulla Lezione</a>
-                    <button type="button" class="btn--ui btn-primary hideDelete" onclick="goPresence()">Presenze</button>
+                    <button class="btn--ui lightGrey hideDelete hideDeleteButton activeCalendarButton" onclick="showDelete()">Annulla Lezione</a>
+                    <button type="button" class="btn--ui btn-primary hideDelete activeCalendarButton" onclick="goPresence()">Presenze</button>
                     <button type="button" class="btn--ui primary showDelete" onclick="deleteCalendar()" style="display:none">Annulla lezione</button>
+
+                    <button type="button" class="btn--ui primary revertDelete" onclick="revertCalendarDeletion()" style="display:none">Ripristina lezione</button>
                 </div>
             </div>
         </div>
@@ -276,11 +278,13 @@
                     $(".title").html(title);
                     if (title.includes("annullata"))
                     {
-                        $(".hideDeleteButton").css("display", "none");
+                        $(".activeCalendarButton").css("display", "none");
+                        $(".revertDelete").css("display", "block");
                     }
                     else
                     {
-                        $(".hideDeleteButton").css("display", "block");
+                        $(".activeCalendarButton").css("display", "block");
+                        $(".revertDelete").css("display", "none");
                     }
                     $(".time").html(pad(eventDate.getHours(), 2) + ":" + pad(eventDate.getMinutes(), 2));
                     $(".date").html(eventDate.toLocaleDateString('it-IT', { weekday: 'long' }) + " " + pad(eventDate.getDate(), 2) + " " + eventDate.toLocaleDateString('it-IT', { month: 'long' }));
@@ -318,6 +322,11 @@
             @this.cancelCalendar(currentCalendar, motivation);            
         }
 
+        function revertCalendarDeletion()
+        {
+            @this.revertCalendarDeletion(currentCalendar);            
+        }
+
         function reloadCalendar()
         {
             document.location.href = '/calendar?name_filter=' + $("#name_filter").val();