|
1 | | -<p id="notice"><%= notice %></p> |
| 1 | +<div class="w-full"> |
| 2 | + <div class="flex items-start justify-between mb-6"> |
| 3 | + <div class="pr-6"> |
| 4 | + <h1 class="text-2xl font-semibold mb-2">Events</h1> |
| 5 | + Click 'Register' and then 'Register for Selected Events' to sign up for multiple events at once. |
| 6 | + </div> |
| 7 | + <%= link_to_button 'New Event', new_event_path, variant: :secondary_outline %> |
| 8 | + </div> |
| 9 | +</div> |
2 | 10 |
|
3 | | -<h1>Events</h1> |
| 11 | +<!-- Divider --> |
| 12 | +<div class="w-full mt-6"> |
| 13 | + <hr class="border-gray-300 mb-6"> |
| 14 | +</div> |
4 | 15 |
|
5 | 16 | <%= form_with url: bulk_create_event_registrations_path, method: :post, local: true, id: 'bulk-registration-form' do |form| %> |
6 | | - <table> |
7 | | - <thead> |
8 | | - <tr> |
9 | | - <th></th> |
10 | | - <th>Title</th> |
11 | | - <th>Start Date</th> |
12 | | - <th>End Date</th> |
13 | | - <th>Actions</th> |
14 | | - </tr> |
15 | | - </thead> |
16 | | - |
17 | | - <tbody> |
| 17 | + <% if @events.any? %> |
| 18 | + <% if @events.length > 10 %> |
| 19 | + <div class="flex justify-center mb-6"> |
| 20 | + <%= form.submit "Register for Selected Events", |
| 21 | + class: "inline-flex items-center gap-2 px-4 py-2 rounded-lg |
| 22 | + transition-colors duration-200 font-medium shadow-sm text-sm |
| 23 | + border border-blue-600 bg-blue-600 text-white |
| 24 | + enabled:hover:bg-white enabled:hover:text-blue-600 |
| 25 | + disabled:opacity-50 disabled:cursor-not-allowed", |
| 26 | + id: "register-button", |
| 27 | + disabled: true %> |
| 28 | + </div> |
| 29 | + <% end %> |
| 30 | + |
| 31 | + <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6"> |
18 | 32 | <% @events.each do |event| %> |
19 | | - <tr> |
20 | | - <td style="padding-right: 10px;"> |
21 | | - <%= check_box_tag "event_ids[]", event.id, false, class: "event-checkbox" %> |
22 | | - </td> |
23 | | - <td style="padding-right: 10px;"><%= event.title %></td> |
24 | | - <td style="padding-right: 10px;"><%= event.start_date.strftime("%B %d, %Y") if event.start_date %></td> |
25 | | - <td style="padding-right: 10px;"><%= event.end_date.strftime("%B %d, %Y") if event.end_date %></td> |
26 | | - <td style="padding-right: 10px;"> |
27 | | - <%= link_to 'Show', event %> | |
28 | | - <%= link_to 'Edit', edit_event_path(event) %> | |
29 | | - <%= link_to 'Destroy', event, method: :delete, data: { confirm: 'Are you sure?' } %> |
30 | | - </td> |
31 | | - </tr> |
| 33 | + <div class="relative bg-white border border-gray-200 rounded-xl shadow hover:shadow-md transition p-4 flex flex-col"> |
| 34 | + <!-- Event Title --> |
| 35 | + <h3 class="text-lg font-semibold text-gray-900 mb-2"> |
| 36 | + <%= link_to "#{ event.title}#{ " [HIDDEN]" if current_user.super_user? && !event.publicly_visible }", |
| 37 | + event_path(event), |
| 38 | + class: "text-gray-900 hover:underline font-medium block" %> |
| 39 | + |
| 40 | + </h3> |
| 41 | + <% if event.event_registrations.where(email: current_user.email).exists? %> |
| 42 | + <span class="absolute top-2 right-2 text-xs bg-green-100 text-green-700 px-2 py-0.5 rounded-full"> |
| 43 | + Registered |
| 44 | + </span> |
| 45 | + <% end %> |
| 46 | + |
| 47 | + <!-- Dates --> |
| 48 | + <p class="text-sm text-gray-600 mb-1"> |
| 49 | + <span class="font-medium">Start:</span> |
| 50 | + <%= event.start_date&.strftime("%B %d, %Y") %> |
| 51 | + </p> |
| 52 | + <p class="text-sm text-gray-600 mb-3"> |
| 53 | + <span class="font-medium">End:</span> |
| 54 | + <%= event.end_date&.strftime("%B %d, %Y") %> |
| 55 | + </p> |
| 56 | + |
| 57 | + <div class="mt-3 flex gap-2"> |
| 58 | + <!-- Admin Edit --> |
| 59 | + <% if current_user.super_user %> |
| 60 | + <%= link_to_button 'Edit', edit_event_path(event), variant: :secondary_outline %> |
| 61 | + <% end %> |
| 62 | + |
| 63 | + <% if event.event_registrations.where(email: current_user.email).exists? %> |
| 64 | + <% registration = event.event_registrations.where(email: current_user.email).last %> |
| 65 | + <div class="mt-2 ml-auto"> |
| 66 | + <%= link_to_button 'De-register', |
| 67 | + event_registration_path(registration), |
| 68 | + variant: :secondary_outline, |
| 69 | + method: :delete, |
| 70 | + data: { confirm: "Are you sure you want to de-register?" } %> |
| 71 | + </div> |
| 72 | + <% elsif event.registerable? %> |
| 73 | + <div class="mt-2 ml-auto"> |
| 74 | + <label class="flex items-center gap-2 cursor-pointer"> |
| 75 | + <%= check_box_tag "event_ids[]", |
| 76 | + event.id, |
| 77 | + false, |
| 78 | + id: "event_ids_#{event.id}", |
| 79 | + class: "event-checkbox h-5 w-5 text-blue-600 rounded border-gray-300 focus:ring-blue-500" %> |
| 80 | + <span class="text-gray-700">Register</span> |
| 81 | + </label> |
| 82 | + </div> |
| 83 | + <% else %> |
| 84 | + <div class="mt-2 ml-auto"> |
| 85 | + <span class="text-sm text-gray-500 italic">Registration closed</span> |
| 86 | + </div> |
| 87 | + <% end %> |
| 88 | + </div> |
| 89 | + </div> |
32 | 90 | <% end %> |
33 | | - </tbody> |
34 | | - </table> |
| 91 | + </div> |
35 | 92 |
|
36 | | - <br> |
37 | 93 |
|
38 | | - <div> |
39 | | - <%= form.submit "Register for Selected Events", class: "btn btn-primary", id: "register-button", disabled: true %> |
40 | | - <%= link_to 'New Event', new_event_path, class: "btn btn-primary" %> |
41 | | - </div> |
| 94 | + <div class="flex justify-start m-6"> |
| 95 | + <%= form.submit "Register for Selected Events", |
| 96 | + class: "inline-flex items-center gap-2 px-4 py-2 rounded-lg |
| 97 | + transition-colors duration-200 font-medium shadow-sm text-sm |
| 98 | + border border-blue-600 bg-blue-600 text-white |
| 99 | + enabled:hover:bg-white enabled:hover:text-blue-600 |
| 100 | + disabled:opacity-50 disabled:cursor-not-allowed", |
| 101 | + id: "register-button", |
| 102 | + disabled: true %> |
| 103 | + </div> |
| 104 | + <% else %> |
| 105 | + <!-- Empty State --> |
| 106 | + <div class="text-center py-12 text-gray-500"> |
| 107 | + No events available. |
| 108 | + </div> |
| 109 | + <% end %> |
42 | 110 | <% end %> |
43 | 111 |
|
44 | 112 | <script> |
45 | | - document.addEventListener('DOMContentLoaded', function() { |
46 | | - const checkboxes = document.querySelectorAll('.event-checkbox'); |
47 | | - const registerButton = document.getElementById('register-button'); |
48 | | - |
49 | | - function updateRegisterButton() { |
50 | | - const checkedBoxes = document.querySelectorAll('.event-checkbox:checked'); |
51 | | - registerButton.disabled = checkedBoxes.length === 0; |
52 | | - } |
53 | | - |
54 | | - checkboxes.forEach(checkbox => { |
55 | | - checkbox.addEventListener('change', updateRegisterButton); |
| 113 | + document.addEventListener('DOMContentLoaded', function() { |
| 114 | + const checkboxes = document.querySelectorAll('.event-checkbox'); |
| 115 | + const registerButton = document.getElementById('register-button'); |
| 116 | + |
| 117 | + function updateRegisterButton() { |
| 118 | + const checkedBoxes = document.querySelectorAll('.event-checkbox:checked'); |
| 119 | + registerButton.disabled = checkedBoxes.length === 0; |
| 120 | + } |
| 121 | + |
| 122 | + checkboxes.forEach(checkbox => { |
| 123 | + checkbox.addEventListener('change', updateRegisterButton); |
| 124 | + }); |
| 125 | + |
| 126 | + updateRegisterButton(); |
56 | 127 | }); |
57 | | - |
58 | | - updateRegisterButton(); |
59 | | - }); |
60 | 128 | </script> |
0 commit comments