From: Tom Hughes Date: Wed, 19 Aug 2020 16:31:56 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/pull/2782' X-Git-Tag: live~3035 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/5c551d475fa2e055e4b644c26bd7ca8f99b748a1?hp=e6afac351fe1658e8eee17321bad154e4e707e91 Merge remote-tracking branch 'upstream/pull/2782' --- diff --git a/app/helpers/reports_helper.rb b/app/helpers/reports_helper.rb index 70c9adac6..f9cc99621 100644 --- a/app/helpers/reports_helper.rb +++ b/app/helpers/reports_helper.rb @@ -1,5 +1,14 @@ +require "ostruct" + module ReportsHelper def report_link(name, reportable) link_to name, new_report_url(:reportable_id => reportable.id, :reportable_type => reportable.class.name) 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 diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb index 1500a3647..9fd8f1167 100644 --- a/app/views/issues/index.html.erb +++ b/app/views/issues/index.html.erb @@ -2,50 +2,75 @@

<%= t ".title" %>

<% end %> -<%= form_tag(issues_path, :method => :get, :class => "standard-form") do %>

<%= t ".search_guidance" %>

-<%= 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" } %> -<%= text_field_tag :search_by_user, params[:search_by_user], :placeholder => t(".reported_user") %> -<%= 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" } %> -<%= submit_tag t(".search"), :name => nil %> + +<%= form_tag(issues_path, :method => :get) do %> +
+
+ <%= 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" %> +
+
+ <%= 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" %> +
+
+ <%= text_field_tag :search_by_user, + params[:search_by_user], + :placeholder => t(".reported_user"), + :class => "form-control" %> +
+
+ <%= 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" %> +
+
+ <%= submit_tag t(".search"), :name => nil, :class => "btn btn-primary" %> +
+
<% end %> -
<% if @issues.length == 0 %>

<%= t ".issues_not_found" %>

-<% end %> - -
- - - - - - - - - - - - - <% @issues.each do |issue| %> +<% else %> +
<%= t ".status" %><%= t ".reports" %><%= t ".reported_item" %><%= t ".reported_user" %><%= t ".last_updated" %>
+ - - - - - + + + + + - <% end %> - -
<%= t ".states.#{issue.status}" %><%= link_to t(".reports_count", :count => issue.reports_count), issue %><%= link_to reportable_title(issue.reportable), reportable_url(issue.reportable) %><%= link_to issue.reported_user.display_name, user_path(issue.reported_user) if issue.reported_user %> - <% if issue.user_updated %> - <%= t ".last_updated_time_user_html", :user => link_to(issue.user_updated.display_name, user_path(issue.user_updated)), - :time => time_ago_in_words(issue.updated_at, :scope => :'datetime.distance_in_words_ago'), - :title => l(issue.updated_at) %> - <% else %> - <%= t ".last_updated_time_html", :time => time_ago_in_words(issue.updated_at, :scope => :'datetime.distance_in_words_ago'), - :title => l(issue.updated_at) %> - <% end %> - <%= t ".status" %><%= t ".reports" %><%= t ".reported_item" %><%= t ".reported_user" %><%= t ".last_updated" %>
+ + + <% @issues.each do |issue| %> + + <%= t ".states.#{issue.status}" %> + <%= link_to t(".reports_count", :count => issue.reports_count), issue %> + <%= link_to reportable_title(issue.reportable), reportable_url(issue.reportable) %> + <%= link_to issue.reported_user.display_name, user_path(issue.reported_user) if issue.reported_user %> + + <% if issue.user_updated %> + <%= t ".last_updated_time_user_html", :user => link_to(issue.user_updated.display_name, user_path(issue.user_updated)), + :time => time_ago_in_words(issue.updated_at, :scope => :'datetime.distance_in_words_ago'), + :title => l(issue.updated_at) %> + <% else %> + <%= t ".last_updated_time_html", :time => time_ago_in_words(issue.updated_at, :scope => :'datetime.distance_in_words_ago'), + :title => l(issue.updated_at) %> + <% end %> + + + <% end %> + + +<% end %> diff --git a/app/views/oauth_clients/_form.html.erb b/app/views/oauth_clients/_form.html.erb index 4c4b2c519..455450412 100644 --- a/app/views/oauth_clients/_form.html.erb +++ b/app/views/oauth_clients/_form.html.erb @@ -1,29 +1,11 @@ -
-
-
- - <%= f.text_field :name %> -
-
- - <%= f.text_field :url %> -
-
- - <%= f.text_field :callback_url %> -
-
- - <%= f.text_field :support_url %> -
-
-
-

<%= t ".requests" %>

- <% ClientApplication.all_permissions.each do |perm| %> -
- <%= f.check_box perm %> - -
- <% end %> -
+<%= f.text_field :name %> +<%= f.text_field :url %> +<%= f.text_field :callback_url %> +<%= f.text_field :support_url %> +
+

<%= t ".requests" %>

+ <% ClientApplication.all_permissions.each do |perm| %> + <%= f.check_box perm %> + <% end %>
+<%= f.primary %> diff --git a/app/views/oauth_clients/edit.html.erb b/app/views/oauth_clients/edit.html.erb index 551bb68fc..f31063ae0 100644 --- a/app/views/oauth_clients/edit.html.erb +++ b/app/views/oauth_clients/edit.html.erb @@ -2,7 +2,6 @@

<%= t ".title" %>

<% 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 } %> - <%= f.submit %> <% end %> diff --git a/app/views/oauth_clients/new.html.erb b/app/views/oauth_clients/new.html.erb index d9cc05d02..7b4ea5bb0 100644 --- a/app/views/oauth_clients/new.html.erb +++ b/app/views/oauth_clients/new.html.erb @@ -2,9 +2,6 @@

<%= t ".title" %>

<% end %> -
- <%= form_for @client_application, :url => { :action => :create } do |f| %> - <%= render :partial => "form", :locals => { :f => f } %> - <%= f.submit %> - <% end %> -
+<%= bootstrap_form_for @client_application, :url => { :action => :create } do |f| %> + <%= render :partial => "form", :locals => { :f => f } %> +<% end %> diff --git a/app/views/oauth_clients/show.html.erb b/app/views/oauth_clients/show.html.erb index 19c1d9f6e..5f828a057 100644 --- a/app/views/oauth_clients/show.html.erb +++ b/app/views/oauth_clients/show.html.erb @@ -1,33 +1,31 @@ <% content_for :heading do %>

<%= t(".title", :app_name => @client_application.name) %>

<% end %> -
-

- <%= t ".key" %> <%= @client_application.key %> -

-

- <%= t ".secret" %> <%= @client_application.secret %> -

-

- <%= t ".url" %> http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.request_token_path %> -

-

- <%= t ".access_url" %> http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.access_token_path %> -

-

- <%= t ".authorize_url" %> http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.authorize_path %> -

-

<%= t ".requests" %>

-
    <% @client_application.permissions.each do |perm| %> -
    -
  • <%= t("oauth_clients.form." + perm.to_s) %>
  • -
    - <% end %>
+
+
<%= t ".key" %>
+
<%= @client_application.key %> +
<%= t ".secret" %>
+
<%= @client_application.secret %>
+
<%= t ".url" %>
+
http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.request_token_path %>
+
<%= t ".access_url" %>
+
http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.access_token_path %>
+
<%= t ".authorize_url" %>
+
http<%= "s" if request.ssl? %>://<%= request.host_with_port %><%= @client_application.oauth_server.authorize_path %>
+
+
+

<%= t ".requests" %>

+
    + <% @client_application.permissions.each do |perm| %> +
  • <%= t("activerecord.attributes.client_application." + perm.to_s) %>
  • + <% end %> +

<%= t ".support_notice" %>

-
- <%= button_to t(".edit"), edit_oauth_client_path(@client_application.user.display_name, @client_application), :method => :get, :class => "oauth-edit" %> - <%= 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" %>
diff --git a/app/views/reports/new.html.erb b/app/views/reports/new.html.erb index a29104ae7..6c12c14e3 100644 --- a/app/views/reports/new.html.erb +++ b/app/views/reports/new.html.erb @@ -11,32 +11,13 @@
-<%= form_for(@report) do |f| %> - <%= f.error_messages %> -
- <%= f.fields_for @report.issue do |issue_form| %> - <%= issue_form.hidden_field :reportable_id %> - <%= issue_form.hidden_field :reportable_type %> - <% end %> +<%= bootstrap_form_for(@report) do |f| %> + <%= f.fields_for @report.issue do |issue_form| %> + <%= issue_form.hidden_field :reportable_id %> + <%= issue_form.hidden_field :reportable_type %> + <% end %> -
-

<%= t(".select") %>

-
    - <% Report.categories_for(@report.issue.reportable).each do |c| %> -
  • - <%= radio_button :report, :category, c, :required => true %> - <%= label_tag "report_category_#{c}", t(".categories.#{@report.issue.reportable.class.name.underscore}.#{c}_label") %> -
  • - <% end %> -
-
- -
- <%= text_area :report, :details, :cols => 20, :rows => 5, :placeholder => t(".details") %> -
- -
- <%= f.submit %> -
-
+ <%= f.collection_radio_buttons :category, report_categories(@report.issue.reportable), :id, :label %> + <%= f.text_area :details, :rows => 5, :label_as_placeholder => true %> + <%= f.primary %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index f416f3259..e142a6d4d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -20,7 +20,7 @@ en: create: Send client_application: create: Register - update: Edit + update: Update redaction: create: Create redaction update: Save redaction @@ -75,6 +75,18 @@ en: # 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 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: body: "Body" diary_entry: @@ -104,6 +116,9 @@ en: title: "Subject" body: "Body" recipient: "Recipient" + report: + category: Select a reason for your report + details: Please provide some more details about the problem (required). user: email: "Email" active: "Active" @@ -1299,8 +1314,6 @@ en: new: title_html: "Report %{link}" 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: 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 @@ -2153,13 +2166,6 @@ en: delete: "Delete Client" confirm: "Are you sure?" 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: title: "My OAuth Details" my_tokens: "My Authorised Applications" @@ -2173,19 +2179,7 @@ en: registered_apps: "You have the following client applications registered:" register_new: "Register your application" 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:" - 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: sorry: "Sorry, that %{type} could not be found." create: