Merge remote-tracking branch 'upstream/pull/2782'

This commit is contained in:
Tom Hughes 2020-08-19 17:31:56 +01:00
commit 5c551d475f
8 changed files with 135 additions and 150 deletions

View file

@ -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

View file

@ -2,22 +2,46 @@
<h1><%= t ".title" %></h1> <h1><%= t ".title" %></h1>
<% end %> <% end %>
<%= form_tag(issues_path, :method => :get, :class => "standard-form") do %>
<p><%= t ".search_guidance" %></p> <p><%= t ".search_guidance" %></p>
<%= select_tag :status, options_for_select(Issue.aasm.states.map(&:name).map { |state| [t(".states.#{state}"), state] }, params[:status]), :include_blank => t(".select_status"), :data => { :behavior => "category_dropdown" } %>
<%= select_tag :issue_type, options_for_select(@issue_types, params[:issue_type]), :include_blank => t(".select_type"), :data => { :behavior => "category_dropdown" } %> <%= form_tag(issues_path, :method => :get) do %>
<%= text_field_tag :search_by_user, params[:search_by_user], :placeholder => t(".reported_user") %> <div class="form-row">
<%= select_tag :last_updated_by, options_for_select(@users.all.collect { |f| [f.display_name, f.id] } << [t(".not_updated"), "nil"], params[:last_updated_by]), :include_blank => t(".select_last_updated_by"), :data => { :behavior => "category_dropdown" } %> <div class="form-group col-md-auto">
<%= submit_tag t(".search"), :name => nil %> <%= select_tag :status,
options_for_select(Issue.aasm.states.map(&:name).map { |state| [t(".states.#{state}"), state] }, params[:status]),
:include_blank => t(".select_status"),
:data => { :behavior => "category_dropdown" },
:class => "form-control custom-select" %>
</div>
<div class="form-group col-md-auto">
<%= select_tag :issue_type,
options_for_select(@issue_types, params[:issue_type]),
:include_blank => t(".select_type"),
:data => { :behavior => "category_dropdown" },
:class => "form-control custom-select" %>
</div>
<div class="form-group col-md">
<%= text_field_tag :search_by_user,
params[:search_by_user],
:placeholder => t(".reported_user"),
:class => "form-control" %>
</div>
<div class="form-group col-md-auto">
<%= select_tag :last_updated_by,
options_for_select(@users.all.collect { |f| [f.display_name, f.id] } << [t(".not_updated"), "nil"], params[:last_updated_by]),
:include_blank => t(".select_last_updated_by"),
:data => { :behavior => "category_dropdown" },
:class => "form-control custom-select" %>
</div>
<div class="form-group col-md-auto">
<%= submit_tag t(".search"), :name => nil, :class => "btn btn-primary" %>
</div>
</div>
<% end %> <% end %>
<br />
<% if @issues.length == 0 %> <% if @issues.length == 0 %>
<p><%= t ".issues_not_found" %></p> <p><%= t ".issues_not_found" %></p>
<% end %> <% else %>
<br />
<table class="table table-sm"> <table class="table table-sm">
<thead> <thead>
<tr> <tr>
@ -49,3 +73,4 @@
<% end %> <% end %>
</tbody> </tbody>
</table> </table>
<% end %>

View file

@ -1,29 +1,11 @@
<div class='standard-form'>
<fieldset>
<div class="standard-form-row">
<label class='standard-label' for="client_application_name"><%= t ".name" %> (<%= t ".required" %>)</label>
<%= f.text_field :name %> <%= f.text_field :name %>
</div>
<div class="standard-form-row">
<label class='standard-label' for="client_application_url"><%= t ".url" %> (<%= t ".required" %>)</label>
<%= f.text_field :url %> <%= f.text_field :url %>
</div>
<div class="standard-form-row">
<label class='standard-label' for="client_application_callback_url"><%= t ".callback_url" %></label>
<%= f.text_field :callback_url %> <%= f.text_field :callback_url %>
</div>
<div class="standard-form-row">
<label class='standard-label' for="client_application_support_url"><%= t ".support_url" %></label>
<%= f.text_field :support_url %> <%= f.text_field :support_url %>
</div> <div class='form-group'>
</fieldset>
<fieldset class='form-divider'>
<p><%= t ".requests" %></p> <p><%= t ".requests" %></p>
<% ClientApplication.all_permissions.each do |perm| %> <% ClientApplication.all_permissions.each do |perm| %>
<div class="standard-form-row">
<%= f.check_box perm %> <%= f.check_box perm %>
<label class='standard-label' for="client_application_<%= perm.to_s %>"><%= t("." + perm.to_s) %></label>
</div>
<% end %> <% end %>
</fieldset>
</div> </div>
<%= f.primary %>

View file

@ -2,7 +2,6 @@
<h1><%= t ".title" %></h1> <h1><%= t ".title" %></h1>
<% end %> <% end %>
<%= form_for @client_application, :url => oauth_client_path(@client_application.user.display_name, @client_application), :html => { :method => :put, :class => "standard-form" } do |f| %> <%= bootstrap_form_for @client_application, :url => oauth_client_path(@client_application.user.display_name, @client_application), :html => { :method => :put } do |f| %>
<%= render :partial => "form", :locals => { :f => f } %> <%= render :partial => "form", :locals => { :f => f } %>
<%= f.submit %>
<% end %> <% end %>

View file

@ -2,9 +2,6 @@
<h1><%= t ".title" %></h1> <h1><%= t ".title" %></h1>
<% end %> <% end %>
<div class='standard-form'> <%= bootstrap_form_for @client_application, :url => { :action => :create } do |f| %>
<%= form_for @client_application, :url => { :action => :create } do |f| %>
<%= render :partial => "form", :locals => { :f => f } %> <%= render :partial => "form", :locals => { :f => f } %>
<%= f.submit %>
<% end %> <% end %>
</div>

View file

@ -1,33 +1,31 @@
<% content_for :heading do %> <% content_for :heading do %>
<h1><%= t(".title", :app_name => @client_application.name) %></h1> <h1><%= t(".title", :app_name => @client_application.name) %></h1>
<% end %> <% end %>
<div class='prose'>
<p>
<strong><%= t ".key" %></strong> <%= @client_application.key %>
</p>
<p>
<strong><%= t ".secret" %></strong> <%= @client_application.secret %>
</p>
<p>
<strong><%= t ".url" %></strong> http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.request_token_path %>
</p>
<p>
<strong><%= t ".access_url" %></strong> http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.access_token_path %>
</p>
<p>
<strong><%= t ".authorize_url" %></strong> http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.authorize_path %>
</p>
<dl class="row">
<dt class="col-sm-3"><%= t ".key" %></dt>
<dd class="col-sm-9"><%= @client_application.key %></dt>
<dt class="col-sm-3"><%= t ".secret" %></dt>
<dd class="col-sm-9"><%= @client_application.secret %></dd>
<dt class="col-sm-3"><%= t ".url" %></dt>
<dd class="col-sm-9">http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.request_token_path %></dd>
<dt class="col-sm-3"><%= t ".access_url" %></dt>
<dd class="col-sm-9">http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.access_token_path %></dd>
<dt class="col-sm-3"><%= t ".authorize_url" %></dt>
<dd class="col-sm-9">http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.authorize_path %></dd>
</dl>
<div>
<p><%= t ".requests" %></p> <p><%= t ".requests" %></p>
<ul><% @client_application.permissions.each do |perm| %> <ul>
<div class="field"> <% @client_application.permissions.each do |perm| %>
<li><%= t("oauth_clients.form." + perm.to_s) %></li> <li><%= t("activerecord.attributes.client_application." + perm.to_s) %></li>
</div> <% end %>
<% end %></ul> </ul>
<p><%= t ".support_notice" %></p> <p><%= t ".support_notice" %></p>
</div> </div>
<div class="buttons standard-form">
<%= button_to t(".edit"), edit_oauth_client_path(@client_application.user.display_name, @client_application), :method => :get, :class => "oauth-edit" %> <div>
<%= button_to t(".delete"), oauth_client_path(@client_application.user.display_name, @client_application), :method => :delete, :data => { :confirm => t(".confirm") }, :class => "oauth-delete deemphasize" %> <%= link_to t(".edit"), edit_oauth_client_path(@client_application.user.display_name, @client_application), :method => :get, :class => "btn btn-outline-primary" %>
<%= link_to t(".delete"), oauth_client_path(@client_application.user.display_name, @client_application), :method => :delete, :data => { :confirm => t(".confirm") }, :class => "btn btn-outline-danger" %>
</div> </div>

View file

@ -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 %>

View file

@ -20,7 +20,7 @@ en:
create: Send create: Send
client_application: client_application:
create: Register create: Register
update: Edit update: Update
redaction: redaction:
create: Create redaction create: Create redaction
update: Save redaction update: Save redaction
@ -75,6 +75,18 @@ en:
# Translates all the model attributes, which is used in error handling on the web site # Translates all the model attributes, which is used in error handling on the web site
# Only the ones that are used on the web site are translated at the moment # Only the ones that are used on the web site are translated at the moment
attributes: attributes:
client_application:
name: Name (Required)
url: Main Application URL (Required)
callback_url: Callback URL
support_url: Support URL
allow_read_prefs: read their user preferences
allow_write_prefs: modify their user preferences
allow_write_diary: create diary entries, comments and make friends
allow_write_api: modify the map
allow_read_gpx: read their private GPS traces
allow_write_gpx: upload GPS traces
allow_write_notes: modify notes
diary_comment: diary_comment:
body: "Body" body: "Body"
diary_entry: diary_entry:
@ -104,6 +116,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"
@ -1299,8 +1314,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
@ -2153,13 +2166,6 @@ en:
delete: "Delete Client" delete: "Delete Client"
confirm: "Are you sure?" confirm: "Are you sure?"
requests: "Requesting the following permissions from the user:" requests: "Requesting the following permissions from the user:"
allow_read_prefs: "read their user preferences."
allow_write_prefs: "modify their user preferences."
allow_write_diary: "create diary entries, comments and make friends."
allow_write_api: "modify the map."
allow_read_gpx: "read their private GPS traces."
allow_write_gpx: "upload GPS traces."
allow_write_notes: "modify notes."
index: index:
title: "My OAuth Details" title: "My OAuth Details"
my_tokens: "My Authorised Applications" my_tokens: "My Authorised Applications"
@ -2173,19 +2179,7 @@ en:
registered_apps: "You have the following client applications registered:" registered_apps: "You have the following client applications registered:"
register_new: "Register your application" register_new: "Register your application"
form: form:
name: "Name"
required: "Required"
url: "Main Application URL"
callback_url: "Callback URL"
support_url: "Support URL"
requests: "Request the following permissions from the user:" requests: "Request the following permissions from the user:"
allow_read_prefs: "read their user preferences."
allow_write_prefs: "modify their user preferences."
allow_write_diary: "create diary entries, comments and make friends."
allow_write_api: "modify the map."
allow_read_gpx: "read their private GPS traces."
allow_write_gpx: "upload GPS traces."
allow_write_notes: "modify notes."
not_found: not_found:
sorry: "Sorry, that %{type} could not be found." sorry: "Sorry, that %{type} could not be found."
create: create: