]> git.openstreetmap.org Git - rails.git/commitdiff
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 9b9dd7d3aad2e0b0c4df16c3fd0d73d6d923b66c..81bf7606c3e715564433785f7900f0b2763f7e3e 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 13751560fbc7af6a12002b7b9ab4d26ab637a1a7..b3648aa5c618fea3c888255b1b0f73c5290d6e1b 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 465bb2c4ddfd4b006eeb61013a85d614b99dbdea..9fc7ec54878746a427da33ec49a54bea223d7c87 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 2c7de033199e2efe2c72e2dc277029b7461ae35b..3c66482b3339a0fb76e1404e7b956b316d0945ea 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 b355c91acb5deeb358de10f967a2301ea9a442c9..f5685b0cd3c1329a407739a89ca39c755ec6f253 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 f9c094f2b76060a03c00101709504da1dc82ac13..37a1bb15edd9f9fd962fa944eb826878fffd90fd 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 52f740b0967191576a4aec34e5960d09f0d6f29e..0992388d064c27ed28d3850ee569227ff5717537 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 2aff5dbc9a91d348bf7b646ee1df0be6e7914d6e..3d31eeb1a971f85aa41373785b6dfeda3281ee7f 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 374502c38d71d39cff117d5903815b302f6155e9..12cd79b376459fb86af7b7f1efaa8df1ab3653b3 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 4252b354fbd598ca530bba346021babc5d331f1a..a2f43e9553f3a01c07b90a2c5d0138f3b0026c35 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 e64eb0e718464bd9aa30cb5229b9858d09396c71..51e179da1de3770179ad6fa870d65fdb44f212d8 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 fbbfefedec5124830ad91a146655af46b26e8d07..b38dca4b75d6cfcc79242153d0ef7a38c872c33e 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 1628e2364967d267b3a58e78a595ad014ae1e0cf..5ff594dd14013da046d0b625d860f184486b3095 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 1c85d677ff534ba919fd87bfb748a85b66c35db5..f01cd3b0e09d613165cc19e3e3cff4fad3fd7559 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 dd8815329bd2925ed38ba73f1decf8cb720cf827..a4a0af3298d41b1595fe4c8c371f2e87ea7061fb 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"