add form for bulk action
organizer can select a booth and perform action on all booth
This commit is contained in:
parent
8b2f2b538e
commit
fed2d8e089
5 changed files with 77 additions and 50 deletions
|
|
@ -115,6 +115,10 @@ module Admin
|
||||||
update_state(:confirm, "#{(t 'booth').capitalize} successfully confirmed")
|
update_state(:confirm, "#{(t 'booth').capitalize} successfully confirmed")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def booths_state
|
||||||
|
redirect_to admin_conference_booths_path
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def update_state(transition, notice)
|
def update_state(transition, notice)
|
||||||
|
|
@ -132,7 +136,7 @@ module Admin
|
||||||
def booth_params
|
def booth_params
|
||||||
params.require(:booth).permit(:title, :description, :reasoning, :state, :picture, :conference_id,
|
params.require(:booth).permit(:title, :description, :reasoning, :state, :picture, :conference_id,
|
||||||
:created_at, :updated_at, :submitter_relationship, :website_url, :invite_responsible,
|
:created_at, :updated_at, :submitter_relationship, :website_url, :invite_responsible,
|
||||||
responsible_ids: [])
|
:current_booth_state, :new_booth_state, responsible_ids: [])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ class Booth < ApplicationRecord
|
||||||
include ActiveRecord::Transitions
|
include ActiveRecord::Transitions
|
||||||
has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id }
|
has_paper_trail ignore: [:updated_at], meta: { conference_id: :conference_id }
|
||||||
|
|
||||||
attr_accessor :invite_responsible
|
attr_accessor :invite_responsible, :current_booth_state, :new_booth_state
|
||||||
|
|
||||||
belongs_to :conference
|
belongs_to :conference
|
||||||
has_many :booth_requests, dependent: :destroy
|
has_many :booth_requests, dependent: :destroy
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
- link = "Accept #{t'booth'}"
|
- link = "Accept #{t'booth'}"
|
||||||
%li= link_to link,
|
%li= link_to link,
|
||||||
accept_admin_conference_booth_path(@conference.short_title, booth),
|
accept_admin_conference_booth_path(@conference.short_title, booth),
|
||||||
method: :patch ,id: "accept_booth_#{booth.id}",
|
method: :patch ,id: "accept_booth_#{booth.id}", class: "common_booth_#{booth.id}",
|
||||||
data: (confirm_message ? { confirm: confirm_message } : nil)
|
data: (confirm_message ? { confirm: confirm_message } : nil)
|
||||||
|
|
||||||
- if booth.transition_possible? :reject
|
- if booth.transition_possible? :reject
|
||||||
|
|
@ -20,30 +20,30 @@
|
||||||
- link = 'Reject'
|
- link = 'Reject'
|
||||||
%li= link_to link,
|
%li= link_to link,
|
||||||
reject_admin_conference_booth_path(@conference.short_title, booth),
|
reject_admin_conference_booth_path(@conference.short_title, booth),
|
||||||
method: :patch, id: "reject_booth_#{booth.id}",
|
method: :patch, id: "reject_booth_#{booth.id}", class: "common_booth_#{booth.id}",
|
||||||
data: (@conference.email_settings.send_on_booths_rejection ? { confirm: 'By rejecting this booth, an email will be sent informing the submitter about the rejection. You may change the state to \'To reject\' until you are completely sure.'} : nil)
|
data: (@conference.email_settings.send_on_booths_rejection ? { confirm: 'By rejecting this booth, an email will be sent informing the submitter about the rejection. You may change the state to \'To reject\' until you are completely sure.'} : nil)
|
||||||
|
|
||||||
- if booth.transition_possible? :to_reject
|
- if booth.transition_possible? :to_reject
|
||||||
%li= link_to "To reject #{t'booth'}",
|
%li= link_to "To reject #{t'booth'}",
|
||||||
to_reject_admin_conference_booth_path(@conference.short_title, booth),
|
to_reject_admin_conference_booth_path(@conference.short_title, booth),
|
||||||
method: :patch, id: "to_reject_booth_#{booth.id}"
|
method: :patch, id: "to_reject_booth_#{booth.id}", class: "common_booth_#{booth.id}"
|
||||||
|
|
||||||
- if booth.transition_possible? :restart
|
- if booth.transition_possible? :restart
|
||||||
%li= link_to 'Start review',
|
%li= link_to 'Start review',
|
||||||
restart_admin_conference_booth_path(@conference.short_title, booth),
|
restart_admin_conference_booth_path(@conference.short_title, booth),
|
||||||
method: :patch, id: "restart_booth_#{booth.id}"
|
method: :patch, id: "restart_booth_#{booth.id}", class: "common_booth_#{booth.id}"
|
||||||
|
|
||||||
- if booth.transition_possible? :to_accept
|
- if booth.transition_possible? :to_accept
|
||||||
%li= link_to "To accept #{t'booth'}",
|
%li= link_to "To accept #{t'booth'}",
|
||||||
to_accept_admin_conference_booth_path(@conference.short_title, booth),
|
to_accept_admin_conference_booth_path(@conference.short_title, booth),
|
||||||
method: :patch, id: "to_accept_booth_#{booth.id}"
|
method: :patch, id: "to_accept_booth_#{booth.id}", class: "common_booth_#{booth.id}"
|
||||||
|
|
||||||
- if booth.transition_possible? :cancel
|
- if booth.transition_possible? :cancel
|
||||||
%li= link_to "Cancel #{t'booth'}",
|
%li= link_to "Cancel #{t'booth'}",
|
||||||
cancel_admin_conference_booth_path(@conference.short_title, booth),
|
cancel_admin_conference_booth_path(@conference.short_title, booth),
|
||||||
method: :patch, id: "cancel_booth_#{booth.id}"
|
method: :patch, id: "cancel_booth_#{booth.id}", class: "common_booth_#{booth.id}"
|
||||||
|
|
||||||
- if booth.transition_possible? :confirm
|
- if booth.transition_possible? :confirm
|
||||||
%li= link_to "Confirm #{t'booth'}",
|
%li= link_to "Confirm #{t'booth'}",
|
||||||
confirm_admin_conference_booth_path(@conference.short_title, booth),
|
confirm_admin_conference_booth_path(@conference.short_title, booth),
|
||||||
method: :patch, id: "confirm_booth_#{booth.id}"
|
method: :patch, id: "confirm_booth_#{booth.id}", class: "common_booth_#{booth.id}"
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,18 @@
|
||||||
= link_to "#{@conference.booth_limit} #{(t'booth').pluralize}", edit_admin_conference_path(@conference.short_title)
|
= link_to "#{@conference.booth_limit} #{(t'booth').pluralize}", edit_admin_conference_path(@conference.short_title)
|
||||||
)
|
)
|
||||||
- if @booths.any?
|
- if @booths.any?
|
||||||
|
%br
|
||||||
|
= form_for(:booth, url: admin_conference_booths_state_path) do |f|
|
||||||
|
.row
|
||||||
|
.col-md-offset-3.col-md-4
|
||||||
|
= f.select :new_booth_state,
|
||||||
|
[],
|
||||||
|
{ include_blank: "Change same state #{(t'booth').pluralize} to other state (select #{(t'booth')} first)" }, { class: 'form-control center', onchange: 'this.form.submit()'}
|
||||||
|
%br
|
||||||
%table.datatable
|
%table.datatable
|
||||||
%thead
|
%thead
|
||||||
|
%th
|
||||||
|
%b Select
|
||||||
%th
|
%th
|
||||||
%b ID
|
%b ID
|
||||||
%th
|
%th
|
||||||
|
|
@ -72,6 +82,8 @@
|
||||||
%b Actions
|
%b Actions
|
||||||
- @booths.each do |booth|
|
- @booths.each do |booth|
|
||||||
%tr
|
%tr
|
||||||
|
%td
|
||||||
|
= f.radio_button :current_booth_state, booth.state, { onclick: "showOptions(#{booth.id})" }
|
||||||
%td
|
%td
|
||||||
= booth.id
|
= booth.id
|
||||||
%td
|
%td
|
||||||
|
|
@ -100,3 +112,13 @@
|
||||||
.col-md-12.text-right
|
.col-md-12.text-right
|
||||||
- if can? :create, Booth
|
- if can? :create, Booth
|
||||||
= link_to 'New Booth', new_admin_conference_booth_path(@conference.short_title), class: 'button btn btn-primary'
|
= link_to 'New Booth', new_admin_conference_booth_path(@conference.short_title), class: 'button btn btn-primary'
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
function showOptions(booth_id){
|
||||||
|
var states = document.getElementsByClassName("common_booth_" + booth_id);
|
||||||
|
var select_tag = $('#booth_new_booth_state');
|
||||||
|
$('#booth_new_booth_state option:not(:first)').remove();
|
||||||
|
for (var state = 0; state < states.length; state++ ){
|
||||||
|
select_tag.append($("<option></option>").text(states[state].textContent));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ Osem::Application.routes.draw do
|
||||||
patch :confirm
|
patch :confirm
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
post '/booths_state' => 'booths#booths_state'
|
||||||
|
|
||||||
resources :registrations, except: [:create, :new] do
|
resources :registrations, except: [:create, :new] do
|
||||||
member do
|
member do
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue