Update booth views
This commit is contained in:
parent
64cb6ec456
commit
ffcb4d1374
5 changed files with 161 additions and 69 deletions
|
|
@ -8,6 +8,7 @@ module Admin
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@file_name = "#{(t 'booth').pluralize}_for_#{@conference.short_title}"
|
@file_name = "#{(t 'booth').pluralize}_for_#{@conference.short_title}"
|
||||||
|
@booth_groups = @conference.program.booth_groups
|
||||||
@booth_export_option = params[:booth_export_option]
|
@booth_export_option = params[:booth_export_option]
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,26 @@ module ApplicationHelper
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def booth_selector_input(field, form, hint = '', multiple = true)
|
||||||
|
booths = Booth.pluck(:id, :title).map { |booth| [booth[0], booth[1]]}
|
||||||
|
form.input(
|
||||||
|
field,
|
||||||
|
as: :select,
|
||||||
|
include_blank: true,
|
||||||
|
label: field.to_s.titleize,
|
||||||
|
hint: hint,
|
||||||
|
collection: options_for_select(
|
||||||
|
booths.map { |booth| [booth[1].to_s, booth[0]]},
|
||||||
|
(form.object.send(field)&.map(&:id) || form.object.send(field)&.id)
|
||||||
|
),
|
||||||
|
input_html: {
|
||||||
|
class: 'select-help-toggle',
|
||||||
|
multiple: multiple,
|
||||||
|
placeholder: (multiple ? "Select #{(t 'booth').pluralize}..." : "Select a #{t 'booth'}...")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
def event_types_sentence(conference)
|
def event_types_sentence(conference)
|
||||||
conference.event_types.map { |et| et.title.pluralize }.to_sentence
|
conference.event_types.map { |et| et.title.pluralize }.to_sentence
|
||||||
end
|
end
|
||||||
|
|
|
||||||
29
app/views/admin/booth_groups/_form.html.haml
Normal file
29
app/views/admin/booth_groups/_form.html.haml
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
.page-header
|
||||||
|
%h1
|
||||||
|
- if @booth_group.new_record?
|
||||||
|
New
|
||||||
|
#{(t 'booth').capitalize} Group
|
||||||
|
= @booth_group.name
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
= semantic_form_for(@booth_group, url: (@booth_group.new_record? ? admin_conference_program_booth_groups_path : admin_conference_program_booth_group_path(@conference.short_title, @booth_group))) do |f|
|
||||||
|
= f.input :name, input_html: { autofocus: true }
|
||||||
|
= f.input :color, input_html: {size: 6, type: 'color'}, required: true
|
||||||
|
|
||||||
|
- if @conference.try(:booths).present?
|
||||||
|
= booth_selector_input :booths, f, "The #{(t 'booth').pluralize} that you want to add to this Group."
|
||||||
|
- else
|
||||||
|
%b Please add #{(t 'booth').pluralize} before combining them.
|
||||||
|
|
||||||
|
%p.text-right
|
||||||
|
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#booth_group_booth_ids').selectize({
|
||||||
|
plugins: ['remove_button'],
|
||||||
|
minItems: 2
|
||||||
|
} )
|
||||||
|
});
|
||||||
74
app/views/admin/booths/_booths.html.haml
Normal file
74
app/views/admin/booths/_booths.html.haml
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
%h4
|
||||||
|
- if @conference.booth_limit == 0
|
||||||
|
%p
|
||||||
|
Set the
|
||||||
|
= link_to "#{(t'booth').capitalize } limit", edit_admin_conference_path(@conference.short_title)
|
||||||
|
to make sure you are not accepting more #{(t'booth').pluralize} than you can accommodate.
|
||||||
|
- elsif !@conference.maximum_accepted_booths?
|
||||||
|
%p
|
||||||
|
You cannot accept more than
|
||||||
|
%b
|
||||||
|
= pluralize(@conference.booth_limit, "#{t'booth'}")
|
||||||
|
(
|
||||||
|
= pluralize(@conference.booths.accepted.count + @conference.booths.confirmed.count, "accepted #{t'booth'}")
|
||||||
|
so far)
|
||||||
|
- else
|
||||||
|
%p
|
||||||
|
You have reached the maximum number of accepted #{(t'booth').pluralize}.
|
||||||
|
(
|
||||||
|
= link_to "#{@conference.booth_limit} #{(t'booth').pluralize}", edit_admin_conference_path(@conference.short_title)
|
||||||
|
)
|
||||||
|
- if @booths.any?
|
||||||
|
%table.datatable
|
||||||
|
%thead
|
||||||
|
%th
|
||||||
|
%b ID
|
||||||
|
%th
|
||||||
|
%b Logo
|
||||||
|
%th
|
||||||
|
%b Title
|
||||||
|
%th
|
||||||
|
%b Submitter
|
||||||
|
%th
|
||||||
|
%b Responsibles
|
||||||
|
%th
|
||||||
|
%b State
|
||||||
|
%th
|
||||||
|
%b Actions
|
||||||
|
- @booths.each do |booth|
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
= booth.id
|
||||||
|
%td
|
||||||
|
- if booth.logo_link
|
||||||
|
= image_tag(booth.picture.thumb.url, width: '20%')
|
||||||
|
%td{ style: 'padding: 15px 0px 0px 10px;' }
|
||||||
|
- if booth.try(:booth_group).present?
|
||||||
|
= link_to admin_conference_booth_path(@conference.short_title, booth), class: 'btn' do
|
||||||
|
%span.label{style: "background-color: #{booth.booth_group.color}; color: #{ contrast_color(booth.booth_group.color) }"}
|
||||||
|
= booth.title
|
||||||
|
- else
|
||||||
|
= link_to booth.title, admin_conference_booth_path(@conference.short_title, booth)
|
||||||
|
%td
|
||||||
|
= link_to booth.submitter.name, admin_user_path(booth.submitter) if booth.submitter
|
||||||
|
%td
|
||||||
|
.responsibles
|
||||||
|
- booth.responsibles.each_with_index do |responsible, i|
|
||||||
|
= link_to responsible.name, admin_user_path(responsible)
|
||||||
|
= ", " unless i == booth.responsibles.length - 1
|
||||||
|
%td
|
||||||
|
.btn-group
|
||||||
|
%button{ type: 'button', class: 'btn btn-link dropdown-toggle', 'data-toggle' => 'dropdown' }
|
||||||
|
= booth.state.humanize
|
||||||
|
%span.caret
|
||||||
|
%ul.dropdown-menu{ role: 'menu' }
|
||||||
|
= render 'change_state_dropdown', booth: booth
|
||||||
|
%td
|
||||||
|
= link_to 'Edit', edit_admin_conference_booth_path(@conference.short_title, booth.id),
|
||||||
|
class: 'btn btn-primary'
|
||||||
|
.row
|
||||||
|
.col-md-12.text-right
|
||||||
|
- if can? :create, Booth
|
||||||
|
= link_to 'New Booth', new_admin_conference_booth_path(@conference.short_title), class: 'button btn btn-primary'
|
||||||
|
|
@ -31,72 +31,40 @@
|
||||||
%p.text-muted
|
%p.text-muted
|
||||||
All the #{t'booth'} requests
|
All the #{t'booth'} requests
|
||||||
|
|
||||||
.row
|
.tabbable
|
||||||
.col-md-12
|
%ul.nav.nav-tabs
|
||||||
%h4
|
%li.active
|
||||||
- if @conference.booth_limit == 0
|
= link_to "All #{(t 'booth').pluralize}", '#all-stands', 'data-toggle' => 'tab'
|
||||||
%p
|
%li
|
||||||
Set the
|
= link_to "Combined #{(t 'booth').pluralize}", '#combined-stands', 'data-toggle' => 'tab'
|
||||||
= link_to "#{(t'booth').capitalize } limit", edit_admin_conference_path(@conference.short_title)
|
.tab-content
|
||||||
to make sure you are not accepting more #{(t'booth').pluralize} than you can accommodate.
|
#all-stands.tab-pane.active
|
||||||
- elsif !@conference.maximum_accepted_booths?
|
= render 'booths'
|
||||||
%p
|
#combined-stands.tab-pane
|
||||||
You cannot accept more than
|
.col-md-12
|
||||||
%b
|
%table.datatable
|
||||||
= pluralize(@conference.booth_limit, "#{t'booth'}")
|
%thead
|
||||||
(
|
%th ID
|
||||||
= pluralize(@conference.booths.accepted.count + @conference.booths.confirmed.count, "accepted #{t'booth'}")
|
%th Title
|
||||||
so far)
|
%th #{(t 'booth').pluralize.capitalize}
|
||||||
- else
|
%th Actions
|
||||||
%p
|
%tbody
|
||||||
You have reached the maximum number of accepted #{(t'booth').pluralize}.
|
- @booth_groups.each do |booth_group|
|
||||||
(
|
%tr
|
||||||
= link_to "#{@conference.booth_limit} #{(t'booth').pluralize}", edit_admin_conference_path(@conference.short_title)
|
%td
|
||||||
)
|
= booth_group.id
|
||||||
- if @booths.any?
|
%td
|
||||||
%table.datatable
|
= booth_group.name
|
||||||
%thead
|
%td
|
||||||
%th
|
- booth_group.booths.each do |booth|
|
||||||
%b ID
|
= link_to booth.title, admin_conference_booth_path(@conference.short_title, booth)
|
||||||
%th
|
%td
|
||||||
%b Logo
|
.btn-group{ role: 'group' }
|
||||||
%th
|
= link_to 'Edit', edit_admin_conference_program_booth_group_path(@conference.short_title, booth_group.id),
|
||||||
%b Title
|
method: :get, class: 'btn btn-primary'
|
||||||
%th
|
= link_to 'Delete', admin_conference_program_booth_group_path(@conference.short_title, booth_group.id),
|
||||||
%b Submitter
|
method: :delete, class: 'btn btn-danger', data: { confirm: "Do you really want to delete #{booth_group.name}?" }
|
||||||
%th
|
.row
|
||||||
%b Responsibles
|
.col-md-12.text-right
|
||||||
%th
|
= link_to "Create #{(t 'booth').capitalize} Group", new_admin_conference_program_booth_group_path(@conference.short_title), class: 'btn btn-primary'
|
||||||
%b State
|
|
||||||
%th
|
|
||||||
%b Actions
|
|
||||||
- @booths.each do |booth|
|
|
||||||
%tr
|
|
||||||
%td
|
|
||||||
= booth.id
|
|
||||||
%td
|
|
||||||
- if booth.logo_link
|
|
||||||
= image_tag(booth.picture.thumb.url, width: '20%')
|
|
||||||
%td
|
|
||||||
= link_to booth.title, admin_conference_booth_path(@conference.short_title, booth)
|
|
||||||
%td
|
|
||||||
= link_to booth.submitter.name, admin_user_path(booth.submitter) if booth.submitter
|
|
||||||
%td
|
|
||||||
.responsibles
|
|
||||||
- booth.responsibles.each_with_index do |responsible, i|
|
|
||||||
= link_to responsible.name, admin_user_path(responsible)
|
|
||||||
= ", " unless i == booth.responsibles.length - 1
|
|
||||||
%td
|
|
||||||
.btn-group
|
|
||||||
%button{ type: 'button', class: 'btn btn-link dropdown-toggle', 'data-toggle' => 'dropdown' }
|
|
||||||
= booth.state.humanize
|
|
||||||
%span.caret
|
|
||||||
%ul.dropdown-menu{ role: 'menu' }
|
|
||||||
= render 'change_state_dropdown', booth: booth
|
|
||||||
%td
|
|
||||||
= link_to 'Edit', edit_admin_conference_booth_path(@conference.short_title, booth.id),
|
|
||||||
class: 'btn btn-primary'
|
|
||||||
.row
|
|
||||||
.col-md-12.text-right
|
|
||||||
- if can? :create, Booth
|
|
||||||
= link_to 'New Booth', new_admin_conference_booth_path(@conference.short_title), class: 'button btn btn-primary'
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue