diff --git a/app/controllers/admin/plans_controller.rb b/app/controllers/admin/plans_controller.rb index 43cb977e..c39e9d5e 100644 --- a/app/controllers/admin/plans_controller.rb +++ b/app/controllers/admin/plans_controller.rb @@ -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 @@ -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 @@ -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 diff --git a/app/views/admin/conferences/show.html.haml b/app/views/admin/conferences/show.html.haml index 004d52df..3368b01c 100644 --- a/app/views/admin/conferences/show.html.haml +++ b/app/views/admin/conferences/show.html.haml @@ -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 diff --git a/app/views/admin/plans/index.html.haml b/app/views/admin/plans/index.html.haml new file mode 100644 index 00000000..83b0a864 --- /dev/null +++ b/app/views/admin/plans/index.html.haml @@ -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) diff --git a/config/routes.rb b/config/routes.rb index 3f55387b..f93cfc9e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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)