Add a browse page for bugs
authorKai Krueger <kakrueger@gmail.com>
Sat, 13 Mar 2010 13:45:02 +0000 (13:45 +0000)
committerKai Krueger <kakrueger@gmail.com>
Sat, 13 Mar 2010 13:45:02 +0000 (13:45 +0000)
app/controllers/browse_controller.rb
app/models/map_bug.rb
app/models/map_bug_comment.rb
app/views/browse/_map.html.erb
app/views/browse/bug.html.erb [new file with mode: 0644]
config/locales/en.yml
config/routes.rb

index a77b0f9..cb866eb 100644 (file)
@@ -78,6 +78,15 @@ class BrowseController < ApplicationController
     render :action => "not_found", :status => :not_found
   end
 
+  def bug
+    @type = "bug"
+    @bug = MapBug.find(params[:id])
+    @next = MapBug.find(:first, :order => "id ASC", :conditions => [ "status != 'hidden' AND id > :id", { :id => @bug.id }] )
+    @prev = MapBug.find(:first, :order => "id DESC", :conditions => [ "status != 'hidden' AND id < :id", { :id => @bug.id }] )
+  rescue ActiveRecord::RecordNotFound
+    render :action => "not_found", :status => :not_found
+  end
+
 private
 
   def timeout
index 18e6ab2..74b6b31 100644 (file)
@@ -49,4 +49,8 @@ class MapBug < ActiveRecord::Base
 
   end
 
+  def visible
+       return status != "hidden"
+  end
+
 end
index 9839cae..945b1b2 100644 (file)
@@ -3,8 +3,7 @@ class MapBugComment < ActiveRecord::Base
   set_table_name 'map_bug_comment'
 
   belongs_to :map_bug, :foreign_key => 'bug_id'
-  
-  
+  belongs_to :user, :foreign_key => 'commenter_id'
 
   validates_presence_of :id, :on => :update
   validates_uniqueness_of :id
index 5bb83b6..5d72858 100644 (file)
 
         $("area_larger_map").href = '/?minlon='+minlon+'&minlat='+minlat+'&maxlon='+maxlon+'&maxlat='+maxlat+'&box=yes';
         $("area_larger_map").innerHTML = "<%= t 'browse.map.larger.area' %>";
+      <% else if map.instance_of? MapBug %>
+               $("loading").innerHTML = "";
+               var centre = new OpenLayers.LonLat(<%= map.lon %>, <%= map.lat %>);
+        var zoom = 16;
+        setMapCenter(centre, zoom);
+               marker = addMarkerToMap(centre);
+               $("area_larger_map").href = '/?mlon=<%= map.lon %>&mlat=<%=map.lat %>';
+        $("area_larger_map").innerHTML = "<%= t 'browse.map.larger.area' %>";
       <% else %>
         var obj_type = "<%= map.class.name.downcase %>";
         var obj_id = <%= map.id %>;
@@ -66,7 +74,7 @@
             $("small_map").style.display = "none";
           }
         });
-      <% end %>
+      <% end end %>
     }
 
     window.onload = init;
diff --git a/app/views/browse/bug.html.erb b/app/views/browse/bug.html.erb
new file mode 100644 (file)
index 0000000..5c65b3e
--- /dev/null
@@ -0,0 +1,87 @@
+<table width="100%">
+  <tr>
+    <td width="100%">
+      <h2>
+               <% if @bug.status == "closed" %>
+                       <%= image_tag("closed_bug_marker.png", :alt => 'closed') %>
+                       <%= t'browse.bug.closed_title', :bug_name => @bug.id %>
+               <% else %>
+                       <%= image_tag("open_bug_marker.png", :alt => 'open') %>
+                       <%=     t'browse.bug.open_title', :bug_name => @bug.id %>
+               <% end %>
+               </h2>
+    </td>
+    <td>
+      <%= render :partial => "navigation" %>
+    </td>
+  </tr>
+  <tr valign="top">
+    <td>
+               <table>
+                       <tr>
+                           <th><%= t 'browse.bug.created_at' %></th>
+                           <td><%= l @bug.date_created %></td>
+                       </tr>  
+                       
+                       <tr>
+                               <th><%= t 'browse.bug.edited_at' %></th>
+                               <td><%= l @bug.last_changed %></td>
+                       </tr>
+                       <% if @bug.status == "closed" %>
+                       <tr>
+                           <th><%= t 'browse.bug.closed_at' %></th>
+                           <td><%= l @bug.date_closed %></td>
+                       </tr>
+                       <% end %>
+                       <tr>
+                               <th><%= t 'browse.bug.opened_by' %></th>
+                               <% if @bug.map_bug_comment[0].user.nil? %>
+                                       <td> <%= @bug.map_bug_comment[0].commenter_name %> </td>
+                               <% else %>
+                                       <td><%= link_to h(@bug.map_bug_comment[0].user.display_name), :controller => "user", :action => "view", :display_name => @bug.map_bug_comment[0].user.display_name %></td>                                      
+                               <% end %>
+                       </tr>
+                       <tr>
+                               <th><%= t 'browse.bug.description' %></th>
+                               <td><%= h(@bug.map_bug_comment[0].comment) %></td>
+                       </tr>
+
+                       <tr>
+                               <th><%= t 'browse.node_details.coordinates' %></th>
+                               <td><div class="geo"><%= link_to ("<span class='latitude'>#{number_with_delimiter(@bug.lat)}</span>, <span class='longitude'>#{number_with_delimiter(@bug.lon)}</span>"), {:controller => 'site', :action => 'index', :lat => h(@bug.lat), :lon => h(@bug.lon), :zoom => "18"} %></div></td>
+                               </tr>
+
+               </table>
+
+               <br>
+
+       <%if @bug.map_bug_comment.length > 1 %>
+
+               <table>
+                       <tr>
+                               <th width="20%"> <%= t 'browse.bug.comment_by' %></th> <th width="60%"> <%= t 'browse.bug.comment' %></th> <th width="20%"> <%= t 'browse.bug.date' %></th> 
+                       </tr>
+                       <% @bug.map_bug_comment[1..-1].each do |bug_comment| %>
+                               <tr>
+                                       
+                                       <td>
+                                               <% if bug_comment.user.nil? %>
+                                                       <%= bug_comment.commenter_name %>
+                                               <% else %>
+                                                       <%= link_to h(bug_comment.user.display_name), :controller => "user", :action => "view", :display_name => bug_comment.user.display_name %>                                       
+                                               <% end %>
+                                       </td>
+                                       <td> <%= h(bug_comment.comment) %> </td>
+                                       <td> <%= l bug_comment.date_created %> </td>
+                               </tr>
+                       <% end %>
+               </table>
+
+       <% end %>
+       
+      <hr />
+      
+    </td>
+    <%= render :partial => "map", :object => @bug %>
+  </tr>
+</table>
\ No newline at end of file
index af50662..7df9bd3 100644 (file)
@@ -249,6 +249,17 @@ en:
       download_xml: "Download XML"
       view_history: "view history"
       edit: "edit"
+    bug:
+      open_title: "Unresolved issue: {{bug_name}}"
+      closed_title: "Resolved issue: {{bug_name}}"
+      created_at: "Created at:"
+      edited_at: "Edited at:"
+      closed_at: "Closed at:"
+      opened_by: "Opened by:"
+      description: "Description:"
+      comment_by: "Comment by: "
+      comment: "Comment:"
+      date: "Date:"
   changeset:
     changeset_paging_nav: 
       showing_page: "Showing page {{page}}"
index 52d4f41..cadf376 100644 (file)
@@ -92,6 +92,7 @@ ActionController::Routing::Routes.draw do |map|
   map.changeset '/browse/changeset/:id', :controller => 'browse', :action => 'changeset', :id => /\d+/
   map.connect '/browse/changesets', :controller => 'changeset', :action => 'list'
   map.connect '/browse/changesets/feed', :controller => 'changeset', :action => 'list', :format => :atom
+  map.connect '/browse/bug/:id', :controller => 'browse', :action => 'bug', :id => /\d+/
   
   # web site
   map.root :controller => 'site', :action => 'index'