diff --git a/app/controllers/admin/cfps_controller.rb b/app/controllers/admin/cfps_controller.rb index b7a6b36a..5751797b 100644 --- a/app/controllers/admin/cfps_controller.rb +++ b/app/controllers/admin/cfps_controller.rb @@ -11,7 +11,7 @@ module Admin def show; end def new - @cfp = @program.cfps.new + @cfp = @program.cfps.new(cfp_params_or_first_remaining_type) end def edit; end @@ -59,5 +59,11 @@ module Admin def cfp_params params.require(:cfp).permit(:start_date, :end_date, :description, :cfp_type) end + + def cfp_params_or_first_remaining_type + cfp_params + rescue ActionController::ParameterMissing + { 'cfp_type' => @program.remaining_cfp_types.first } + end end end diff --git a/app/helpers/admin/cfps_helper.rb b/app/helpers/admin/cfps_helper.rb index 99753d2f..7b62fc20 100644 --- a/app/helpers/admin/cfps_helper.rb +++ b/app/helpers/admin/cfps_helper.rb @@ -9,11 +9,5 @@ module Admin admin_conference_program_cfp_path(conference, cfp) end end - - def select_cfp_types(cfp, program) - cfp_types = program.remaining_cfp_types - cfp_types.unshift(cfp.cfp_type) unless cfp.new_record? - cfp_types.map { |cfp_type| ["#{cfp_type.capitalize}", cfp_type] } - end end end diff --git a/app/views/admin/cfps/_form.html.haml b/app/views/admin/cfps/_form.html.haml index f4e65cba..c7113ff1 100644 --- a/app/views/admin/cfps/_form.html.haml +++ b/app/views/admin/cfps/_form.html.haml @@ -1,11 +1,14 @@ .row .col-md-12 .page-header - %h1 Call for Papers + %h1 + Call for + = cfp.cfp_type.capitalize .row .col-md-8 = semantic_form_for(cfp, url: cfp_form_url(cfp, conference), html: { multipart: true }) do |f| + = f.input :cfp_type, as: :hidden = f.input :start_date, as: :string, input_html: { id: 'registration-period-start-datepicker', start_date: conference.start_date, @@ -13,9 +16,6 @@ = f.input :end_date, as: :string, input_html: { id: 'registration-period-end-datepicker', readonly: 'readonly' } - = f.input :cfp_type, as: :select, include_blank: false, - collection: select_cfp_types(cfp, conference.program), - label: 'Type', input_html: { class: 'select-help-toggle' } = f.input :description, hint: markdown_hint, input_html: { rows: 2, data: { provide: 'markdown-editable' } } %p.text-right diff --git a/app/views/admin/cfps/index.html.haml b/app/views/admin/cfps/index.html.haml index a1811b9e..b15d1614 100644 --- a/app/views/admin/cfps/index.html.haml +++ b/app/views/admin/cfps/index.html.haml @@ -43,6 +43,14 @@ - if can? :new, @program.cfps.new .row .col-md-12.text-right - = link_to 'Create Call for Papers', - new_admin_conference_program_cfp_path(@conference), - class: 'btn btn-primary' + .btn-group + %button.btn.btn-primary.dropdown-toggle{ type: 'button', + data: { toggle: 'dropdown' } } + Add Call for... + %span.caret + %ul.dropdown-menu + - @program.remaining_cfp_types.each do |cfp_type| + %li + = link_to cfp_type.capitalize, + new_admin_conference_program_cfp_path(@conference, + cfp: { cfp_type: cfp_type })