UI changes + Redirection after creating report fixed
authorShrey <shrey14099@iiitd.ac.in>
Thu, 13 Aug 2015 11:23:05 +0000 (16:53 +0530)
committerMatt Amos <zerebubuth@gmail.com>
Mon, 22 Aug 2016 15:18:15 +0000 (16:18 +0100)
(cherry picked from commit 987fcf0ba5e7e914dc479e9dc7613400e72148a0)

15 files changed:
app/controllers/issues_controller.rb
app/models/notifier.rb
app/views/browse/changeset.html.erb
app/views/browse/note.html.erb
app/views/diary_entry/_diary_comment.html.erb
app/views/diary_entry/_diary_entry.html.erb
app/views/issues/_comments.html.erb
app/views/issues/_reports.html.erb
app/views/issues/index.html.erb
app/views/issues/new.html.erb
app/views/issues/show.html.erb
app/views/notifier/new_issue_notification.html.erb
app/views/user/view.html.erb
config/locales/en-GB.yml
config/locales/en.yml

index 9b9dd7d..81bf760 100644 (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')
index 1375156..b3648aa 100644 (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
index 465bb2c..9fc7ec5 100644 (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 %>
index 2c7de03..3c66482 100644 (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 %>
index b355c91..f5685b0 100644 (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 %>
index f9c094f..37a1bb1 100644 (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 %>
index 52f740b..0992388 100644 (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>
index 2aff5db..3d31eeb 100644 (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 %>
index 374502c..12cd79b 100644 (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>
index 4252b35..a2f43e9 100644 (file)
             <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>
 
index e64eb0e..51e179d 100644 (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 %>       
index fbbfefe..b38dca4 100644 (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>
\ No newline at end of file
index 1628e23..5ff594d 100644 (file)
 
     <% 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>
index 1c85d67..f01cd3b 100644 (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
index dd88153..a4a0af3 100644 (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"