Browse Source

Added accessibility support to interest and add facilitator buttons and made facilitation buttons and message make more sense

development
Godwin 8 years ago
parent
commit
abe0b3a40d
  1. 2
      app/assets/javascripts/main.js
  2. 1
      app/assets/stylesheets/_application.scss
  3. 1
      app/controllers/application_controller.rb
  4. 8
      app/controllers/conferences_controller.rb
  5. 17
      app/helpers/application_helper.rb
  6. 2
      app/views/conferences/_contact_info.html.haml
  7. 14
      app/views/workshops/_show.html.haml
  8. 13
      config/locales/en.yml

2
app/assets/javascripts/main.js

@ -104,7 +104,7 @@
if (request.status == 200) { if (request.status == 200) {
var response = JSON.parse(request.responseText); var response = JSON.parse(request.responseText);
for (var i = 0; i < response.length; i++) { for (var i = 0; i < response.length; i++) {
form.querySelector(response[i].selector).outerHTML = response[i].html; form.querySelector(response[i].selector).innerHTML = response[i].html;
} }
} }
} }

1
app/assets/stylesheets/_application.scss

@ -1995,6 +1995,7 @@ html[data-lingua-franca-example="html"] {
font-size: 0.9em; font-size: 0.9em;
margin: 1em; margin: 1em;
background-color: $colour-1; background-color: $colour-1;
vertical-align: middle;
&.delete { &.delete {
background-color: $colour-4; background-color: $colour-4;

1
app/controllers/application_controller.rb

@ -303,5 +303,6 @@ class ApplicationController < LinguaFrancaApplicationController
params, params,
current_user, current_user,
).deliver_now if Rails.env.preview? || Rails.env.production? ).deliver_now if Rails.env.preview? || Rails.env.production?
logger.info "Missing translation found for: #{key}"
end end
end end

8
app/controllers/conferences_controller.rb

@ -913,7 +913,7 @@ class ConferencesController < ApplicationController
set_conference set_conference
set_conference_registration set_conference_registration
@workshops = Workshop.where(:conference_id => @this_conference.id) @workshops = Workshop.where(:conference_id => @this_conference.id)
@my_workshops = Workshop.joins(:workshop_facilitators).where(:workshop_facilitators => {:user_id => current_user.id}, :conference_id => @this_conference.id)#, :workshop_facilitator => current_user.id) @my_workshops = Workshop.joins(:workshop_facilitators).where(:workshop_facilitators => {:user_id => current_user.id}, :conference_id => @this_conference.id)
render 'workshops/index' render 'workshops/index'
end end
@ -1084,11 +1084,9 @@ class ConferencesController < ApplicationController
WorkshopInterest.create(:workshop_id => workshop.id, :user_id => current_user.id) unless interested WorkshopInterest.create(:workshop_id => workshop.id, :user_id => current_user.id) unless interested
if request.xhr? if request.xhr?
interest = workshop.interested?(current_user) ? :remove_interest : :show_interest
css_class = workshop.interested?(current_user) ? :delete : :add
render json: [ { render json: [ {
selector: 'button[value="toggle_interest"]', selector: '.interest-button',
html: view_context.button_tag(interest, :value => :toggle_interest, :class => css_class) html: view_context.interest_button(workshop)
} ] } ]
else else
# go back to the workshop # go back to the workshop

17
app/helpers/application_helper.rb

@ -211,8 +211,8 @@ module ApplicationHelper
false false
end end
def off_screen(text) def off_screen(text, id = nil)
"<span class=\"screen-reader-text\">#{text}</span>".html_safe content_tag(:span, text.html_safe, id: id, class: 'screen-reader-text')
end end
def url_for_locale(locale) def url_for_locale(locale)
@ -620,10 +620,10 @@ module ApplicationHelper
location1.eql? location2 location1.eql? location2
end end
def show_errors(field) def show_errors(field, value)
return '' unless @errors && @errors[field].present? return '' unless @errors && @errors[field].present?
error_txt = _"errors.messages.fields.#{field.to_s}.#{@errors[field]}", :s error_txt = _"errors.messages.fields.#{field.to_s}.#{@errors[field]}", :s, vars: { value: value }
"<div class=\"field-error\">#{error_txt}</div>".html_safe "<div class=\"field-error\">#{error_txt}</div>".html_safe
end end
@ -706,6 +706,13 @@ module ApplicationHelper
return days return days
end end
def interest_button(workshop)
interested = workshop.interested?(current_user) ? :remove_interest : :show_interest
id = "#{interested.to_s.gsub('_', '-')}-#{workshop.id}"
return (off_screen (_"form.actions.aria.#{interested.to_s}"), id) +
(button_tag interested, :value => :toggle_interest, :class => (workshop.interested?(current_user) ? :delete : :add), aria: { labelledby: id })
end
def richtext(text, reduce_headings = 2) def richtext(text, reduce_headings = 2)
return '' unless text.present? return '' unless text.present?
return _!(text). return _!(text).
@ -795,7 +802,7 @@ module ApplicationHelper
html += content_tag(:div, _(options[:help], :s, 2), class: 'input-field-help', id: description_id) html += content_tag(:div, _(options[:help], :s, 2), class: 'input-field-help', id: description_id)
end end
html += show_errors name html += show_errors name, value
html += label_tag name html += label_tag name
input_options = { input_options = {
required: options[:required], required: options[:required],

2
app/views/conferences/_contact_info.html.haml

@ -4,7 +4,7 @@
= columns(medium: 12) do = columns(medium: 12) do
= form_tag register_path(@this_conference.slug) do = form_tag register_path(@this_conference.slug) do
= textfield :name, @name, required: true, heading: 'articles.conference_registration.headings.name', big: true = textfield :name, @name, required: true, heading: 'articles.conference_registration.headings.name', big: true
= textfield :location, (@registration.city || location(lookup_ip_location)), required: true, heading: 'articles.conference_registration.headings.location' = textfield :location, (params[:location] || @registration.city || location(lookup_ip_location)), required: true, heading: 'articles.conference_registration.headings.location'
= checkboxes :languages, [:en, :es, :fr], current_user.languages, 'languages', heading: 'articles.conference_registration.headings.languages' = checkboxes :languages, [:en, :es, :fr], current_user.languages, 'languages', heading: 'articles.conference_registration.headings.languages'
.actions.next-prev .actions.next-prev
= button_tag (params[:step] == :save ? :save : :next), value: :contact_info = button_tag (params[:step] == :save ? :save : :next), value: :contact_info

14
app/views/workshops/_show.html.haml

@ -9,7 +9,7 @@
=_'articles.workshops.info.interested_count', "#{workshop.interested_count} people are interested in this workshop", :vars => {:count => workshop.interested_count} =_'articles.workshops.info.interested_count', "#{workshop.interested_count} people are interested in this workshop", :vars => {:count => workshop.interested_count}
- if preview.blank? && workshop.can_show_interest?(current_user) - if preview.blank? && workshop.can_show_interest?(current_user)
= form_tag toggle_workshop_interest_path(workshop.conference.slug, workshop.id), class: 'js-xhr' do = form_tag toggle_workshop_interest_path(workshop.conference.slug, workshop.id), class: 'js-xhr' do
= button_tag (workshop.interested?(current_user) ? :remove_interest : :show_interest), :value => :toggle_interest, :class => (workshop.interested?(current_user) ? :delete : :add) %span.interest-button=interest_button(workshop)
= richtext workshop.info = richtext workshop.info
- if preview.blank? && translations_available_for_editing - if preview.blank? && translations_available_for_editing
.actions .actions
@ -20,7 +20,8 @@
.facilitators .facilitators
- workshop.workshop_facilitators.each do |f| - workshop.workshop_facilitators.each do |f|
- u = User.find(f.user_id) - u = User.find(f.user_id)
- if logged_in? && (workshop.public_facilitator?(u) || f.user_id == current_user.id || is_facilitator) - is_this_user = (f.user_id == current_user.id)
- if logged_in? && (workshop.public_facilitator?(u) || is_this_user || is_facilitator)
.facilitator .facilitator
.name=_!u.name .name=_!u.name
.role .role
@ -33,10 +34,10 @@
=(link_to (_'actions.workshops.Deny'), approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'deny'), :class => [:button, :delete]) =(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) - elsif workshop.can_remove?(current_user, u)
=(link_to (_'actions.workshops.Make_Owner'), approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'switch_ownership'), :class => [:button, :modify], data: {confirmation: CGI::escapeHTML(_'modals.workshops.facilitators.confirm_transfer_ownership', vars: { user_name: u.name})}) unless f.role.to_sym == :creator || !workshop.creator?(current_user) =(link_to (_'actions.workshops.Make_Owner'), approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'switch_ownership'), :class => [:button, :modify], data: {confirmation: CGI::escapeHTML(_'modals.workshops.facilitators.confirm_transfer_ownership', vars: { user_name: u.name})}) unless f.role.to_sym == :creator || !workshop.creator?(current_user)
=(link_to (_'actions.workshops.Remove'), approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'remove'), :class => [:button, :delete], data: {confirmation: CGI::escapeHTML(_'modals.workshops.facilitators.confirm_remove', vars: { user_name: u.name})}) =(link_to (_"actions.workshops.#{is_this_user ? 'Leave' : 'Remove'}"), approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'remove'), :class => [:button, :delete], data: {confirmation: CGI::escapeHTML(_"modals.workshops.facilitators.confirm_remove#{is_this_user ? '_self' : ''}", vars: { user_name: u.name})})
- if f.user_id == current_user.id && workshop.requested_collaborator?(current_user) - if is_this_user && workshop.requested_collaborator?(current_user)
.details .details
=(link_to (_'actions.workshops.Remove'), approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'remove'), :class => [:button, :delete], data: {confirmation: CGI::escapeHTML(_'modals.workshops.facilitators.confirm_remove_self')}) =(link_to (_'actions.workshops.Cancel_Request'), approve_facilitate_workshop_request_path(workshop.conference.slug, workshop.id, f.user_id, 'remove'), :class => [:button, :delete], data: {confirmation: CGI::escapeHTML(_'modals.workshops.facilitators.confirm_cancel_request')})
- unless preview.present? - 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) =(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 - if is_facilitator
@ -45,7 +46,8 @@
.email-field.input-field .email-field.input-field
= email_field_tag :email, nil, required: true = email_field_tag :email, nil, required: true
= label_tag :email = label_tag :email
= button_tag :add = off_screen (_'form.actions.aria.add'), 'add-new-desc'
= button_tag :add, aria: { labelledby: 'add-new-desc' }
- languages = JSON.parse(workshop.languages || '[]') - languages = JSON.parse(workshop.languages || '[]')
- if languages.present? - if languages.present?
= columns(medium: 6) do = columns(medium: 6) do

13
config/locales/en.yml

@ -151,6 +151,12 @@ en:
not valid content-type? Original Error: %{e}' not valid content-type? Original Error: %{e}'
mini_magick_processing_error: 'Failed to manipulate with MiniMagick, maybe it mini_magick_processing_error: 'Failed to manipulate with MiniMagick, maybe it
is not an image? Original Error: %{e}' is not an image? Original Error: %{e}'
fields:
location:
empty: 'Please enter your location'
unknown: 'Please include your city or town, we could not find a locality from "%{value}"'
name:
empty: 'Please enter a valid name'
template: template:
body: 'There were problems with the following fields:' body: 'There were problems with the following fields:'
header: header:
@ -5267,6 +5273,7 @@ en:
facilitators: facilitators:
confirm_remove: Are you sure you would like to remove %{user_name} as a facilitator of this workshop? confirm_remove: Are you sure you would like to remove %{user_name} as a facilitator of this workshop?
confirm_remove_self: Are you sure you would like to remove yourself as a facilitator of this workshop? confirm_remove_self: Are you sure you would like to remove yourself as a facilitator of this workshop?
confirm_cancel_request: Are you sure you would like to cancel your request to become a facilitator of this workshop?
confirm_transfer_ownership: By transferring ownership, you will lose administrative capabilities such as deletion and approving new facilitators. Are you sure you want to transfer ownership to %{user_name}? confirm_transfer_ownership: By transferring ownership, you will lose administrative capabilities such as deletion and approving new facilitators. Are you sure you want to transfer ownership to %{user_name}?
articles: articles:
policy: policy:
@ -5609,6 +5616,10 @@ en:
next: Next next: Next
continue: Continue continue: Continue
facebook_sign_in: Facebook Sign In facebook_sign_in: Facebook Sign In
aria:
remove_interest: Click if you are no longer interested in this workshop
show_interest: Click if you are interested in this workshop
add: Add new
page_titles: page_titles:
'403': '403':
Access_Denied: Access Denied Access_Denied: Access Denied
@ -5675,6 +5686,8 @@ en:
Deny: Deny Deny: Deny
Facilitate: Make a facilitation request Facilitate: Make a facilitation request
Remove: Remove Remove: Remove
Leave: Leave
Cancel_Request: Cancel Request
Make_Owner: Transfer Ownership Make_Owner: Transfer Ownership
View: View this workshop View: View this workshop
View_All: View all workshops View_All: View all workshops

Loading…
Cancel
Save