Refactor reports form to use bootstrap
This commit is contained in:
parent
c3435167b9
commit
8df3010766
3 changed files with 20 additions and 29 deletions
|
@ -1,5 +1,14 @@
|
||||||
|
require "ostruct"
|
||||||
|
|
||||||
module ReportsHelper
|
module ReportsHelper
|
||||||
def report_link(name, reportable)
|
def report_link(name, reportable)
|
||||||
link_to name, new_report_url(:reportable_id => reportable.id, :reportable_type => reportable.class.name)
|
link_to name, new_report_url(:reportable_id => reportable.id, :reportable_type => reportable.class.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Convert a list of strings into objects with methods that the collection_radio_buttons helper expects
|
||||||
|
def report_categories(reportable)
|
||||||
|
Report.categories_for(reportable).map do |c|
|
||||||
|
OpenStruct.new(:id => c, :label => t(".categories.#{reportable.class.name.underscore}.#{c}_label"))
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,32 +11,13 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= form_for(@report) do |f| %>
|
<%= bootstrap_form_for(@report) do |f| %>
|
||||||
<%= f.error_messages %>
|
|
||||||
<fieldset class="standard-form">
|
|
||||||
<%= f.fields_for @report.issue do |issue_form| %>
|
<%= f.fields_for @report.issue do |issue_form| %>
|
||||||
<%= issue_form.hidden_field :reportable_id %>
|
<%= issue_form.hidden_field :reportable_id %>
|
||||||
<%= issue_form.hidden_field :reportable_type %>
|
<%= issue_form.hidden_field :reportable_type %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class='standard-form-row'>
|
<%= f.collection_radio_buttons :category, report_categories(@report.issue.reportable), :id, :label %>
|
||||||
<p><%= t(".select") %></p>
|
<%= f.text_area :details, :rows => 5, :label_as_placeholder => true %>
|
||||||
<ul class="form-list">
|
<%= f.primary %>
|
||||||
<% Report.categories_for(@report.issue.reportable).each do |c| %>
|
|
||||||
<li>
|
|
||||||
<%= radio_button :report, :category, c, :required => true %>
|
|
||||||
<%= label_tag "report_category_#{c}", t(".categories.#{@report.issue.reportable.class.name.underscore}.#{c}_label") %>
|
|
||||||
</li>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class='standard-form-row'>
|
|
||||||
<%= text_area :report, :details, :cols => 20, :rows => 5, :placeholder => t(".details") %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class='buttons'>
|
|
||||||
<%= f.submit %>
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -104,6 +104,9 @@ en:
|
||||||
title: "Subject"
|
title: "Subject"
|
||||||
body: "Body"
|
body: "Body"
|
||||||
recipient: "Recipient"
|
recipient: "Recipient"
|
||||||
|
report:
|
||||||
|
category: Select a reason for your report
|
||||||
|
details: Please provide some more details about the problem (required).
|
||||||
user:
|
user:
|
||||||
email: "Email"
|
email: "Email"
|
||||||
active: "Active"
|
active: "Active"
|
||||||
|
@ -1118,8 +1121,6 @@ en:
|
||||||
new:
|
new:
|
||||||
title_html: "Report %{link}"
|
title_html: "Report %{link}"
|
||||||
missing_params: "Cannot create a new report"
|
missing_params: "Cannot create a new report"
|
||||||
details: Please provide some more details about the problem (required).
|
|
||||||
select: "Select a reason for your report:"
|
|
||||||
disclaimer:
|
disclaimer:
|
||||||
intro: "Before sending your report to the site moderators, please ensure that:"
|
intro: "Before sending your report to the site moderators, please ensure that:"
|
||||||
not_just_mistake: You are certain that the problem is not just a mistake
|
not_just_mistake: You are certain that the problem is not just a mistake
|
||||||
|
|
Loading…
Add table
Reference in a new issue