From 01aa27031526280d8b1d219902a7b4c97617d19f Mon Sep 17 00:00:00 2001 From: Kai Krueger Date: Sat, 13 Mar 2010 13:45:02 +0000 Subject: [PATCH] Add a browse page for bugs --- app/controllers/browse_controller.rb | 9 +++ app/models/map_bug.rb | 4 ++ app/models/map_bug_comment.rb | 3 +- app/views/browse/_map.html.erb | 10 +++- app/views/browse/bug.html.erb | 87 ++++++++++++++++++++++++++++ config/locales/en.yml | 11 ++++ config/routes.rb | 1 + 7 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 app/views/browse/bug.html.erb diff --git a/app/controllers/browse_controller.rb b/app/controllers/browse_controller.rb index a77b0f94a..cb866eb3f 100644 --- a/app/controllers/browse_controller.rb +++ b/app/controllers/browse_controller.rb @@ -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 diff --git a/app/models/map_bug.rb b/app/models/map_bug.rb index 18e6ab270..74b6b3191 100644 --- a/app/models/map_bug.rb +++ b/app/models/map_bug.rb @@ -49,4 +49,8 @@ class MapBug < ActiveRecord::Base end + def visible + return status != "hidden" + end + end diff --git a/app/models/map_bug_comment.rb b/app/models/map_bug_comment.rb index 9839cae45..945b1b2f7 100644 --- a/app/models/map_bug_comment.rb +++ b/app/models/map_bug_comment.rb @@ -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 diff --git a/app/views/browse/_map.html.erb b/app/views/browse/_map.html.erb index 5bb83b6bf..5d7285840 100644 --- a/app/views/browse/_map.html.erb +++ b/app/views/browse/_map.html.erb @@ -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; diff --git a/app/views/browse/bug.html.erb b/app/views/browse/bug.html.erb new file mode 100644 index 000000000..5c65b3e41 --- /dev/null +++ b/app/views/browse/bug.html.erb @@ -0,0 +1,87 @@ + + + + + + + + <%= render :partial => "map", :object => @bug %> + +
+

+ <% 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 %> +

+
+ <%= render :partial => "navigation" %> +
+ + + + + + + + + + + <% if @bug.status == "closed" %> + + + + + <% end %> + + + <% if @bug.map_bug_comment[0].user.nil? %> + + <% else %> + + <% end %> + + + + + + + + + + + +
<%= t 'browse.bug.created_at' %><%= l @bug.date_created %>
<%= t 'browse.bug.edited_at' %><%= l @bug.last_changed %>
<%= t 'browse.bug.closed_at' %><%= l @bug.date_closed %>
<%= t 'browse.bug.opened_by' %> <%= @bug.map_bug_comment[0].commenter_name %> <%= 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 %>
<%= t 'browse.bug.description' %><%= h(@bug.map_bug_comment[0].comment) %>
<%= t 'browse.node_details.coordinates' %>
<%= link_to ("#{number_with_delimiter(@bug.lat)}, #{number_with_delimiter(@bug.lon)}"), {:controller => 'site', :action => 'index', :lat => h(@bug.lat), :lon => h(@bug.lon), :zoom => "18"} %>
+ +
+ + <%if @bug.map_bug_comment.length > 1 %> + + + + + + <% @bug.map_bug_comment[1..-1].each do |bug_comment| %> + + + + + + + <% end %> +
<%= t 'browse.bug.comment_by' %> <%= t 'browse.bug.comment' %> <%= t 'browse.bug.date' %>
+ <% 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 %> + <%= h(bug_comment.comment) %> <%= l bug_comment.date_created %>
+ + <% end %> + +
+ +
\ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index af506627c..7df9bd373 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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}}" diff --git a/config/routes.rb b/config/routes.rb index 52d4f413d..cadf37625 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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' -- 2.43.2