Skip to content

Commit ca549b7

Browse files
authored
Merge pull request #104 from ruby-no-kai/copilot/create-admin-plans-index
2 parents 391b770 + 521953d commit ca549b7

File tree

4 files changed

+60
-4
lines changed

4 files changed

+60
-4
lines changed

app/controllers/admin/plans_controller.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ class Admin::PlansController < Admin::ApplicationController
22
before_action :set_conference
33
before_action :set_plan, only: [:edit, :update]
44

5+
def index
6+
@plans = @conference.plans.order(:rank)
7+
end
8+
59
def new
610
@plan = Plan.new(conference: @conference)
711
end
@@ -15,7 +19,7 @@ def create
1519

1620
respond_to do |format|
1721
if @plan.save
18-
format.html { redirect_to edit_conference_plan_path(@conference, @plan), notice: 'Plan was successfully created.' }
22+
format.html { redirect_to conference_plans_path(@conference), notice: 'Plan was successfully created.' }
1923
else
2024
format.html { render :new }
2125
end
@@ -25,9 +29,9 @@ def create
2529
def update
2630
respond_to do |format|
2731
if @plan.update(plan_params)
28-
format.html { redirect_to edit_conference_plan_path(@conference, @plan), notice: 'Plan was successfully updated.' }
32+
format.html { redirect_to conference_plans_path(@conference), notice: 'Plan was successfully updated.' }
2933
else
30-
format.html { render :new }
34+
format.html { render :edit }
3135
end
3236
end
3337
end

app/views/admin/conferences/show.html.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
%li
5050
= link_to plan.name, edit_conference_plan_path(@conference, plan)
5151
%span (#{count}/#{capacity})
52+
= link_to 'View all plans', conference_plans_path(@conference), class: 'card-link'
5253
= link_to 'Add plan', new_conference_plan_path(@conference), class: 'card-link'
5354

5455
.col-md-4
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
%nav{aria: {label: 'breadcrumb'}}
2+
%ol.breadcrumb
3+
%li.breadcrumb-item= link_to @conference.name, conference_path(@conference)
4+
%li.breadcrumb-item.active{aria: {current: 'page'}} Plans
5+
6+
.d-md-flex.justify-content-between
7+
%h3 Plans
8+
%div
9+
= link_to "New Plan", new_conference_plan_path(@conference), class: 'btn btn-primary'
10+
11+
- if @plans.any?
12+
.table-responsive
13+
%table.table.table-bordered.table-striped
14+
%thead
15+
%tr
16+
%th Rank
17+
%th Name
18+
%th Summary
19+
%th Price
20+
%th Capacity
21+
%th Guests
22+
%th Booth Size
23+
%th Words Limit
24+
%th Closes At
25+
%th Auto Accept
26+
%th Actions
27+
%tbody
28+
- @plans.each do |plan|
29+
%tr
30+
%td= plan.rank
31+
%td= plan.name
32+
%td= plan.summary
33+
%td= plan.price_text
34+
%td= plan.capacity
35+
%td= plan.number_of_guests
36+
%td= plan.booth_size
37+
%td= plan.words_limit
38+
%td
39+
- if plan.closes_at
40+
= plan.closes_at.strftime('%Y-%m-%d %H:%M')
41+
%td
42+
- if plan.auto_acceptance
43+
%span.badge.badge-success Yes
44+
- else
45+
%span.badge.badge-secondary No
46+
%td
47+
= link_to 'Edit', edit_conference_plan_path(@conference, plan), class: 'btn btn-sm btn-secondary'
48+
- else
49+
.alert.alert-info
50+
No plans have been created yet.
51+
= link_to "Create the first plan", new_conference_plan_path(@conference)

config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
resource :booth_assignment, only: %i(show update)
2020

2121
resources :form_descriptions, except: %i(index)
22-
resources :plans, except: %i(index show)
22+
resources :plans, except: %i(show)
2323

2424
resources :sponsorships, except: %i(index new create) do
2525
resources :sponsorship_editing_histories, as: :editing_histories, path: 'editing_history', only: %i(index)

0 commit comments

Comments
 (0)