|
4 | 4 | <%= link_to edit_aeon_appointment_path(appointment.id), data: { action: 'modal#open' } do %> |
5 | 5 | <i class="bi bi-pencil-fill me-1"></i>Edit appointment |
6 | 6 | <% end %> |
7 | | - <%= link_to aeon_appointment_path(appointment.id), data: { turbo_method: :delete }, aria: { label: 'Delete'} do %> |
8 | | - <i class="bi bi-trash"></i> |
9 | | - <% end %> |
| 7 | + <% if helpers.can? :destroy, appointment %> |
| 8 | + <button class="btn btn-link su-underline p-0" data-bs-toggle="modal" data-bs-target="#delete-appointment-<%= @appointment.id %>"> |
| 9 | + <i class="bi bi-trash align-middle"></i><span class="visually-hidden">Delete appointment</span> |
| 10 | + </button> |
| 11 | + <% end %> |
10 | 12 | </div> |
11 | 13 | <div class="card-body"> |
12 | 14 | <% if appointment.requests.present? %> |
|
40 | 42 | </div> |
41 | 43 | <% end %> |
42 | 44 | </div> |
| 45 | + <!-- Delete modal --> |
| 46 | + <div class="modal fade" id="delete-appointment-<%= appointment.id %>" tabindex="-1" aria-labelledby="title-appointment-<%= appointment.id %>" aria-hidden="true"> |
| 47 | + <div class="modal-dialog modal-dialog-centered"> |
| 48 | + <div class="modal-content"> |
| 49 | + <div class="modal-header"> |
| 50 | + <h2 class="modal-title" id="title-appointment-<%= appointment.id %>">Delete appointment?</h2> |
| 51 | + <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> |
| 52 | + </div> |
| 53 | + <div class="modal-body fw-normal"> |
| 54 | + <div class="mb-2"><%= appointment.reading_room.name %></div> |
| 55 | + <div class="my-2"><i class="bi bi-calendar me-2"></i><%= appointment_date %><i class="bi bi-clock mx-2"></i><%= appointment_time_range %></div> |
| 56 | + <% if appointment.requests.any? %> |
| 57 | + <p class="mb-0"> |
| 58 | + <%= pluralize(appointment.requests.length, 'requested item') %> are assigned to this appointment. If you cancel or delete the appointment, the items will not be deleted. |
| 59 | + Instead, they will be moved to <strong>Draft requests</strong>. |
| 60 | + </p> |
| 61 | + <% end %> |
| 62 | + </div> |
| 63 | + <div class="modal-footer"> |
| 64 | + <button type="button" class="btn btn-outline-primary" data-bs-dismiss="modal">No</button> |
| 65 | + <%= form_with url: aeon_appointment_path(appointment.id), method: 'delete' do %> |
| 66 | + <button type="submit" class="btn btn-primary" data-bs-dismiss="modal">Yes - Delete</button> |
| 67 | + <% end %> |
| 68 | + </div> |
| 69 | + </div> |
| 70 | + </div> |
| 71 | + </div> |
43 | 72 | </div> |
0 commit comments