Browse Source

Restyled registration add popover

development
Godwin 8 years ago
parent
commit
d70795e72c
  1. 34
      app/assets/stylesheets/_application.scss
  2. 42
      app/controllers/conferences_controller.rb
  3. 124
      app/helpers/application_helper.rb
  4. 2
      app/views/conferences/admin/_stats.html.haml
  5. 1
      config/locales/en.yml

34
app/assets/stylesheets/_application.scss

@ -393,7 +393,7 @@ body.expanded-element {
background-color: rgba($black, 0.5);
&.open {
display: block;
display: flex;
}
.modal-edit-overlay {
@ -407,23 +407,39 @@ body.expanded-element {
table {
margin: 0;
background-color: $white;
td.empty {
background-color: #F8F8F8;
border-bottom-color: #F8F8F8;
}
}
thead th {
text-align: center;
font-size: 1.125em;
color: $white;
border-color: lighten($colour-1, 12.5%);
background-color: $colour-1;
}
tbody th {
white-space: nowrap;
}
.modal-edit-content {
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
max-width: 40em;
position: relative;
min-width: 50em;
max-width: 75em;
margin: auto;
overflow: auto;
z-index: 1002;
background-color: #F8F8F8;
flex: 1;
}
table {
background-color: $white;
.actions {
margin: 1em 1em 0;
}
}

42
app/controllers/conferences_controller.rb

@ -481,6 +481,7 @@ class ConferencesController < ApplicationController
:email,
:status,
:is_attending,
:is_subscribed,
:registration_fees_paid,
:date,
:city,
@ -502,7 +503,8 @@ class ConferencesController < ApplicationController
:last_day,
:address,
:phone
] + ConferenceRegistration.all_spaces + [
] + ConferenceRegistration.all_spaces +
ConferenceRegistration.all_considerations + [
:notes
],
column_types: {
@ -524,7 +526,8 @@ class ConferencesController < ApplicationController
email: 'forms.labels.generic.email',
status: 'forms.labels.generic.registration_status',
is_attending: 'articles.conference_registration.terms.is_attending',
city: 'forms.labels.generic.location',
is_subscribed: 'articles.user_settings.headings.email_subscribe',
city: 'forms.labels.generic.event_location',
date: 'articles.conference_registration.terms.Date',
preferred_language: 'articles.conference_registration.terms.Preferred_Languages',
arrival: 'forms.labels.generic.arrival',
@ -536,13 +539,16 @@ class ConferencesController < ApplicationController
companion_email: 'articles.conference_registration.terms.companion_email',
allergies: 'forms.labels.generic.allergies',
registration_fees_paid: 'articles.conference_registration.headings.fees_paid',
other: 'articles.conference_registration.headings.other',
other: 'forms.labels.generic.other_notes',
can_provide_housing: 'articles.conference_registration.can_provide_housing',
first_day: 'forms.labels.generic.first_day',
last_day: 'forms.labels.generic.last_day',
notes: 'forms.labels.generic.notes',
phone: 'forms.labels.generic.phone',
address: 'forms.labels.generic.address'
address: 'forms.labels.generic.address',
contact_info: 'articles.conference_registration.headings.contact_info',
questions: 'articles.conference_registration.headings.questions',
hosting: 'articles.conference_registration.headings.hosting'
},
data: []
}
@ -553,6 +559,9 @@ class ConferencesController < ApplicationController
@excel_data[:column_types][s] = :number
@excel_data[:keys][s] = "forms.labels.generic.#{s.to_s}"
end
ConferenceRegistration.all_considerations.each do |c|
@excel_data[:keys][c] = "articles.conference_registration.host.considerations.#{c.to_s}"
end
@registrations.each do | r |
user = r.user_id ? User.where(id: r.user_id).first : nil
if user.present?
@ -572,10 +581,10 @@ class ConferencesController < ApplicationController
email: user.email || '',
status: (view_context._"articles.conference_registration.terms.registration_status.#{(steps.include? 'questions') ? 'registered' : ((steps.include? 'contact_info') ? 'preregistered' : 'unregistered')}"),
is_attending: (view_context._"articles.conference_registration.questions.bike.#{r.is_attending == 'n' ? 'no' : 'yes'}"),
is_subscribed: user.is_subscribed == false ? (view_context._'articles.conference_registration.questions.bike.no') : '',
date: r.created_at ? r.created_at.strftime("%F %T") : '',
city: r.city || '',
preferred_language: user.locale.present? ? (view_context.language_name user.locale) : '',
#languages: ((r.languages || []).map { |x| view_context.language_name x }).join(', ').to_s,
arrival: r.arrival ? r.arrival.strftime("%F %T") : '',
departure: r.departure ? r.departure.strftime("%F %T") : '',
housing: r.housing.present? ? (view_context._"articles.conference_registration.questions.housing.#{r.housing}") : '',
@ -600,6 +609,7 @@ class ConferencesController < ApplicationController
departure: r.departure.present? ? r.departure.to_date : nil,
preferred_language: user.locale,
is_attending: r.is_attending != 'n',
is_subscribed: user.is_subscribed,
can_provide_housing: r.can_provide_housing,
first_day: availability[0].present? ? availability[0].to_date : nil,
last_day: availability[1].present? ? availability[1].to_date : nil
@ -621,6 +631,11 @@ class ConferencesController < ApplicationController
space = (housing_data['space'] || {})[s.to_s]
data[s] = space.present? ? space.to_i : nil
end
ConferenceRegistration.all_considerations.each do |c|
consideration = (housing_data['considerations'] || []).include?(c.to_s)
data[c] = (consideration ? (view_context._'articles.conference_registration.questions.bike.yes') : '')
data[:raw_values][c] = consideration
end
@excel_data[:data] << data
end
end
@ -647,6 +662,7 @@ class ConferencesController < ApplicationController
(view_context.language_name l), l
] },
is_attending: [yes_no.first],
is_subscribed: [yes_no.last],
can_provide_housing: yes_no,
first_day: view_context.conference_days_options_list(:before),
last_day: view_context.conference_days_options_list(:after)
@ -656,6 +672,11 @@ class ConferencesController < ApplicationController
[(view_context._"articles.conference_registration.questions.bike.yes"), true]
]
end
ConferenceRegistration.all_considerations.each do | c |
@column_options[c.to_sym] = [
[(view_context._"articles.conference_registration.questions.bike.yes"), true]
]
end
end
end
@ -821,6 +842,9 @@ class ConferencesController < ApplicationController
when :preferred_language
registration.user.locale = value
user_changed = true
when :is_subscribed
registration.user.is_subscribed = (value != "false")
user_changed = true
when :is_attending
registration.is_attending = value.present? ? 'y' : 'n'
when :address, :phone, :first_day, :last_day, :notes
@ -838,6 +862,14 @@ class ConferencesController < ApplicationController
end
user_changed = true
end
elsif ConferenceRegistration.all_considerations.include? key.to_sym
registration.housing_data ||= {}
registration.housing_data['considerations'] ||= {}
if value.present?
registration.housing_data['considerations'] |= [key]
else
registration.housing_data['considerations'] -= [key]
end
elsif ConferenceRegistration.all_spaces.include? key.to_sym
registration.housing_data ||= {}
registration.housing_data['space'] ||= {}

124
app/helpers/application_helper.rb

@ -1542,20 +1542,67 @@ module ApplicationHelper
attributes = { class: options[:class], id: options[:id] }
attributes[:data] = { 'update-url' => options[:editable] } if options[:editable].present?
content_tag(:table, attributes) do
(content_tag(:tbody) do
rows = ''
excel_data[:columns].each do |column|
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)
if options[:column_names].is_a? Hash
return content_tag(:table, attributes) do
max_columns = 0
column_names = {}
(content_tag(:thead) do
headers = ''
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 |
column_names[header_name] << column
if (options[:row_spans] || {})[column].present?
row_count += (options[:row_spans][column] - 1)
for i in 1...options[:row_spans][column]
column_names[header_name] << false
end
end
end
max_columns = row_count if row_count > max_columns
end
end
rows.html_safe
end)
content_tag(:tr, headers.html_safe)
end) + (content_tag(:tbody) do
rows = ''
for i in 0...max_columns
columns_html = ''
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)
elsif column != false
columns_html += content_tag(:td, ' ', colspan: 2, class: :empty)
end
end
rows += content_tag(:tr, columns_html.html_safe, { class: 'always-edit', data: { key: '' } })
end
rows.html_safe
end)
end
else
return content_tag(:table, attributes) do
(content_tag(:tbody) do
rows = ''
excel_data[:columns].each do |column|
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)
end
end
end
rows.html_safe
end)
end
end
end
@ -1777,12 +1824,49 @@ module ApplicationHelper
end
def registrations_edit_table_options
options = registrations_table_options
options[:id] = 'create-table'
options[:class] << 'always-editing'
options[:column_names] += [:name, :email]
options[:required_columns] = [:name, :email]
return options
{
id: 'create-table',
class: ['registrations', 'admin-edit', 'always-editing'],
primary_key: :id,
column_names: {
contact_info: [
:name,
:email,
:is_subscribed,
:city,
:preferred_language
] + User.AVAILABLE_LANGUAGES.map { |l| "language_#{l}".to_sym },
questions: [
:registration_fees_paid,
:is_attending,
:arrival,
:departure,
:housing,
:bike,
:food,
:companion_email,
:allergies,
:other
],
hosting: [
:can_provide_housing,
:address,
:phone,
:first_day,
:last_day
] + ConferenceRegistration.all_spaces +
ConferenceRegistration.all_considerations + [
:notes
]
},
row_spans: {
allergies: 3,
other: 2
},
required_columns: [:name, :email],
editable: administration_update_path(@this_conference.slug, :stats),
column_options: @column_options
}
end
def registrations_table_options
@ -1793,6 +1877,7 @@ module ApplicationHelper
column_names: [
:registration_fees_paid,
:is_attending,
:is_subscribed,
:city,
:preferred_language,
:arrival,
@ -1811,7 +1896,8 @@ module ApplicationHelper
:notes
] +
User.AVAILABLE_LANGUAGES.map { |l| "language_#{l}".to_sym } +
ConferenceRegistration.all_spaces,
ConferenceRegistration.all_spaces +
ConferenceRegistration.all_considerations,
editable: administration_update_path(@this_conference.slug, :stats),
column_options: @column_options
}

2
app/views/conferences/admin/_stats.html.haml

@ -32,6 +32,6 @@
.modal-edit-overlay{data: { 'closes-modal': 'new-registration' }}
.modal-edit-content
=html_edit_table @excel_data, registrations_edit_table_options
.actions
.actions.right
%a.button.subdued{data: { 'closes-modal': 'new-registration' }}='Cancel'
= button_tag :save, value: :save, class: :modify

1
config/locales/en.yml

@ -1244,6 +1244,7 @@ en:
body: Body
day: Day
event_location: Location
other_notes: Other
time: Time
time_span: Length
reasons:

Loading…
Cancel
Save