Skip to content

Commit 8a71b6d

Browse files
authored
Admin volunteer slots: add Add slot button (#41)
Adds a primary CTA on /admin/volunteer_slots that opens the schedule item form with kind pre-selected to volunteer and Cancel returning to this page. Reuses the existing form (which already conditionally shows volunteer-only fields), and mirrors the established Edit-button pattern on this index. The schedule_items#new action now honors a ?kind= URL param, with an enum whitelist guard falling back to :talk for unknown values.
1 parent 031d78e commit 8a71b6d

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

app/controllers/admin/schedule_items_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ def index
2424
end
2525

2626
def new
27-
@schedule_item = ScheduleItem.new(day: "fri", kind: :talk, is_public: true, flexible: false)
27+
requested_kind = ScheduleItem.kinds.key?(params[:kind].to_s) ? params[:kind] : :talk
28+
@schedule_item = ScheduleItem.new(day: "fri", kind: requested_kind, is_public: true, flexible: false)
2829
end
2930

3031
def create

app/views/admin/volunteer_slots/index.html.erb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<% content_for :container_width, "max-w-6xl" %>
22

3-
<h1 class="text-2xl font-bold text-navy mb-6">Volunteers</h1>
3+
<div class="flex items-center justify-between mb-6 gap-3 flex-wrap">
4+
<h1 class="text-2xl font-bold text-navy">Volunteers</h1>
5+
<%= link_to "Add slot", new_admin_schedule_item_path(kind: "volunteer", return_to: admin_volunteer_slots_path), class: "btn btn-red" %>
6+
</div>
47

58
<%= render "admin/volunteers/tabs" %>
69

710
<% if @slots.empty? %>
811
<p class="text-gray">
9-
No volunteer slots yet. Create one from
10-
<%= link_to "Schedule", admin_schedule_items_path, class: "text-blue underline" %>
11-
(set Kind to Volunteer).
12+
No volunteer slots yet. Click <strong>Add slot</strong> above to create the first one.
1213
</p>
1314
<% else %>
1415
<div class="table-scroll">

0 commit comments

Comments
 (0)