Check in and some other improvements

This commit is contained in:
Godwin
2017-07-12 21:54:47 -07:00
parent 5a2dee502b
commit 0c4cde0669
22 changed files with 695 additions and 419 deletions
@@ -0,0 +1,174 @@
%script#registration-data{type: :json}=@registration_data.to_json.to_s.html_safe
= columns(medium: 12) do
= admin_update_form id: 'search-form' do
= searchfield :search, nil, big: true
%table#search-results
%thead
%tr
%th.corner
%th Email
%th Location
%th Organization
%th Status
%tbody
%p#no-search.search-message Search for a user by name, email, location, or organization
%p#no-results.search-message No matching user was found, enter an email address to regster a new user
#new-user.actions.center=link_to 'Register %{email}', check_in_path(@this_conference.slug, 'new_user').gsub('new_user', '%{url_email}'), class: :button
%template#search-result
%tr.registration{tabindex: 0}
%th.name= link_to '%{name}', check_in_path(@this_conference.slug, 'user_id').gsub('user_id', '%{user_id}')
%td %{email}
%td %{location}
%td %{organization}
%td.no-wrap %{status}
:javascript
var searchTable = null,
searchField = null,
lastSearch = null,
registrationData = null,
newUserMessage = null,
newUserMessageTemplate = null,
searchResultTemplate = null,
searchForm = null,
searchFields = ['email', 'name', 'location', 'oranization'];
function getRegistrationData() {
return JSON.parse(document.getElementById('registration-data').innerHTML);
}
function getSearchTable() {
return document.getElementById('search-results').getElementsByTagName('tbody')[0];
}
function getSearchResultTemplate() {
return document.getElementById('search-result').innerHTML;
}
function matchScore(data, terms) {
var score = 0;
for (var i = 0; i < terms.length; i++) {
var keys = Object.keys(data), termPos = -1;
for (var j = 0; j < keys.length; j++) {
var dataItem = data[keys[j]];
if (typeof(dataItem) === "string" && dataItem.length > 0) {
dataItem = dataItem.toLocaleLowerCase();
var index = dataItem.indexOf(' ' + terms[i]);
if (index < 0) {
index = dataItem.indexOf(terms[i]);
} else {
index = 0;
}
if (index >= 0 && (termPos < 0 || index < termPos)) {
termPos = index;
}
}
}
if (termPos >= 0) {
score += (termPos > 0 ? 10 : 20);
} else {
return 0;
}
}
return score + data['sort_weight'];
}
function searchResultHTML(data) {
if (searchResultTemplate === null) {
searchResultTemplate = getSearchResultTemplate();
}
var keys = Object.keys(data), html = searchResultTemplate;
for (var i = 0; i < keys.length; i++) {
var value = data[keys[i]];
if (value === null) {
value = '';
}
html = html.replace(new RegExp('%\\{' + keys[i] + '\\}', 'ig'), value);
}
return html;
}
function filterSearchResults() {
if (searchTable === null) {
searchTable = getSearchTable();
}
if (searchField === null) {
searchField = document.getElementById('search');
}
if (searchForm === null) {
searchForm = document.getElementById('search-form');
}
var searchTerm = searchField.value.toLocaleLowerCase().trim();
if (searchTerm != lastSearch) {
searchForm.classList.add('requesting');
var range = document.createRange();
range.selectNodeContents(searchTable);
range.deleteContents();
lastSearch = searchTerm;
var status = null;
if (searchTerm.length > 0) {
var terms = searchTerm.split(/\s+/);
if (registrationData === null) {
registrationData = getRegistrationData();
}
var matches = [];
for (var i = 0; i < registrationData.length; i++) {
var score = matchScore(registrationData[i], terms);
if (score > 0) {
matches.push({ score: score, data: registrationData[i] });
}
}
if (matches.length > 0) {
matches.sort(function(a, b) { return b.score - a.score; });
var html = '';
for (var i = 0; i < matches.length; i++) {
html += searchResultHTML(matches[i].data);
}
searchTable.innerHTML = html;
status = 'success';
} else if (searchTerm.match(/^\S+@\S+\.\S{2,}$/)) {
status = 'new-user';
if (newUserMessage === null) {
newUserMessage = document.getElementById('new-user');
newUserMessageTemplate = newUserMessage.innerHTML;
}
newUserMessage.innerHTML = newUserMessageTemplate.replace(/%\{email\}/g, searchTerm).replace(/%\{url_email\}/g, encodeURIComponent(searchTerm));
} else {
status = 'no-results';
}
} else {
status = 'no-search';
}
searchForm.setAttribute('data-status', status);
searchForm.classList.remove('requesting');
}
}
document.addEventListener('click', function(event) {
if (searchTable === null) {
searchTable = getSearchTable();
}
var target = event.target;
if (searchTable.contains(target)) {
while (target.tagName !== 'TR') {
target = target.parentElement;
}
var link = target.getElementsByTagName('a')[0];
window.location.href = link.href;
}
});
document.addEventListener('keyup', filterSearchResults);
filterSearchResults();
@@ -16,5 +16,7 @@
%th
.name=registration.user.name
.address=registration.housing_data['address']
- if registration.housing_data['notes'].present?
.host-notes=paragraph(registration.housing_data['notes'])
%td.inner-table{colspan: 2}=host_guests_table(registration)
- first_row = false
@@ -7,4 +7,4 @@
%h3 Select a Guest
#table
.actions.center
= link_to (_'links.download.Excel'), administration_step_path(@this_conference.slug, @admin_step, :format => :xlsx), class: [:button, :download]
= link_to (_'links.download.Excel'), administration_step_path(@this_conference.slug, @admin_step, format: :xlsx), class: [:button, :download]
@@ -13,8 +13,8 @@
= columns(medium: 12) do
%nav.sub-nav
%ul
%li=link_to (_'articles.admin.headings.back'), administrate_conference_path(@this_conference.slug)
- administration_steps[@admin_group].each do | step |
%li=link_to (_'articles.admin.headings.back'), administrate_conference_path(@this_conference.slug), class: 'back-to-start'
- administration_steps[@admin_group].each do |step|
%li
- title = (_"articles.admin.#{@admin_group}.headings.#{step}", :t)
- if step == @admin_step.to_sym
@@ -0,0 +1,94 @@
- body_class 'banner-bottom' unless @this_conference.poster.present?
- add_stylesheet :admin
- content_for :banner do
= render partial: 'application/header', locals: { page_group: :administration, page_key: 'Administration', image_file: @this_conference.poster_url || 'admin.jpg'}
%article{id: "admin-#{@admin_step}"}
= row do
= columns(medium: 12) do
- if admin_help_pages[@admin_step.to_sym]
= link_help_dlg("admin_#{admin_help_pages[@admin_step.to_sym]}", class: ['button', 'help-link'])
%h2.floating=_("articles.admin.#{@admin_group}.headings.check_in_user", vars: { name: @user_name_for_title }).html_safe
= row do
= columns(medium: 12) do
%nav.sub-nav
%ul
%li=link_to (_'articles.admin.headings.back'), administrate_conference_path(@this_conference.slug), class: 'back-to-start'
- administration_steps[@admin_group].each do |step|
%li
- title = (_"articles.admin.#{@admin_group}.headings.#{step}", :t)
- if step == @admin_step.to_sym
= title
- else
= link_to title, administration_step_path(@this_conference.slug, step.to_s)
= row do
= admin_update_form do
= columns(medium: 12) do
%p="Please verify with #{@user_name} that the following is correct. If you need to change check in information later, you can check the person in again to overwrite these values."
- if @user.id.present?
= hidden_field_tag :user_id, @user.id
- else
= hidden_field_tag :email, @user.email
= columns(medium: 12) do
%table#check-in{aria: { role: :presentation }}
- unless @user.firstname.present?
%tr
%td
%p="What is their name?"
%td= textfield :name, nil, big: true, label: false, required: true
- if @user.pronoun.nil?
%tr
%td
%p="Does #{@user_name} have a preferred pronoun? If so, enter it here"
%td= textfield :pronoun, nil, label: false
- unless @registration.city.present?
%tr
%td
%p="What city is #{@user_name} based? (Please be specific)"
%td= textfield :location, @user.last_location, label: false
%tr
%td
%p="Did you give #{@user_name} a programme and any other informational materials?"
%td= selectfield :programme, 'yes', [["I gave #{@user_name} a programme", 'yes'], ["I DID NOT give #{@user_name} a programme", 'no']], stretch: true, label: false
%tr
%td
- if @registration.bike.to_s == 'yes'
%p="#{@user_name_proper} said they <strong>do need a bike</strong>".html_safe
- elsif @registration.bike.to_s == 'no'
%p="#{@user_name_proper} said they <strong>do not need a bike</strong>".html_safe
- else
%p="Does #{@user_name} need a bike?".html_safe
%td= selectfield :bike, @registration.bike.to_s, [["#{@user_name_proper} is taking a bike", 'yes'], ["#{@user_name_proper} is NOT taking a bike", 'no']], stretch: true, label: false
%tr
%td
%p
- amount = @registration.registration_fees_paid || 0
- currency = @registration.conference.default_currency
- can_change_currency = true
- if amount > 0
- currency = @registration.data['payment_currency'] if @registration.data['payment_currency'].present?
="#{@user_name_proper} <strong>has already paid</strong> <u>#{number_to_currency amount, unit: '$'} #{currency}</u>, if they decide to make another donation you can add the amount here".html_safe
- amount = 0
- can_change_currency = false
- else
- amount = @registration.data['payment_amount'] || 0
- if amount > 0
="#{@user_name_proper} <strong>has pledged</strong> to pay <u>#{number_to_currency amount, unit: '$'} #{@registration.data['payment_currency']}</u>, please confirm and take their payment now".html_safe
- elsif @registration.data['payment_method'].present?
="#{@user_name_proper} <strong>has not pledged</strong> to pay for registration. If they would like to pay for registration now, enter their donation amount here".html_safe
- else
="Please collect registration fees from #{@user_name} if they are willing to donate and enter the amount here".html_safe
%td
.flex-column
.currency $
= numberfield :payment, amount || 0.0, required: true, step: 0.01, min: 0.0, inline: true, label: false, stretch: true
- if can_change_currency
= selectfield :currency, currency, [:CAD, :USD], inline: true, label: false, inline: true, label: false
- else
.currency
= currency
= hidden_field_tag :currency, currency
= columns(medium: 12) do
.actions.center
= button :check_in
= button :cancel, value: :cancel
@@ -1,20 +0,0 @@
<svg>
<defs>
<g id="rainbow">
<rect x="0%" y="0" width="<%= (100/5) %>%" height="100%" class="colour-2"/>
<rect x="<%= (100/5)*1 %>%" y="0" width="<%= (100/5) %>%" height="100%" class="colour-5"/>
<rect x="<%= (100/5)*2 %>%" y="0" width="<%= (100/5) %>%" height="100%" class="colour-4"/>
<rect x="<%= (100/5)*3 %>%" y="0" width="<%= (100/5) %>%" height="100%" class="colour-3"/>
<rect x="<%= (100/5)*4 %>%" y="0" width="<%= (100/5) %>%" height="100%" class="colour-1"/>
</g>
<image x="0" y="0" width="100%" height="100%" xlink:href="<%= @conference.cover_url || image_path('default_poster.jpg') %>" id="banner-image" preserveAspectRatio="xMidYMid slice"/>
<filter id="f1" x="0" y="0" width="1" height="1">
<feImage xlink:href="#rainbow" result="rainbow"/>
<feImage xlink:href="#banner-image" result="banner-image"/>
<feBlend mode="multiply" in="rainbow" in2="banner-image" />
</filter>
</defs>
<rect width="100%" height="100%" filter="url(#f1)"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.0 KiB

+11 -15
View File
@@ -10,8 +10,9 @@
- if conference.start_date.present? && conference.end_date.present?
.secondary
= date_span(conference.start_date.to_date, conference.end_date.to_date)
.register-link
= (link_to (_'forms.actions.generic.register'), register_path(conference.slug), class: [:button, :register]) if links.include?(:register) && conference.can_register?
- if conference.poster.present? && links.include?(:register) && conference.can_register?
.register-link
= (link_to _(is_registered ? 'actions.conference.edit_registration' : 'forms.actions.generic.register'), register_path(conference.slug), class: [:button, :register])
- if conference.poster.present?
%figure
%img{src: conference.poster.full.url, role: :presentation, alt: (_'images.conference.poster', vars: { conference_title: conference.title })}
@@ -20,26 +21,21 @@
= columns(medium: 10, push: {medium: 1}) do
%h2=_!conference.title if conference.poster.present?
= richtext conference.info
- conference.extended_details.each do |section|
- if sections.include?(section) && conference.copy_data[section][:show]
%h3=(_ conference.copy_data[section][:heading], vars: conference.copy_data[section][:vars]) unless conference.copy_data[section][:heading] == false
= richtext conference.copy_data[section][:value], (conference.copy_data[section][:heading] == false ? 2 : 3)
.links
= (link_to (_(is_registered ? 'actions.conference.edit_registration' : 'forms.actions.generic.register')), register_path(conference.slug), class: [:button, :register]) if links.include?(:register) && conference.can_register?
= (link_to (_'articles.workshops.info.read_more'), conference_path(conference.slug), class: :button) if links.include?(:read_more)
= (link_to (_'forms.actions.generic.administrate'), administrate_conference_path(conference.slug), class: [:button]) if links.include?(:administrate)
= (link_to (_'forms.actions.generic.edit'), edit_conference_path(conference.slug), class: [:button, :subdued]) if links.include?(:edit)
- if conference.registration_status == :open && sections.include?(:workshops)
- conference.extended_details.each do |section|
- if sections.include?(section) && conference.copy_data[section][:show]
%h3{id: section}=(_ conference.copy_data[section][:heading], vars: conference.copy_data[section][:vars]) unless conference.copy_data[section][:heading] == false
= richtext conference.copy_data[section][:value], (conference.copy_data[section][:heading] == false ? 2 : 3)
- if section == :workshop_info
.actions.center= link_to (_'articles.conference_registration.actions.View_Workshops'), workshops_path(conference), class: :button
- if conference.registration_status == :open && sections.include?(:schedule)
- if conference.workshop_schedule_published
- add_inline_script :home_schedule
%h3=_'articles.workshops.headings.Schedule'
= render 'conference_administration/schedule'
- else
%h3=_'articles.workshops.headings.Proposed_Workshops'
%p=_'articles.workshops.paragraphs.Proposed_Workshops'
= render 'workshops/workshop_previews', workshops: (conference.workshops.sort { |a, b| a.title.downcase <=> b.title.downcase })
.actions.center
= link_to (_'actions.workshops.create'), create_workshop_path(conference.slug), class: [:button, :modify]
+56 -54
View File
@@ -14,39 +14,40 @@
.actions.center
- translations_available_for_editing.each do |locale|
= link_to (_'actions.workshops.Translate', "Translate into #{language_name(locale)}", :vars => {:language => language_name(locale)}), translate_workshop_url(workshop.conference.slug, workshop.id, locale), :class => [:button, :translate]
= columns(medium: 6) do
%h3=_'articles.workshops.headings.facilitators'
.facilitators
- workshop.workshop_facilitators.each do |f|
- u = User.find(f.user_id)
- is_this_user = (f.user_id == current_user.id)
- if logged_in? && (workshop.public_facilitator?(u) || is_this_user || is_facilitator)
.facilitator
.name=_!u.name
.role
=_"roles.workshops.facilitator.#{workshop.role(u).to_s}"
- if is_facilitator && preview.blank?
.details
.email=_!u.email
- if f.role.to_sym == :requested
=(link_to (_'actions.workshops.Approve'), approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'approve'), :class => [:button, :modify])
=(link_to (_'actions.workshops.Deny'), approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'deny'), :class => [:button, :delete])
- elsif workshop.can_remove?(current_user, u)
=(link_with_confirmation (_'actions.workshops.Make_Owner'), (_'modals.workshops.facilitators.confirm_transfer_ownership', vars: { user_name: u.name}),approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'switch_ownership'), :class => [:button, :modify]) unless f.role.to_sym == :creator || !workshop.creator?(current_user)
=(link_with_confirmation (_"actions.workshops.#{is_this_user ? 'Leave' : 'Remove'}"), (_"modals.workshops.facilitators.confirm_remove#{is_this_user ? '_self' : ''}", vars: { user_name: u.name}), approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'remove'), :class => [:button, :delete])
- if is_this_user && workshop.requested_collaborator?(current_user)
.details
=(link_with_confirmation (_'actions.workshops.Cancel_Request'), (_'modals.workshops.facilitators.confirm_cancel_request'), approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'remove'), :class => [:button, :delete])
- unless preview.present?
=(link_to (_'actions.workshops.Facilitate'), facilitate_workshop_path(workshop.conference.slug, workshop.id), :class => [:button, workshop.needs_facilitators ? :accented : :subdued]) unless workshop.facilitator?(current_user)
- if is_facilitator
%h4=_'articles.workshops.headings.add_facilitator','Add a facilitator'
= form_tag workshop_add_facilitator_path(workshop.conference.slug, workshop.id), :class => 'add-facilitator mini-flex-form' do
.email-field.input-field
= email_field_tag :email, nil, required: true
= label_tag :email
= off_screen (_'forms.actions.aria.add'), 'add-new-desc'
= button :add, aria: { labelledby: 'add-new-desc' }
- if logged_in?
= columns(medium: 6) do
%h3=_'articles.workshops.headings.facilitators'
.facilitators
- workshop.workshop_facilitators.each do |f|
- u = User.find(f.user_id)
- is_this_user = (f.user_id == current_user.id)
- if logged_in? && (workshop.public_facilitator?(u) || is_this_user || is_facilitator)
.facilitator
.name=_!u.name
.role
=_"roles.workshops.facilitator.#{workshop.role(u).to_s}"
- if is_facilitator && preview.blank?
.details
.email=_!u.email
- if f.role.to_sym == :requested
=(link_to (_'actions.workshops.Approve'), approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'approve'), :class => [:button, :modify])
=(link_to (_'actions.workshops.Deny'), approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'deny'), :class => [:button, :delete])
- elsif workshop.can_remove?(current_user, u)
=(link_with_confirmation (_'actions.workshops.Make_Owner'), (_'modals.workshops.facilitators.confirm_transfer_ownership', vars: { user_name: u.name}),approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'switch_ownership'), :class => [:button, :modify]) unless f.role.to_sym == :creator || !workshop.creator?(current_user)
=(link_with_confirmation (_"actions.workshops.#{is_this_user ? 'Leave' : 'Remove'}"), (_"modals.workshops.facilitators.confirm_remove#{is_this_user ? '_self' : ''}", vars: { user_name: u.name}), approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'remove'), :class => [:button, :delete])
- if is_this_user && workshop.requested_collaborator?(current_user)
.details
=(link_with_confirmation (_'actions.workshops.Cancel_Request'), (_'modals.workshops.facilitators.confirm_cancel_request'), approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'remove'), :class => [:button, :delete])
- unless preview.present?
=(link_to (_'actions.workshops.Facilitate'), facilitate_workshop_path(workshop.conference.slug, workshop.id), :class => [:button, workshop.needs_facilitators ? :accented : :subdued]) unless workshop.facilitator?(current_user)
- if is_facilitator
%h4=_'articles.workshops.headings.add_facilitator','Add a facilitator'
= form_tag workshop_add_facilitator_path(workshop.conference.slug, workshop.id), :class => 'add-facilitator mini-flex-form' do
.email-field.input-field
= email_field_tag :email, nil, required: true
= label_tag :email
= off_screen (_'forms.actions.aria.add'), 'add-new-desc'
= button :add, aria: { labelledby: 'add-new-desc' }
- languages = JSON.parse(workshop.languages || '[]')
- if languages.present?
= columns(medium: 6) do
@@ -66,24 +67,25 @@
= columns(medium: 12, class: 'workshop-notes') do
%h3=_'articles.workshops.headings.notes','Notes'
= richtext workshop.notes, 3
= columns(medium: 12, id: :comments) do
%h3=_'articles.workshops.headings.Comments'
%ul.comments
- workshop.comments.each do |comment|
%li.comment{id: "comment-#{comment.id}"}
= comment(comment)
- sub_comments = comment.comments
- if sub_comments.present?
%ul.sub-comments.comments
- sub_comments.each do |sub_comment|
%li.sub-comment.comment{id: "comment-#{sub_comment.id}"}
= comment(sub_comment)
= form_tag workshop_comment_path(workshop.conference.slug, workshop.id) do
= hidden_field_tag :comment_id, comment.id
= textarea :reply, nil, plain: true, required: true, label: false, labelledby: "replyto-#{comment.id}"
.actions.right
= button :reply, value: :reply, data: {opens: "#comment-#{comment.id} form", focus: :textarea}, class: :small, id: "replyto-#{comment.id}"
= form_tag workshop_comment_path(workshop.conference.slug, workshop.id) do
= textarea :comment, nil, plain: true, required: true, label: false, labelledby: :add_comment
.actions.right
= button :add_comment, value: :add_comment, id: :add_comment
- if logged_in?
= columns(medium: 12, id: :comments) do
%h3=_'articles.workshops.headings.Comments'
%ul.comments
- workshop.comments.each do |comment|
%li.comment{id: "comment-#{comment.id}"}
= comment(comment)
- sub_comments = comment.comments
- if sub_comments.present?
%ul.sub-comments.comments
- sub_comments.each do |sub_comment|
%li.sub-comment.comment{id: "comment-#{sub_comment.id}"}
= comment(sub_comment)
= form_tag workshop_comment_path(workshop.conference.slug, workshop.id) do
= hidden_field_tag :comment_id, comment.id
= textarea :reply, nil, plain: true, required: true, label: false, labelledby: "replyto-#{comment.id}"
.actions.right
= button :reply, value: :reply, data: {opens: "#comment-#{comment.id} form", focus: :textarea}, class: :small, id: "replyto-#{comment.id}"
= form_tag workshop_comment_path(workshop.conference.slug, workshop.id) do
= textarea :comment, nil, plain: true, required: true, label: false, labelledby: :add_comment
.actions.right
= button :add_comment, value: :add_comment, id: :add_comment