From ed84930283982062753e8fbd7323239d70dd1611 Mon Sep 17 00:00:00 2001 From: Shrey Date: Thu, 13 Aug 2015 16:53:05 +0530 Subject: [PATCH 1/1] UI changes + Redirection after creating report fixed (cherry picked from commit 987fcf0ba5e7e914dc479e9dc7613400e72148a0) --- app/controllers/issues_controller.rb | 17 ++++++++-------- app/models/notifier.rb | 6 +++++- app/views/browse/changeset.html.erb | 2 +- app/views/browse/note.html.erb | 2 +- app/views/diary_entry/_diary_comment.html.erb | 2 +- app/views/diary_entry/_diary_entry.html.erb | 2 +- app/views/issues/_comments.html.erb | 2 +- app/views/issues/_reports.html.erb | 12 +++++------ app/views/issues/index.html.erb | 4 ++-- app/views/issues/new.html.erb | 20 +++++++++---------- app/views/issues/show.html.erb | 17 ++++++++++------ .../notifier/new_issue_notification.html.erb | 1 + app/views/user/view.html.erb | 2 +- config/locales/en-GB.yml | 1 + config/locales/en.yml | 1 + 15 files changed, 50 insertions(+), 41 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 9b9dd7d3a..81bf7606c 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -75,6 +75,7 @@ class IssuesController < ApplicationController @issue = Issue.find_or_initialize_by(create_new_issue_params) path = 'issues.report_strings.' + @issue.reportable.class.name.to_s @report_strings_yaml = t(path) + flash[:referer] = params[:referer] end end @@ -90,12 +91,6 @@ class IssuesController < ApplicationController if @moderator_issues.include? @issue.reportable.class.name reassign_issue end - - @admins_or_mods = UserRole.where(role: @issue.issue_type) - @admins_or_mods.each do |user| - Notifier.new_issue_notification(User.find(user.user_id)).deliver_now - end - end # Check if details provided are sufficient @@ -115,7 +110,13 @@ class IssuesController < ApplicationController if @issue.save! @issue.report_count = @issue.reports.count @issue.save! - redirect_to root_path, notice: t('issues.create.successful_report') + + @admins_or_mods = UserRole.where(role: @issue.issue_type) + @admins_or_mods.each do |user| + Notifier.new_issue_notification(@issue.id, User.find(user.user_id)).deliver_now + end + + redirect_to flash[:referer], notice: t('issues.create.successful_report') end else redirect_to new_issue_path(reportable_type: @issue.reportable_type,reportable_id: @issue.reportable_id, reported_user_id: @issue.reported_user_id), notice: t('issues.create.provide_details') @@ -152,7 +153,7 @@ class IssuesController < ApplicationController if @report.save! @issue.report_count = @issue.reports.count @issue.save! - redirect_to root_path, notice: notice + redirect_to flash[:referer], notice: notice end else redirect_to new_issue_path(reportable_type: @issue.reportable_type,reportable_id: @issue.reportable_id, reported_user_id: @issue.reported_user_id), notice: t('issues.update.provide_details') diff --git a/app/models/notifier.rb b/app/models/notifier.rb index 13751560f..b3648aa5c 100644 --- a/app/models/notifier.rb +++ b/app/models/notifier.rb @@ -172,8 +172,12 @@ class Notifier < ActionMailer::Base end end - def new_issue_notification(recipient) + def new_issue_notification(issue_id,recipient) with_recipient_locale recipient do + @url = url_for(:host => SERVER_URL, + :controller => "issues", + :action => "show", + :id => issue_id) subject = I18n.t("notifier.new_issue_notification.subject") mail :to => recipient.email, :subject => subject end diff --git a/app/views/browse/changeset.html.erb b/app/views/browse/changeset.html.erb index 465bb2c4d..9fc7ec548 100644 --- a/app/views/browse/changeset.html.erb +++ b/app/views/browse/changeset.html.erb @@ -4,7 +4,7 @@ <%= t('browse.changeset.title', :id => @changeset.id) %> <% if @user and @user.id != @changeset.user.id %> - <%= link_to new_issue_url(reportable_id: @changeset.id, reportable_type: @changeset.class.name, reported_user_id: @changeset.user.id), :title => t('browse.changeset.report') do %> + <%= link_to new_issue_url(reportable_id: @changeset.id, reportable_type: @changeset.class.name, reported_user_id: @changeset.user.id,referer: request.fullpath), :title => t('browse.changeset.report') do %>  ⚐ <% end %> <% end %> diff --git a/app/views/browse/note.html.erb b/app/views/browse/note.html.erb index 2c7de0331..3c66482b3 100644 --- a/app/views/browse/note.html.erb +++ b/app/views/browse/note.html.erb @@ -4,7 +4,7 @@ <%= t "browse.note.#{@note.status}_title", :note_name => @note.id %> <% if @user and @user.id!=@note.author.id %> - <%= link_to new_issue_url(reportable_id: @note.id, reportable_type: @note.class.name, reported_user_id: @note.author.id), :title => t('browse.note.report') do %> + <%= link_to new_issue_url(reportable_id: @note.id, reportable_type: @note.class.name, reported_user_id: @note.author.id,referer: request.fullpath), :title => t('browse.note.report') do %>  ⚐ <% end %> <% end %> diff --git a/app/views/diary_entry/_diary_comment.html.erb b/app/views/diary_entry/_diary_comment.html.erb index b355c91ac..f5685b0cd 100644 --- a/app/views/diary_entry/_diary_comment.html.erb +++ b/app/views/diary_entry/_diary_comment.html.erb @@ -2,7 +2,7 @@ <%= user_thumbnail diary_comment.user %>

<%= raw(t('diary_entry.diary_comment.comment_from', :link_user => (link_to h(diary_comment.user.display_name), :controller => 'user', :action => 'view', :display_name => diary_comment.user.display_name), :comment_created_at => link_to(l(diary_comment.created_at, :format => :friendly), :anchor => "comment#{diary_comment.id}"))) %> <% if @user and diary_comment.user.id != @user.id %> - <%= link_to new_issue_url(reportable_id: diary_comment.id, reportable_type: diary_comment.class.name, reported_user_id: diary_comment.user.id), :title => t('diary_entry.diary_comment.report') do %> + <%= link_to new_issue_url(reportable_id: diary_comment.id, reportable_type: diary_comment.class.name, reported_user_id: diary_comment.user.id, referer: request.fullpath), :title => t('diary_entry.diary_comment.report') do %>  ⚐ <% end %> <% end %> diff --git a/app/views/diary_entry/_diary_entry.html.erb b/app/views/diary_entry/_diary_entry.html.erb index f9c094f2b..37a1bb15e 100644 --- a/app/views/diary_entry/_diary_entry.html.erb +++ b/app/views/diary_entry/_diary_entry.html.erb @@ -7,7 +7,7 @@

<%= link_to h(diary_entry.title), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id %>

<% if @user and diary_entry.user.id != @user.id %> - <%= link_to new_issue_url(reportable_id: diary_entry.id, reportable_type: diary_entry.class.name, reported_user_id: diary_entry.user.id), :title => t('diary_entry.diary_entry.report') do %> + <%= link_to new_issue_url(reportable_id: diary_entry.id, reportable_type: diary_entry.class.name, reported_user_id: diary_entry.user.id,referer: request.fullpath), :title => t('diary_entry.diary_entry.report') do %>  ⚐ <% end %> <% end %> diff --git a/app/views/issues/_comments.html.erb b/app/views/issues/_comments.html.erb index 52f740b09..0992388d0 100644 --- a/app/views/issues/_comments.html.erb +++ b/app/views/issues/_comments.html.erb @@ -13,7 +13,7 @@ <% end %> - On <%= l comment.created_at.to_datetime, :format => :long %> + On <%= l comment.created_at.to_datetime, :format => :friendly %>
<% end %> diff --git a/app/views/issues/_reports.html.erb b/app/views/issues/_reports.html.erb index 2aff5dbc9..3d31eeb1a 100644 --- a/app/views/issues/_reports.html.erb +++ b/app/views/issues/_reports.html.erb @@ -1,18 +1,16 @@ <% reports.each do |report| %> + <% details = report.details.split("--||--") %>
<%= link_to user_thumbnail(report.user), :controller => :user,:action =>:view, :display_name => report.user.display_name %>
- <%= link_to report.user.display_name, :controller => :user,:action =>:view, :display_name => report.user.display_name %>
- <% details = report.details.split("--||--") %> - - <%= details[1] %> + Reported as <%= details[1].delete('[').delete(']').downcase %> by <%= link_to report.user.display_name, :controller => :user,:action =>:view, :display_name => report.user.display_name %>
+ + On <%= l report.updated_at.to_datetime, :format => :friendly %> +
<%= details[0] %>
-
- - On <%= l report.created_at.to_datetime, :format => :long %>

<% end %> diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb index 374502c38..12cd79b37 100644 --- a/app/views/issues/index.html.erb +++ b/app/views/issues/index.html.erb @@ -32,9 +32,9 @@ <% @issues.each do |issue| %> - <%= issue.status %> + <%= issue.status.humanize %> <%= issue.report_count %> - <%= issue.updated_at.strftime('%H:%M %m/%d/%y') %> + <%= l(issue.updated_at.to_datetime, :format => :friendly) %> <% if issue.user_updated %> <%= issue.user_updated.display_name %> <% else %> - <% end %> <%= reports_url(issue) %> <%= link_to issue.user.display_name , :controller => :user, :action => :view,:display_name => issue.user.display_name %> diff --git a/app/views/issues/new.html.erb b/app/views/issues/new.html.erb index 4252b354f..a2f43e955 100644 --- a/app/views/issues/new.html.erb +++ b/app/views/issues/new.html.erb @@ -23,18 +23,16 @@

<%= t('issues.new.select') %>:

- <% @report_strings_yaml.each do |k,v| %> -
-
- <%= radio_button_tag :report_type, v[:type].to_s %> -
-
- <%= label_tag v[:details].to_s %>
-
-
-
- <% end %> +
+ <% @report_strings_yaml.each do |k,v| %> +
+ <%= radio_button_tag :report_type, v[:type].to_s %> + <%= label_tag v[:details].to_s %>
+
+ <% end %> +
+
<%= text_area :report, :details, :cols => 20, :rows => 3, placeholder: t('issues.new.details'), required: true %>
diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb index e64eb0e71..51e179da1 100644 --- a/app/views/issues/show.html.erb +++ b/app/views/issues/show.html.erb @@ -1,14 +1,17 @@ <% content_for :heading do %> -

Issue #<%= @issue.id %>
Status: <%= @issue. status %>

-

Issue against: <%= reportable_url(@issue.reportable) %>

-

Issue type: <%= @issue.reportable_type %>

+

<%= @issue.status.humanize %> Issue #<%= @issue.id %>

+

<%= @issue.reportable_type %> : <%= reportable_url(@issue.reportable) %>

- <%= @issue.reports.count %> reports | First reported: <%= l @issue.created_at.to_date, :format => :long %> <%= "| Last resolved at #{l(@issue.resolved_at.to_datetime, :format =>:long)}" if @issue.resolved_at? %> <%= "| Last updated at #{l(@issue.updated_at.to_datetime, :format => :long)} by #{@updated_by_admin.display_name}" if @updated_by_admin %> + <%= @issue.reports.count %> reports | First reported: <%= l @issue.created_at.to_datetime, :format => :friendly %> <%= "| Last resolved at #{l(@issue.resolved_at.to_datetime, :format =>:friendly)}" if @issue.resolved_at? %> <%= "| Last updated at #{l(@issue.updated_at.to_datetime, :format => :friendly)} by #{@updated_by_admin.display_name}" if @updated_by_admin %>

-

<%= link_to t('issues.resolve'), resolve_issue_url(@issue), :method => :post if @issue.may_resolve? %>

-

<%= link_to t('issues.ignore'), ignore_issue_url(@issue), :method => :post if @issue.may_ignore? %>

+

+ <%= link_to t('issues.resolve'), resolve_issue_url(@issue), :method => :post if @issue.may_resolve? %> + <% if @issue.may_ignore? %> + | <%= link_to t('issues.ignore'), ignore_issue_url(@issue), :method => :post %> + <% end %> +

<%= link_to t('issues.reopen'), reopen_issue_url(@issue), :method => :post if @issue.may_reopen? %>

<% end %> @@ -20,6 +23,7 @@ <% if @read_reports.present? %>

Read Reports:

+
<%= render 'reports',reports: @read_reports %>
<% end %> @@ -27,6 +31,7 @@ <% if @unread_reports.any? %>

New Reports:

+
<%= render 'reports',reports: @unread_reports %>
<% end %> diff --git a/app/views/notifier/new_issue_notification.html.erb b/app/views/notifier/new_issue_notification.html.erb index fbbfefede..b38dca4b7 100644 --- a/app/views/notifier/new_issue_notification.html.erb +++ b/app/views/notifier/new_issue_notification.html.erb @@ -2,3 +2,4 @@

<%= t("notifier.new_issue_notification.new_issue") %>

+

<%= link_to t("notifier.new_issue_notification.url"), @url %>

\ No newline at end of file diff --git a/app/views/user/view.html.erb b/app/views/user/view.html.erb index 1628e2364..5ff594dd1 100644 --- a/app/views/user/view.html.erb +++ b/app/views/user/view.html.erb @@ -155,7 +155,7 @@ <% if @user and @this_user.id != @user.id %>
- <%= link_to new_issue_url(reportable_id: @this_user.id, reportable_type: @this_user.class.name, reported_user_id: @this_user.id), :title => t('user.view.report') do%> + <%= link_to new_issue_url(reportable_id: @this_user.id, reportable_type: @this_user.class.name, reported_user_id: @this_user.id,referer: request.fullpath), :title => t('user.view.report') do%>  ⚐ <% end %>
diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml index 1c85d677f..f01cd3b0e 100644 --- a/config/locales/en-GB.yml +++ b/config/locales/en-GB.yml @@ -1470,6 +1470,7 @@ en-GB: subject: "[OpenStreetMap] New Issue" greeting: "Hi," new_issue: "A new issue has been created" + url: You can view the issue here message: inbox: title: Inbox diff --git a/config/locales/en.yml b/config/locales/en.yml index dd8815329..a4a0af329 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1438,6 +1438,7 @@ en: subject: "[OpenStreetMap] New Issue" greeting: "Hi," new_issue: "A new issue has been created" + url: You can view the issue here message: inbox: title: "Inbox" -- 2.43.2