Admin improvements
This commit is contained in:
@@ -160,21 +160,6 @@ module AdminHelper
|
||||
end
|
||||
end
|
||||
|
||||
# housing_data = guest.housing_data || []
|
||||
|
||||
# if housing_data['host'].present?
|
||||
# if housing_data['host'] == host.id
|
||||
# return space == housing_data['space'] ? :selected_space : :other_space
|
||||
# end
|
||||
|
||||
# return :other_host
|
||||
# end
|
||||
|
||||
# if space_matches?(space, guest.housing) && available_dates_match?(host, guest)
|
||||
# return :good_match
|
||||
# end
|
||||
|
||||
# return :bad_match
|
||||
return :good_match
|
||||
end
|
||||
|
||||
@@ -190,6 +175,7 @@ module AdminHelper
|
||||
|
||||
def available_dates_match?(host, guest)
|
||||
return false unless host.housing_data['availability'].present? && host.housing_data['availability'][1].present?
|
||||
return false unless guest.arrival.present? && guest.departure.present?
|
||||
if host.housing_data['availability'][0] <= guest.arrival &&
|
||||
host.housing_data['availability'][1] >= guest.departure
|
||||
return true
|
||||
@@ -208,4 +194,10 @@ module AdminHelper
|
||||
end).html_safe
|
||||
end).html_safe
|
||||
end
|
||||
|
||||
def admin_help_pages
|
||||
return {
|
||||
housing: :housing
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -74,7 +74,7 @@ module GeocoderHelper
|
||||
return nil unless city.present?
|
||||
|
||||
hash = Hash.new
|
||||
region_translation = region.present? && country.present? ? _("geography.subregions.#{country}.#{region}", locale: locale) : ''
|
||||
region_translation = region.present? && country.present? ? I18n.t("geography.subregions.#{country}.#{region}", locale: locale, resolve: false) : ''
|
||||
country_translation = country.present? ? _("geography.countries.#{country}", locale: locale) : ''
|
||||
hash[:city] = _!(city) if city.present?
|
||||
hash[:region] = region_translation if region_translation.present?
|
||||
|
||||
@@ -8,6 +8,7 @@ module RegistrationHelper
|
||||
|
||||
def registration_status(registration)
|
||||
return :unregistered if registration.nil?
|
||||
return :cancelled if registration.is_attending == 'n'
|
||||
return registration.status
|
||||
end
|
||||
|
||||
@@ -47,7 +48,7 @@ module RegistrationHelper
|
||||
completed_steps = registration.steps_completed || []
|
||||
last_step = nil
|
||||
steps = current_registration_steps(registration) || []
|
||||
steps.each do | step |
|
||||
steps.each do |step|
|
||||
# return the last enabled step if this one is disabled
|
||||
return last_step unless step[:enabled]
|
||||
|
||||
|
||||
+51
-16
@@ -1,7 +1,12 @@
|
||||
module TableHelper
|
||||
def html_edit_table(excel_data, options = {})
|
||||
attributes = { class: options[:class], id: options[:id] }
|
||||
attributes[:data] = { 'update-url' => options[:editable] } if options[:editable].present?
|
||||
if options[:editable].present? || options[:sortable].present?
|
||||
attributes[:data] = {
|
||||
'update-url' => options[:editable],
|
||||
'sort-url' => options[:sortable]
|
||||
}
|
||||
end
|
||||
|
||||
if options[:column_names].is_a? Hash
|
||||
return content_tag(:table, attributes) do
|
||||
@@ -9,11 +14,11 @@ module TableHelper
|
||||
column_names = {}
|
||||
(content_tag(:thead) do
|
||||
headers = ''
|
||||
options[:column_names].each do | header_name, columns |
|
||||
options[:column_names].each do |header_name, columns|
|
||||
column_names[header_name] ||= []
|
||||
headers += content_tag(:th, excel_data[:keys][header_name].present? ? _(excel_data[:keys][header_name]) : '', colspan: 2)
|
||||
row_count = columns.size
|
||||
columns.each do | column |
|
||||
columns.each do |column|
|
||||
column_names[header_name] << column
|
||||
if (options[:row_spans] || {})[column].present?
|
||||
row_count += (options[:row_spans][column] - 1)
|
||||
@@ -30,15 +35,18 @@ module TableHelper
|
||||
|
||||
for i in 0...max_columns
|
||||
columns_html = ''
|
||||
column_names.each do | header_name, columns |
|
||||
column_names.each do |header_name, columns|
|
||||
column = columns[i]
|
||||
if column.present?
|
||||
attributes = { class: [excel_data[:column_types][column]], data: { 'column-id' => column } }
|
||||
if (options[:row_spans] || {})[column].present?
|
||||
attributes[:rowspan] = options[:row_spans][column]
|
||||
end
|
||||
columns_html += content_tag(:th, excel_data[:keys][column].present? ? _(excel_data[:keys][column]) : '', rowspan: attributes[:rowspan]) +
|
||||
edit_column(nil, column, nil, attributes, excel_data, options)
|
||||
|
||||
column_text = excel_data[:keys][column].present? ? _(excel_data[:keys][column]) : ''
|
||||
|
||||
columns_html += content_tag(:th, column_text.html_safe, rowspan: attributes[:rowspan]) +
|
||||
edit_column(nil, column, nil, attributes, excel_data, options)
|
||||
elsif column != false
|
||||
columns_html += content_tag(:td, ' ', colspan: 2, class: :empty)
|
||||
end
|
||||
@@ -56,8 +64,9 @@ module TableHelper
|
||||
if (excel_data[:column_types] || {})[column] != :table && ((options[:column_names] || []).include? column)
|
||||
rows += content_tag(:tr, { class: 'always-edit', data: { key: '' } }) do
|
||||
attributes = { class: [excel_data[:column_types][column]], data: { 'column-id' => column } }
|
||||
columns = content_tag(:th, excel_data[:keys][column].present? ? _(excel_data[:keys][column]) : '') +
|
||||
edit_column(nil, column, nil, attributes, excel_data, options)
|
||||
column_text = excel_data[:keys][column].present? ? _(excel_data[:keys][column]) : ''
|
||||
|
||||
columns = content_tag(:th, column_text.html_safe) + edit_column(nil, column, nil, attributes, excel_data, options)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -70,7 +79,16 @@ module TableHelper
|
||||
def html_table(excel_data, options = {})
|
||||
options[:html] = true
|
||||
attributes = { class: options[:class], id: options[:id] }
|
||||
attributes[:data] = { 'update-url' => options[:editable] } if options[:editable].present?
|
||||
|
||||
if options[:editable].present?
|
||||
attributes[:data] ||= {}
|
||||
attributes[:data]['update-url'] = options[:editable]
|
||||
end
|
||||
if options[:sortable].present?
|
||||
attributes[:data] ||= {}
|
||||
attributes[:data]['sort-url'] = options[:sortable]
|
||||
end
|
||||
|
||||
content_tag(:table, attributes) do
|
||||
(content_tag(:thead) do
|
||||
content_tag(:tr, excel_header_columns(excel_data))
|
||||
@@ -106,7 +124,17 @@ module TableHelper
|
||||
|
||||
data[:columns].each do |column|
|
||||
unless data[:column_types].present? && data[:column_types][column] == :table
|
||||
columns += content_tag(:th, data[:keys][column].present? ? _(data[:keys][column]) : '', class: class_name)
|
||||
column_text = data[:keys][column].present? ? _(data[:keys][column]) : ''
|
||||
attrs = { class: class_name }
|
||||
|
||||
unless @sort_column.nil?
|
||||
attrs[:data] = { colname: column }
|
||||
|
||||
if @sort_column == column
|
||||
attrs[:data][:dir] = @sort_dir || :down
|
||||
end
|
||||
end
|
||||
columns += content_tag(:th, column_text.html_safe, attrs)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -214,7 +242,7 @@ module TableHelper
|
||||
|
||||
def edit_column(row, column, value, attributes, data, options)
|
||||
attributes[:class] << 'has-editor'
|
||||
raw_value = row.present? ? (row[:raw_values][column] || value) : nil
|
||||
raw_value = row.present? ? ((row[:raw_values] || {})[column] || value) : nil
|
||||
|
||||
if row.present? && options[:html] && row[:html_values].present? && row[:html_values][column].present?
|
||||
value = row[:html_values][column]
|
||||
@@ -299,14 +327,16 @@ module TableHelper
|
||||
] + User.AVAILABLE_LANGUAGES.map { |l| "language_#{l}".to_sym },
|
||||
questions: [
|
||||
:registration_fees_paid,
|
||||
:payment_currency,
|
||||
:payment_method,
|
||||
:is_attending,
|
||||
:arrival,
|
||||
:departure,
|
||||
:housing,
|
||||
:bike,
|
||||
:food,
|
||||
:group_ride,
|
||||
:companion_email,
|
||||
:allergies,
|
||||
:other
|
||||
],
|
||||
hosting: [
|
||||
@@ -315,14 +345,15 @@ module TableHelper
|
||||
:phone,
|
||||
:first_day,
|
||||
:last_day
|
||||
] + ConferenceRegistration.all_spaces +
|
||||
ConferenceRegistration.all_considerations + [
|
||||
] + ConferenceRegistration.all_spaces + [
|
||||
:notes
|
||||
]
|
||||
},
|
||||
row_spans: {
|
||||
allergies: 3,
|
||||
other: 2
|
||||
other: 2,
|
||||
address: 2,
|
||||
city: 2,
|
||||
notes: 4
|
||||
},
|
||||
required_columns: [:name, :email],
|
||||
editable: administration_update_path(@this_conference.slug, @admin_step),
|
||||
@@ -337,12 +368,15 @@ module TableHelper
|
||||
primary_key: :id,
|
||||
column_names: [
|
||||
:registration_fees_paid,
|
||||
:payment_currency,
|
||||
:payment_method,
|
||||
:is_attending,
|
||||
:is_subscribed,
|
||||
:city,
|
||||
:preferred_language,
|
||||
:arrival,
|
||||
:departure,
|
||||
:group_ride,
|
||||
:housing,
|
||||
:bike,
|
||||
:food,
|
||||
@@ -360,6 +394,7 @@ module TableHelper
|
||||
ConferenceRegistration.all_spaces +
|
||||
ConferenceRegistration.all_considerations,
|
||||
editable: administration_update_path(@this_conference.slug, @admin_step),
|
||||
sortable: administration_step_path(@this_conference.slug, @admin_step),
|
||||
column_options: @column_options
|
||||
}
|
||||
end
|
||||
|
||||
@@ -99,75 +99,86 @@ module WidgetsHelper
|
||||
def host_guests_table(registration)
|
||||
id = registration.id
|
||||
html = ''
|
||||
first_row = true
|
||||
|
||||
@housing_data[id][:guests].each do |area, guests|
|
||||
guest_rows = ''
|
||||
guests.each do |guest_id, guest|
|
||||
space_size = (@housing_data[id][:space][area] || 0)
|
||||
|
||||
if space_size > 0 || guests.size > 0
|
||||
guests.each do |guest_id, guest|
|
||||
status_html = ''
|
||||
|
||||
@housing_data[id][:guest_data][guest_id][:errors].each do |error, value|
|
||||
if value.is_a?(Array)
|
||||
value.each do |v|
|
||||
status_html += content_tag(:li, _("errors.messages.housing.space.#{error.to_s}", vars: v))
|
||||
end
|
||||
else
|
||||
status_html += content_tag(:li, _("errors.messages.housing.space.#{error.to_s}", vars: value))
|
||||
end
|
||||
end
|
||||
|
||||
@housing_data[id][:guest_data][guest_id][:warnings].each do |error, value|
|
||||
if value.is_a?(Array)
|
||||
value.each do |v|
|
||||
status_html += content_tag(:li, _("warnings.messages.housing.space.#{error.to_s}", v))
|
||||
end
|
||||
else
|
||||
status_html += content_tag(:li, _("warnings.messages.housing.space.#{error.to_s}", vars: value))
|
||||
end
|
||||
end
|
||||
|
||||
if status_html.present?
|
||||
status_html = content_tag(:ul, status_html.html_safe)
|
||||
end
|
||||
|
||||
guest_rows += content_tag :tr, id: "hosted-guest-#{guest_id}" do
|
||||
(content_tag :td, guest[:guest].user.name) +
|
||||
(content_tag :td do
|
||||
(guest[:guest].from +
|
||||
(content_tag :a, (_'actions.workshops.Remove'), href: '#', class: 'remove-guest', data: { guest: guest_id })).html_safe
|
||||
end) +
|
||||
(content_tag :td, status_html.html_safe, class: [:state, status_html.present? ? :unhappy : :happy])
|
||||
end
|
||||
end
|
||||
|
||||
# add empty rows to represent empty guest spots
|
||||
for i in guests.size...space_size
|
||||
guest_rows += content_tag :tr, class: 'empty-space' do
|
||||
(content_tag :td, ' '.html_safe, colspan: 2) +
|
||||
(content_tag :td)
|
||||
end
|
||||
end
|
||||
|
||||
status_html = ''
|
||||
|
||||
@housing_data[id][:guest_data][guest_id][:errors].each do |error, value|
|
||||
if value.is_a?(Array)
|
||||
value.each do |v|
|
||||
status_html += content_tag(:li, _("errors.messages.housing.space.#{error.to_s}", vars: v))
|
||||
end
|
||||
else
|
||||
status_html += content_tag(:li, _("errors.messages.housing.space.#{error.to_s}", vars: value))
|
||||
if @housing_data[id][:warnings].present? && @housing_data[id][:warnings][:space].present? && @housing_data[id][:warnings][:space][area].present?
|
||||
@housing_data[id][:warnings][:space][area].each do |w|
|
||||
status_html += content_tag(:li, _("warnings.messages.housing.space.#{w.to_s}"))
|
||||
end
|
||||
end
|
||||
|
||||
@housing_data[id][:guest_data][guest_id][:warnings].each do |error, value|
|
||||
if value.is_a?(Array)
|
||||
value.each do |v|
|
||||
status_html += content_tag(:li, _("warnings.messages.housing.space.#{error.to_s}", v))
|
||||
end
|
||||
else
|
||||
status_html += content_tag(:li, _("warnings.messages.housing.space.#{error.to_s}", vars: value))
|
||||
end
|
||||
end
|
||||
|
||||
if status_html.present?
|
||||
status_html = content_tag(:ul, status_html.html_safe)
|
||||
end
|
||||
|
||||
guest_rows += content_tag :tr, id: "hosted-guest-#{guest_id}" do
|
||||
(content_tag :td, guest[:guest].user.name) +
|
||||
(content_tag :td do
|
||||
(guest[:guest].from +
|
||||
(content_tag :a, (_'actions.workshops.Remove'), href: '#', class: 'remove-guest', data: { guest: guest_id })).html_safe
|
||||
end) +
|
||||
(content_tag :td, status_html.html_safe, class: [:state, status_html.present? ? :unhappy : :happy])
|
||||
unless first_row
|
||||
html += content_tag :tr, class: :spacer do
|
||||
content_tag :td, '', colspan: 3
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
space_size = (@housing_data[id][:space][area] || 0)
|
||||
|
||||
# add empty rows to represent empty guest spots
|
||||
for i in guests.size...space_size
|
||||
guest_rows += content_tag :tr, class: 'empty-space' do
|
||||
(content_tag :td, ' '.html_safe, colspan: 2) +
|
||||
(content_tag :td)
|
||||
html += content_tag :tr do
|
||||
(content_tag :th, (_"forms.labels.generic.#{area}"), colspan: 2) +
|
||||
(content_tag :th, status_html.html_safe, class: [:state, status_html.present? ? :unhappy : :happy])
|
||||
end
|
||||
end
|
||||
|
||||
status_html = ''
|
||||
if @housing_data[id][:warnings].present? && @housing_data[id][:warnings][:space].present? && @housing_data[id][:warnings][:space][area].present?
|
||||
@housing_data[id][:warnings][:space][area].each do |w|
|
||||
status_html += content_tag(:li, _("warnings.messages.housing.space.#{w.to_s}"))
|
||||
html += guest_rows
|
||||
html += content_tag :tr, class: 'place-guest' do
|
||||
content_tag :td, class: guests.size >= space_size ? 'full' : nil, colspan: 3 do
|
||||
content_tag :a, (_"forms.actions.generic.place_guest_in.#{area}"), class: 'select-guest button small', href: '#', data: { host: id, space: area }
|
||||
end
|
||||
end
|
||||
end
|
||||
if status_html.present?
|
||||
status_html = content_tag(:ul, status_html.html_safe)
|
||||
end
|
||||
|
||||
html += content_tag :tr do
|
||||
(content_tag :th, (_"forms.labels.generic.#{area}"), colspan: 2) +
|
||||
(content_tag :th, status_html.html_safe, class: [:state, status_html.present? ? :unhappy : :happy])
|
||||
end
|
||||
html += guest_rows
|
||||
html += content_tag :tr, class: 'place-guest' do
|
||||
content_tag :td, class: guests.size >= space_size ? 'full' : nil, colspan: 3 do
|
||||
content_tag :a, (_'forms.actions.generic.place_guest'), class: 'select-guest', href: '#', data: { host: id, space: area }
|
||||
end
|
||||
first_row = false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -181,21 +192,31 @@ module WidgetsHelper
|
||||
id = registration.id
|
||||
@housing_data[id][:guests].each do |area, guests|
|
||||
max_space = @housing_data[id][:space][area] || 0
|
||||
area_name = (_"forms.labels.generic.#{area}")
|
||||
status_html = ''
|
||||
if @housing_data[id][:warnings].present? && @housing_data[id][:warnings][:space].present? && @housing_data[id][:warnings][:space][area].present?
|
||||
@housing_data[id][:warnings][:space][area].each do |w|
|
||||
status_html += content_tag(:div, _("warnings.housing.space.#{w.to_s}"), class: 'warning')
|
||||
|
||||
# don't include the area if the host doesn't want anyone there
|
||||
if max_space > 0 || guests.size > 0
|
||||
area_name = (_"forms.labels.generic.#{area}")
|
||||
status_html = ''
|
||||
if @housing_data[id][:warnings].present? && @housing_data[id][:warnings][:space].present? && @housing_data[id][:warnings][:space][area].present?
|
||||
@housing_data[id][:warnings][:space][area].each do |w|
|
||||
status_html += content_tag(:div, _("warnings.housing.space.#{w.to_s}"), class: 'warning')
|
||||
end
|
||||
end
|
||||
space_html = content_tag(:h5, area_name + _!(" (#{guests.size.to_s}/#{max_space.to_s})") + status_html.html_safe)
|
||||
guest_items = ''
|
||||
guests.each do |guest_id, guest|
|
||||
guest_items += content_tag(:li, guest[:guest].user.name, id: "hosted-guest-#{guest_id}")
|
||||
end
|
||||
space_html += content_tag(:ul, guest_items.html_safe)
|
||||
|
||||
# see if the space is overbooked
|
||||
booked_state = guests.size >= max_space ? (guests.size > max_space ? :overbooked : :booked) : nil
|
||||
|
||||
# let space be overbooked, even bed space can be overbooked if a couple is staying in the bed
|
||||
space_html += button :place_guest, type: :button, value: "#{area}:#{id}", class: [:small, 'place-guest', 'on-top-only', booked_state, max_space > 0 ? nil : :unwanted]
|
||||
|
||||
html += content_tag(:div, space_html, class: [:space, area, max_space > 0 || guests.size > 0 ? nil : 'on-top-only'])
|
||||
end
|
||||
space_html = content_tag(:h5, area_name + _!(" (#{guests.size.to_s}/#{max_space.to_s})") + status_html.html_safe)
|
||||
guest_items = ''
|
||||
guests.each do |guest_id, guest|
|
||||
guest_items += content_tag(:li, guest[:guest].user.name, id: "hosted-guest-#{guest_id}")
|
||||
end
|
||||
space_html += content_tag(:ul, guest_items.html_safe)
|
||||
space_html += button :place_guest, type: :button, value: "#{area}:#{id}", class: [:small, 'place-guest', 'on-top-only', guests.size >= max_space ? (guests.size > max_space ? :overbooked : :booked) : nil, max_space > 0 ? nil : :unwanted]
|
||||
html += content_tag(:div, space_html, class: [:space, area, max_space > 0 || guests.size > 0 ? nil : 'on-top-only'])
|
||||
end
|
||||
|
||||
classes << 'status-warning' if @housing_data[id][:warnings].present?
|
||||
@@ -228,6 +249,16 @@ module WidgetsHelper
|
||||
end
|
||||
end
|
||||
|
||||
def link_help_dlg(topic, args = {})
|
||||
@help_dlg ||= true
|
||||
args[:data] ||= {}
|
||||
args[:data]['info-title'] = I18n.t("help.headings.#{topic}")
|
||||
args[:data]['help-text'] = true
|
||||
content_tag(:a, args) do
|
||||
(I18n.t('help.link_text') + content_tag(:template, (render "/help/#{topic}"), class: 'message')).html_safe
|
||||
end
|
||||
end
|
||||
|
||||
def button_with_confirmation(button_name, confirmation_text = nil, args = {})
|
||||
if confirmation_text.is_a? Hash
|
||||
args = confirmation_text
|
||||
|
||||
Reference in New Issue
Block a user