Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions app/controllers/admin/plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ class Admin::PlansController < Admin::ApplicationController
before_action :set_conference
before_action :set_plan, only: [:edit, :update]

def index
@plans = @conference.plans.order(:rank)
end

def new
@plan = Plan.new(conference: @conference)
end
Expand All @@ -15,7 +19,7 @@ def create

respond_to do |format|
if @plan.save
format.html { redirect_to edit_conference_plan_path(@conference, @plan), notice: 'Plan was successfully created.' }
format.html { redirect_to conference_plans_path(@conference), notice: 'Plan was successfully created.' }
else
format.html { render :new }
end
Expand All @@ -25,9 +29,9 @@ def create
def update
respond_to do |format|
if @plan.update(plan_params)
format.html { redirect_to edit_conference_plan_path(@conference, @plan), notice: 'Plan was successfully updated.' }
format.html { redirect_to conference_plans_path(@conference), notice: 'Plan was successfully updated.' }
else
format.html { render :new }
format.html { render :edit }
end
end
end
Expand Down
1 change: 1 addition & 0 deletions app/views/admin/conferences/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
%li
= link_to plan.name, edit_conference_plan_path(@conference, plan)
%span (#{count}/#{capacity})
= link_to 'View all plans', conference_plans_path(@conference), class: 'card-link'
= link_to 'Add plan', new_conference_plan_path(@conference), class: 'card-link'

.col-md-4
Expand Down
51 changes: 51 additions & 0 deletions app/views/admin/plans/index.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
%nav{aria: {label: 'breadcrumb'}}
%ol.breadcrumb
%li.breadcrumb-item= link_to @conference.name, conference_path(@conference)
%li.breadcrumb-item.active{aria: {current: 'page'}} Plans

.d-md-flex.justify-content-between
%h3 Plans
%div
= link_to "New Plan", new_conference_plan_path(@conference), class: 'btn btn-primary'

- if @plans.any?
.table-responsive
%table.table.table-bordered.table-striped
%thead
%tr
%th Rank
%th Name
%th Summary
%th Price
%th Capacity
%th Guests
%th Booth Size
%th Words Limit
%th Closes At
%th Auto Accept
%th Actions
%tbody
- @plans.each do |plan|
%tr
%td= plan.rank
%td= plan.name
%td= plan.summary
%td= plan.price_text
%td= plan.capacity
%td= plan.number_of_guests
%td= plan.booth_size
%td= plan.words_limit
%td
- if plan.closes_at
= plan.closes_at.strftime('%Y-%m-%d %H:%M')
%td
- if plan.auto_acceptance
%span.badge.badge-success Yes
- else
%span.badge.badge-secondary No
%td
= link_to 'Edit', edit_conference_plan_path(@conference, plan), class: 'btn btn-sm btn-secondary'
- else
.alert.alert-info
No plans have been created yet.
= link_to "Create the first plan", new_conference_plan_path(@conference)
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
resource :booth_assignment, only: %i(show update)

resources :form_descriptions, except: %i(index)
resources :plans, except: %i(index show)
resources :plans, except: %i(show)

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