Add a browse page for bugs

This commit is contained in:
Kai Krueger 2010-03-13 13:45:02 +00:00
parent c22958faed
commit 01aa270315
7 changed files with 122 additions and 3 deletions

View 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

View file

@ -49,4 +49,8 @@ class MapBug < ActiveRecord::Base
end
def visible
return status != "hidden"
end
end

View 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

View file

@ -40,6 +40,14 @@
$("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;

View file

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

View 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}}"

View 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'