Tidy up some of the map bugs code
This commit is contained in:
parent
e7cd90f4b4
commit
fb4d003ebe
11 changed files with 149 additions and 154 deletions
|
@ -38,12 +38,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 = "";
|
||||
<% elsif map.instance_of? MapBug %>
|
||||
var centre = new OpenLayers.LonLat(<%= map.lon %>, <%= map.lat %>);
|
||||
var zoom = 16;
|
||||
setMapCenter(centre, zoom);
|
||||
marker = addMarkerToMap(centre);
|
||||
|
||||
setMapCenter(centre, 16);
|
||||
addMarkerToMap(centre);
|
||||
|
||||
$("loading").innerHTML = "";
|
||||
|
||||
$("area_larger_map").href = '/?mlon=<%= map.lon %>&mlat=<%=map.lat %>';
|
||||
$("area_larger_map").innerHTML = "<%= t 'browse.map.larger.area' %>";
|
||||
<% else %>
|
||||
|
@ -77,7 +79,7 @@
|
|||
$("small_map").style.display = "none";
|
||||
}
|
||||
});
|
||||
<% end end %>
|
||||
<% end %>
|
||||
}
|
||||
|
||||
window.onload = init;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<div id="permalink">
|
||||
<a href="/" id="permalinkanchor"><%= t 'site.index.permalink' %></a><br/>
|
||||
<a href="/" id="shortlinkanchor"><%= t 'site.index.shortlink' %></a><br/>
|
||||
<a href="javascript:void();" id="ReportBug" class="reportProblem">Report a problem</a>
|
||||
<a href="#" id="reportbuganchor">Report a problem</a>
|
||||
</div>
|
||||
|
||||
<div id="attribution">
|
||||
|
@ -143,33 +143,22 @@ end
|
|||
|
||||
map.osbLayer = new OpenLayers.Layer.OpenStreetBugs("OpenStreetBugs", {
|
||||
serverURL: "/api/0.6/",
|
||||
iconOpen : new OpenLayers.Icon("/images/open_bug_marker.png", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)),
|
||||
iconClosed : new OpenLayers.Icon("/images/closed_bug_marker.png", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)),
|
||||
iconOpen: new OpenLayers.Icon("<%= image_path "open_bug_marker.png" %>", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)),
|
||||
iconClosed: new OpenLayers.Icon("<%= image_path "closed_bug_marker.png" %>", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)),
|
||||
readonly: false,
|
||||
setCookie: false,
|
||||
cookieLifetime : 1000,
|
||||
cookiePath : "/my/map/",
|
||||
permalinkURL: "http://www.openstreetmap.org/",
|
||||
theme : "/stylesheets/openstreetbugs.css",
|
||||
theme: "<%= stylesheet_path "openstreetbugs" %>",
|
||||
visibility: false
|
||||
});
|
||||
|
||||
map.addLayer(map.osbLayer);
|
||||
|
||||
map.osbControl = new OpenLayers.Control.OpenStreetBugs(map.osbLayer);
|
||||
|
||||
map.addControl(map.osbControl);
|
||||
|
||||
var lBug = document.getElementById('ReportBug');
|
||||
/* lBug.addEventListener('click',function (e) {
|
||||
map.osbControl.activate(); document.getElementById("OpenLayers.Map_18_OpenLayers_Container").style.cursor = "crosshair" },false); */
|
||||
lBug.addEventListener('click',function (e) {
|
||||
map.osbControl.activate(); map.osbControl.addTemporaryMarker(map.getCenter());},false);
|
||||
|
||||
map.events.register("zoomend",map,function () { var zoom = map.getZoom(); var lBug = document.getElementById('ReportBug')
|
||||
if (zoom > 11) { lBug.style.visibility = 'visible';} else {lBug.style.visibility = "hidden";}});
|
||||
|
||||
$("reportbuganchor").observe("click", addBug);
|
||||
|
||||
map.events.register("zoomend", map, allowBugReports);
|
||||
<% end %>
|
||||
|
||||
<% unless object_zoom %>
|
||||
|
@ -333,6 +322,19 @@ end
|
|||
<% end %>
|
||||
}
|
||||
|
||||
function addBug() {
|
||||
map.osbControl.activate();
|
||||
map.osbControl.addTemporaryMarker(map.getCenter());
|
||||
}
|
||||
|
||||
function allowBugReports() {
|
||||
if (map.getZoom() > 11) {
|
||||
$("reportbuganchor").style.visibility = "visible";
|
||||
} else {
|
||||
$("reportbuganchor").style.visibility = "hidden";
|
||||
}
|
||||
}
|
||||
|
||||
mapInit();
|
||||
|
||||
Event.observe(window, "load", installEditHandler);
|
||||
|
|
|
@ -82,7 +82,6 @@ ActionController::Routing::Routes.draw do |map|
|
|||
map.connect "api/#{API_VERSION}/bugs/editPOIexec", :controller => 'map_bugs', :action => 'edit_bug'
|
||||
map.connect "api/#{API_VERSION}/bugs/getGPX", :controller => 'map_bugs', :action => 'gpx_bugs'
|
||||
map.connect "api/#{API_VERSION}/bugs/getRSSfeed", :controller => 'map_bugs', :action => 'rss'
|
||||
|
||||
map.connect "api/#{API_VERSION}/bugs", :controller => 'map_bugs', :action => 'get_bugs'
|
||||
map.connect "api/#{API_VERSION}/bugs/search", :controller => 'map_bugs', :action => 'search'
|
||||
map.connect "api/#{API_VERSION}/bugs/rss", :controller =>'map_bugs', :action => 'rss'
|
||||
|
@ -92,10 +91,6 @@ ActionController::Routing::Routes.draw do |map|
|
|||
map.connect "api/#{API_VERSION}/bug/:id", :controller => 'map_bugs', :action => 'read', :id => /\d+/, :conditions => { :method => :get }
|
||||
map.connect "api/#{API_VERSION}/bug/:id", :controller => 'map_bugs', :action => 'delete', :id => /\d+/, :conditions => { :method => :delete }
|
||||
|
||||
map.connect '/user/:display_name/bugs', :controller => 'map_bugs', :action => 'my_bugs'
|
||||
|
||||
|
||||
|
||||
# Data browsing
|
||||
map.connect '/browse/start', :controller => 'browse', :action => 'start'
|
||||
map.connect '/browse/way/:id', :controller => 'browse', :action => 'way', :id => /\d+/
|
||||
|
@ -110,6 +105,7 @@ ActionController::Routing::Routes.draw do |map|
|
|||
map.connect '/browse/changesets/feed', :controller => 'changeset', :action => 'list', :format => :atom
|
||||
map.connect '/browse/changesets', :controller => 'changeset', :action => 'list'
|
||||
map.connect '/browse/bug/:id', :controller => 'browse', :action => 'bug', :id => /\d+/
|
||||
map.connect '/user/:display_name/bugs', :controller => 'map_bugs', :action => 'my_bugs'
|
||||
map.connect '/browse', :controller => 'changeset', :action => 'list'
|
||||
|
||||
# web site
|
||||
|
|
|
@ -2,7 +2,6 @@ require 'lib/migrate'
|
|||
|
||||
class AddMapBugTables < ActiveRecord::Migration
|
||||
def self.up
|
||||
|
||||
create_enumeration :map_bug_status_enum, ["open", "closed", "hidden"]
|
||||
|
||||
create_table :map_bugs do |t|
|
||||
|
@ -15,7 +14,6 @@ class AddMapBugTables < ActiveRecord::Migration
|
|||
t.string :nearby_place
|
||||
t.string :text
|
||||
t.column :status, :map_bug_status_enum, :null => false
|
||||
|
||||
end
|
||||
|
||||
add_index :map_bugs, [:tile, :status], :name => "map_bugs_tile_idx"
|
||||
|
@ -27,7 +25,9 @@ class AddMapBugTables < ActiveRecord::Migration
|
|||
remove_index :map_bugs, :name => "map_bugs_tile_idx"
|
||||
remove_index :map_bugs, :name => "map_bugs_changed_idx"
|
||||
remove_index :map_bugs, :name => "map_bugs_created_idx"
|
||||
|
||||
drop_table :map_bugs
|
||||
|
||||
drop_enumeration :map_bug_status_enum
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,8 +2,6 @@ require 'lib/migrate'
|
|||
|
||||
class RefactorMapBugTables < ActiveRecord::Migration
|
||||
def self.up
|
||||
|
||||
|
||||
create_table :map_bug_comment do |t|
|
||||
t.column :id, :bigint, :null => false
|
||||
t.column :bug_id, :bigint, :null => false
|
||||
|
@ -18,19 +16,19 @@ class RefactorMapBugTables < ActiveRecord::Migration
|
|||
remove_column :map_bugs, :text
|
||||
|
||||
add_index :map_bug_comment, [:bug_id], :name => "map_bug_comment_id_idx"
|
||||
|
||||
add_foreign_key :map_bug_comment, [:bug_id], :map_bugs, [:id]
|
||||
add_foreign_key :map_bug_comment, [:commenter_id], :users, [:id]
|
||||
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_foreign_key :map_bug_comment, [:commenter_id]
|
||||
remove_foreign_key :map_bug_comment, [:bug_id]
|
||||
|
||||
remove_index :map_bugs, :name => "map_bug_comment_id_idx"
|
||||
|
||||
add_column :map_bugs, :text, :string
|
||||
|
||||
remove_index :map_bugs, :name => "map_bug_comment_id_idx"
|
||||
remove_foreign_key :map_bug_comment, [:bug_id]
|
||||
remove_foreign_key :map_bug_comment, [:commenter_id]
|
||||
|
||||
drop_table :map_bugs_comment
|
||||
drop_table :map_bug_comment
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,12 +2,10 @@ require 'lib/migrate'
|
|||
|
||||
class AddDateClosed < ActiveRecord::Migration
|
||||
def self.up
|
||||
|
||||
add_column :map_bugs, :date_closed, :timestamp
|
||||
end
|
||||
|
||||
def self.down
|
||||
|
||||
remove_column :map_bugs, :date_closed
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,12 +3,13 @@ require 'lib/migrate'
|
|||
class AddMapBugCommentEvent < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_enumeration :map_bug_event_enum, ["opened", "closed", "reopened", "commented", "hidden"]
|
||||
|
||||
add_column :map_bug_comment, :event, :map_bug_event_enum
|
||||
end
|
||||
|
||||
def self.down
|
||||
|
||||
remove_column :map_bug_comment, :event
|
||||
|
||||
drop_enumeration :map_bug_event_enum
|
||||
end
|
||||
end
|
||||
|
|
|
@ -54,6 +54,7 @@ private
|
|||
return self.find(:all, options)
|
||||
end
|
||||
end
|
||||
|
||||
def find_by_area_no_quadtile(minlat, minlon, maxlat, maxlon, options)
|
||||
self.with_scope(:find => {:conditions => OSM.sql_for_area_no_quadtile(minlat, minlon, maxlat, maxlon)}) do
|
||||
return self.find(:all, options)
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
display: none;
|
||||
}
|
||||
|
||||
a.reportProblem {
|
||||
/* Rules for map bug reporting */
|
||||
|
||||
#reportbuganchor {
|
||||
font-size: 150%;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ class MapBugsControllerTest < ActionController::TestCase
|
|||
assert_match "\"status\":\"open\"", js
|
||||
assert_match "\"comment\":\"This is an additional comment\"", js
|
||||
assert_match "\"commenter_name\":\"new_tester2 (a)\"", js
|
||||
|
||||
end
|
||||
|
||||
def test_map_bug_read_success
|
||||
|
@ -134,7 +133,6 @@ class MapBugsControllerTest < ActionController::TestCase
|
|||
|
||||
get :my_bugs, {:display_name=>'non-existent'}
|
||||
assert_response :not_found
|
||||
|
||||
end
|
||||
|
||||
def test_map_bug_comment_create_not_found
|
||||
|
@ -168,7 +166,4 @@ class MapBugsControllerTest < ActionController::TestCase
|
|||
assert_match "\"comment\":\"Another valid comment for bug 5\"", js
|
||||
assert_no_match /\"comment\":\"Spam for bug 5\"/, js
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue