UI changes + Redirection after creating report fixed

(cherry picked from commit 987fcf0ba5e7e914dc479e9dc7613400e72148a0)
This commit is contained in:
Shrey 2015-08-13 16:53:05 +05:30 committed by Matt Amos
parent eb79b15681
commit ed84930283
15 changed files with 50 additions and 41 deletions

View file

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

View file

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

View file

@ -4,7 +4,7 @@
<a class="geolink" href="<%= root_path %>"><span class="icon close"></span></a>
<%= 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 %>
&nbsp;&#9872;
<% end %>
<% end %>

View file

@ -4,7 +4,7 @@
<a class="geolink" href="<%= root_path %>"><span class="icon close"></span></a>
<%= 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 %>
&nbsp;&#9872;
<% end %>
<% end %>

View file

@ -2,7 +2,7 @@
<%= user_thumbnail diary_comment.user %>
<p class="deemphasize comment-heading" id="comment<%= diary_comment.id %>"><%= 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 %>
&nbsp;&#9872;
<% end %>
<% end %>

View file

@ -7,7 +7,7 @@
<h2><%= link_to h(diary_entry.title), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id %></h2>
<% 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 %>
&nbsp;&#9872;
<% end %>
<% end %>

View file

@ -13,7 +13,7 @@
<% end %>
</div>
<span class="deemphasize">
On <%= l comment.created_at.to_datetime, :format => :long %> </span>
On <%= l comment.created_at.to_datetime, :format => :friendly %> </span>
<hr>
<% end %>
</div>

View file

@ -1,18 +1,16 @@
<% reports.each do |report| %>
<% details = report.details.split("--||--") %>
<div class="reports">
<div style="float:left">
<%= link_to user_thumbnail(report.user), :controller => :user,:action =>:view, :display_name => report.user.display_name %>
</div>
<b><%= link_to report.user.display_name, :controller => :user,:action =>:view, :display_name => report.user.display_name %></b> <br/>
<% details = report.details.split("--||--") %>
<label>Tag:</label>
<%= details[1] %>
Reported as <b><%= details[1].delete('[').delete(']').downcase %></b> by <b><%= link_to report.user.display_name, :controller => :user,:action =>:view, :display_name => report.user.display_name %></b> <br/>
<span class="deemphasize">
On <%= l report.updated_at.to_datetime, :format => :friendly %>
</span>
<br/>
<%= details[0] %>
<br/>
<br/>
<span class="deemphasize">
On <%= l report.created_at.to_datetime, :format => :long %> </span>
</div>
<hr>
<% end %>

View file

@ -32,9 +32,9 @@
<tbody>
<% @issues.each do |issue| %>
<tr>
<td><span class="count-number"> <strong><%= issue.status %></strong></span> </td>
<td><%= issue.status.humanize %></td>
<td><%= issue.report_count %></td>
<td><%= issue.updated_at.strftime('%H:%M %m/%d/%y') %></td>
<td><%= l(issue.updated_at.to_datetime, :format => :friendly) %></td>
<td><% if issue.user_updated %> <%= issue.user_updated.display_name %> <% else %> - <% end %></td>
<td> <%= reports_url(issue) %></td>
<td><%= link_to issue.user.display_name , :controller => :user, :action => :view,:display_name => issue.user.display_name %></td>

View file

@ -23,18 +23,16 @@
<div class='form-row' style='width:600px'>
<p><%= t('issues.new.select') %>:</p>
<% @report_strings_yaml.each do |k,v| %>
<div class="new-report-form">
<div class="new-report-checkbox">
<%= radio_button_tag :report_type, v[:type].to_s %>
</div>
<div class="new-report-string">
<%= label_tag v[:details].to_s %> <br/>
</div>
</div>
<br/>
<% end %>
<div class="new-report-form">
<% @report_strings_yaml.each do |k,v| %>
<div style="padding-left:5px">
<%= radio_button_tag :report_type, v[:type].to_s %>
<%= label_tag v[:details].to_s %> <br/>
</div>
<% end %>
</div>
<br/>
<%= text_area :report, :details, :cols => 20, :rows => 3, placeholder: t('issues.new.details'), required: true %>
</div>

View file

@ -1,14 +1,17 @@
<% content_for :heading do %>
<h2> Issue #<%= @issue.id %> <br/> <span class="count-number">Status: <strong><%= @issue. status %></strong></span></h2>
<p>Issue against: <%= reportable_url(@issue.reportable) %></p>
<p>Issue type: <%= @issue.reportable_type %></p>
<h2> <%= @issue.status.humanize %> Issue #<%= @issue.id %> <br/></h2>
<p><%= @issue.reportable_type %> : <%= reportable_url(@issue.reportable) %></p>
<p class="deemphasize">
<small>
<%= @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 %>
</small>
</p>
<p><%= link_to t('issues.resolve'), resolve_issue_url(@issue), :method => :post if @issue.may_resolve? %></p>
<p><%= link_to t('issues.ignore'), ignore_issue_url(@issue), :method => :post if @issue.may_ignore? %></p>
<p>
<%= 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 %>
</p>
<p><%= link_to t('issues.reopen'), reopen_issue_url(@issue), :method => :post if @issue.may_reopen? %></p>
<% end %>
@ -20,6 +23,7 @@
<% if @read_reports.present? %>
<div class="read-reports">
<h4>Read Reports:</h4>
<br/>
<%= render 'reports',reports: @read_reports %>
</div>
<% end %>
@ -27,6 +31,7 @@
<% if @unread_reports.any? %>
<div class="unread-reports">
<h4>New Reports:</h4>
<br/>
<%= render 'reports',reports: @unread_reports %>
</div>
<% end %>

View file

@ -2,3 +2,4 @@
<p><%= t("notifier.new_issue_notification.new_issue") %></p>
<p><%= link_to t("notifier.new_issue_notification.url"), @url %></p>

View file

@ -155,7 +155,7 @@
<% if @user and @this_user.id != @user.id %>
<div class="report-button">
<%= 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%>
&nbsp;&#9872;
<% end %>
</div>

View file

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

View file

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