Godwin
7 years ago
22 changed files with 695 additions and 419 deletions
After Width: | Height: | Size: 670 B |
@ -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(); |
@ -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 |
Before Width: | Height: | Size: 1.0 KiB |
Loading…
Reference in new issue