[Git][noosfero/noosfero][master] 3 commits: CustomForms: display results for screen readers
Rodrigo Souto
gitlab at mg.gitlab.com
Fri Mar 23 16:44:30 BRT 2018
Rodrigo Souto pushed to branch master at Noosfero / noosfero
Commits:
04acab19 by Gabriel Silva at 2018-03-22T04:02:23Z
CustomForms: display results for screen readers
Signed-off-by: Gabriel Silva <gabriel93.silva at gmail.com>
- - - - -
38f385c1 by Gabriel Silva at 2018-03-22T04:43:40Z
CustomForms: refactors review page into partials
Signed-off-by: Gabriel Silva <gabriel93.silva at gmail.com>
- - - - -
fe5052fc by Rodrigo Souto at 2018-03-23T19:44:06Z
Merge branch 'table-results' into 'master'
CustomFormsPlugin: shows results to screen readers
See merge request noosfero/noosfero!1421
- - - - -
9 changed files:
- plugins/custom_forms/lib/custom_forms_plugin/graph.rb
- plugins/custom_forms/public/style.scss
- plugins/custom_forms/test/functional/custom_forms_plugin_profile_controller_test.rb
- plugins/custom_forms/views/custom_forms_plugin_myprofile/show_submission.html.erb
- + plugins/custom_forms/views/custom_forms_plugin_profile/_column.html.erb
- + plugins/custom_forms/views/custom_forms_plugin_profile/_pizza.html.erb
- + plugins/custom_forms/views/custom_forms_plugin_profile/_results_table.html.erb
- + plugins/custom_forms/views/custom_forms_plugin_profile/_text.html.erb
- plugins/custom_forms/views/custom_forms_plugin_profile/review.html.erb
Changes:
=====================================
plugins/custom_forms/lib/custom_forms_plugin/graph.rb
=====================================
--- a/plugins/custom_forms/lib/custom_forms_plugin/graph.rb
+++ b/plugins/custom_forms/lib/custom_forms_plugin/graph.rb
@@ -42,16 +42,10 @@ class CustomFormsPlugin::Graph
@query_results
end
- def show_as_pizza?(show_as)
- return true if ["radio", "select"].include? show_as
- end
-
- def show_as_column?(show_as)
- return true if ["check_box", "multiple_select"].include? show_as
- end
-
- def show_as_text?(show_as)
- return true if show_as == "text"
+ def exibition_method(show_as)
+ return 'pizza' if ["radio", "select"].include?(show_as)
+ return 'column' if ["check_box", "multiple_select"].include?(show_as)
+ return 'text' if show_as == 'text'
end
private
=====================================
plugins/custom_forms/public/style.scss
=====================================
--- a/plugins/custom_forms/public/style.scss
+++ b/plugins/custom_forms/public/style.scss
@@ -370,6 +370,11 @@ font-style: italic;
margin-bottom: 10px;
}
+ table.results-table {
+ position: absolute;
+ left: -100vw;
+ }
+
table.review_text_align {
td {
padding: 8px 4px;
=====================================
plugins/custom_forms/test/functional/custom_forms_plugin_profile_controller_test.rb
=====================================
--- a/plugins/custom_forms/test/functional/custom_forms_plugin_profile_controller_test.rb
+++ b/plugins/custom_forms/test/functional/custom_forms_plugin_profile_controller_test.rb
@@ -101,7 +101,9 @@ class CustomFormsPluginProfileControllerTest < ActionController::TestCase
get :review, :profile => profile.identifier, :id => form.identifier
assert_tag :tag => 'h4', :attributes => {:class => 'review_text_align'},
- :content => /What is your favorite food?/
+ :content => /What is your favorite food?/
+ assert_tag :tag => 'table', :attributes => { :class => 'results-table' },
+ :descendant => { :tag => 'td', :content => /bread/ }
end
should 'define filters default values' do
=====================================
plugins/custom_forms/views/custom_forms_plugin_myprofile/show_submission.html.erb
=====================================
--- a/plugins/custom_forms/views/custom_forms_plugin_myprofile/show_submission.html.erb
+++ b/plugins/custom_forms/views/custom_forms_plugin_myprofile/show_submission.html.erb
@@ -28,6 +28,7 @@
<% end %>
</tr>
<% @submission.q_and_a.each do |field, answer| %>
+ <% next unless answer.present? %>
<tr>
<th><%= sanitizer.sanitize field.name %></th>
<td><%=
=====================================
plugins/custom_forms/views/custom_forms_plugin_profile/_column.html.erb
=====================================
--- /dev/null
+++ b/plugins/custom_forms/views/custom_forms_plugin_profile/_column.html.erb
@@ -0,0 +1,7 @@
+<h4 id="<%= result['field'].to_slug %>" class="review_text_align">
+ <%= result['field'] %>
+</h4>
+
+<%= render partial: 'results_table', locals: { result: result } %>
+<%= column_chart result["data"],
+ summary: (result['summary'] if current_person.try(:can_see_summary?, profile)) %>
=====================================
plugins/custom_forms/views/custom_forms_plugin_profile/_pizza.html.erb
=====================================
--- /dev/null
+++ b/plugins/custom_forms/views/custom_forms_plugin_profile/_pizza.html.erb
@@ -0,0 +1,8 @@
+<h4 id="<%= result['field'].to_slug %>" class="review_text_align">
+ <%= result['field'] %>
+</h4>
+
+<%= render partial: 'results_table', locals: { result: result } %>
+
+<%= pie_chart result["data"], donut: true, legend: 'left',
+ summary: (result['summary'] if current_person.try(:can_see_summary?, profile)) %>
=====================================
plugins/custom_forms/views/custom_forms_plugin_profile/_results_table.html.erb
=====================================
--- /dev/null
+++ b/plugins/custom_forms/views/custom_forms_plugin_profile/_results_table.html.erb
@@ -0,0 +1,17 @@
+<table class="results-table" summary='<%= _('Answers') %>'>
+ <caption><%= _('Answers') % result['field'] %></caption>
+ <thead>
+ <tr>
+ <th><%= _('Alternative') %></th>
+ <th><%= _('Answers') %></th>
+ </tr>
+ </thead>
+ <tbody>
+ <% result['data'].each do |key, value| %>
+ <tr>
+ <td><%= key %></td>
+ <td><%= value %></td>
+ </tr>
+ <% end %>
+ </tbody>
+</table>
=====================================
plugins/custom_forms/views/custom_forms_plugin_profile/_text.html.erb
=====================================
--- /dev/null
+++ b/plugins/custom_forms/views/custom_forms_plugin_profile/_text.html.erb
@@ -0,0 +1,31 @@
+<table id="<%= result['field'].to_slug %>" class="review_text_align"
+ summary='<%= result['field'].to_slug %>'>
+
+ <caption><%= result['field'] %></caption>
+
+ <thead>
+ <tr>
+ <th> <%= _('User') %> </th>
+ <th> <%= _('Answer') %> </th>
+ </tr>
+ </thead>
+
+ <tbody>
+ <% result["data"]["answers"].each_with_index do |answer, index| %>
+ <tr>
+ <td class="review_text_align">
+ <%= result["data"]["users"][index] %>
+ <% if result["data"]["imported"][index] &&
+ current_person.try(:can_see_summary?, profile) %>
+ <span>*</span>
+ <% end %>
+ </td>
+ <td class="review_text_align"> <%= answer %> </td>
+ <tr>
+ <% end %>
+ </tbody>
+</table>
+
+<% if current_person.try(:can_see_summary?, profile) %>
+ <p>* <%= _('imported submissions') %></p>
+<% end %>
=====================================
plugins/custom_forms/views/custom_forms_plugin_profile/review.html.erb
=====================================
--- a/plugins/custom_forms/views/custom_forms_plugin_profile/review.html.erb
+++ b/plugins/custom_forms/views/custom_forms_plugin_profile/review.html.erb
@@ -30,59 +30,12 @@
</div>
<% else %>
<div>
- <% if @graph.show_as_pizza? result["show_as"] %>
- <h4 id="<%= result['field'].to_slug %>" class="review_text_align">
- <%= @fields[index].name %>
- </h4>
- <%= pie_chart result["data"], donut: true, legend: 'left',
- summary: (result['summary'] if current_person.try(:can_see_summary?, profile)) %>
+ <%= render partial: @graph.exibition_method(result['show_as']),
+ locals: { graph: @graph, result: result, index: index } %>
- <% if index < @query_results.size - 1 %>
- <hr>
- <br>
- <% end %>
- <% end %>
-
- <% if @graph.show_as_column? result["show_as"] %>
- <h4 id="<%= result['field'].to_slug %>" class="review_text_align">
- <%= @fields[index].name %>
- </h4>
- <%= column_chart result["data"],
- summary: (result['summary'] if current_person.try(:can_see_summary?, profile)) %>
- <% if index < @query_results.size - 1 %>
- <hr>
- <br>
- <% end %>
- <% end %>
-
- <% if @graph.show_as_text? result["show_as"] %>
- <table id="<%= result['field'].to_slug %>" class="review_text_align"
- summary='<%= @fields[index].name %>'>
- <caption><%= @fields[index].name %></caption>
- <thead>
- <tr>
- <th > User </th>
- <th> Answer </th>
- </tr>
- </thead>
- <tbody>
- <% result["data"]["answers"].each_with_index do |answer, index| %>
- <tr>
- <td class="review_text_align">
- <%= result["data"]["users"][index] %>
- <% if result["data"]["imported"][index] &&
- current_person.try(:can_see_summary?, profile) %>
- <span>*</span>
- <% end %>
- </td>
- <td class="review_text_align"> <%= answer %> </td>
- <tr>
- <% end %>
- </tbody>
- </table>
- <% if current_person.try(:can_see_summary?, profile) %>
- <p>* <%= _('imported submissions') %></p>
- <% end %>
+ <% if index < @query_results.size - 1 %>
+ <hr>
+ <br>
<% end %>
</div>
<% end %>
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/21ad07541dae6965f885fe6bcaa14d8ccf93bb03...fe5052fce08746be8d108a33d5d1f1c7c0dc05f5
---
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/21ad07541dae6965f885fe6bcaa14d8ccf93bb03...fe5052fce08746be8d108a33d5d1f1c7c0dc05f5
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20180323/6e1c8c7c/attachment-0001.html>
More information about the Noosfero-dev
mailing list