Support the same edit params for Potlatch 1 and 2
Trac ticket 4587
This commit is contained in:
parent
8523f53099
commit
20e5f756be
4 changed files with 56 additions and 11 deletions
|
@ -39,6 +39,21 @@ class SiteController < ApplicationController
|
||||||
|
|
||||||
if editor == "remote"
|
if editor == "remote"
|
||||||
render :action => :index
|
render :action => :index
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if params[:node]
|
||||||
|
bbox = Node.find(params[:node]).bbox.to_unscaled
|
||||||
|
@lat = bbox.centre_lat
|
||||||
|
@lon = bbox.centre_lon
|
||||||
|
elsif params[:way]
|
||||||
|
bbox = Way.find(params[:way]).bbox.to_unscaled
|
||||||
|
@lat = bbox.centre_lat
|
||||||
|
@lon = bbox.centre_lon
|
||||||
|
elsif params[:gpx]
|
||||||
|
trace = Trace.find(params[:gpx])
|
||||||
|
@lat = trace.latitude
|
||||||
|
@lon = trace.longitude
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,12 @@
|
||||||
// 700,600 for fixed size, 100%,100% for resizable
|
// 700,600 for fixed size, 100%,100% for resizable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<% if @lat && @lon -%>
|
||||||
|
doSWF(<%= @lat %>,<%= @lon %>,16);
|
||||||
|
<% else -%>
|
||||||
var params = OSM.mapParams();
|
var params = OSM.mapParams();
|
||||||
doSWF(params.lat, params.lon, params.zoom || 17);
|
doSWF(params.lat, params.lon, params.zoom || 17);
|
||||||
|
<% end -%>
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$("body").on("click", "a.set_position", function () {
|
$("body").on("click", "a.set_position", function () {
|
||||||
|
|
|
@ -63,15 +63,8 @@
|
||||||
// 700,600 for fixed size, 100%,100% for resizable
|
// 700,600 for fixed size, 100%,100% for resizable
|
||||||
}
|
}
|
||||||
|
|
||||||
<% if params[:node] -%>
|
<% if @lat && @lon -%>
|
||||||
<% bbox = Node.find(params[:node]).bbox.to_unscaled -%>
|
doSWF(<%= @lat %>,<%= @lon %>,16);
|
||||||
doSWF(<%= bbox.centre_lat %>,<%= bbox.centre_lon %>,16);
|
|
||||||
<% elsif params[:way] -%>
|
|
||||||
<% bbox = Way.find(params[:way]).bbox.to_unscaled -%>
|
|
||||||
doSWF(<%= bbox.centre_lat %>,<%= bbox.centre_lon %>,16);
|
|
||||||
<% elsif params[:gpx] -%>
|
|
||||||
<% trace = Trace.find(params[:gpx]) -%>
|
|
||||||
doSWF(<%= trace.latitude %>,<%= trace.longitude %>,16);
|
|
||||||
<% else -%>
|
<% else -%>
|
||||||
var params = OSM.mapParams();
|
var params = OSM.mapParams();
|
||||||
doSWF(params.lat, params.lon, params.zoom || 17);
|
doSWF(params.lat, params.lon, params.zoom || 17);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require File.dirname(__FILE__) + '/../test_helper'
|
require File.dirname(__FILE__) + '/../test_helper'
|
||||||
|
|
||||||
class SiteControllerTest < ActionController::TestCase
|
class SiteControllerTest < ActionController::TestCase
|
||||||
fixtures :users
|
api_fixtures
|
||||||
|
|
||||||
##
|
##
|
||||||
# test all routes which lead to this controller
|
# test all routes which lead to this controller
|
||||||
|
@ -118,5 +118,38 @@ class SiteControllerTest < ActionController::TestCase
|
||||||
get(:edit, nil, { 'user' => user.id })
|
get(:edit, nil, { 'user' => user.id })
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template "index"
|
assert_template "index"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_edit_with_node
|
||||||
|
@request.cookies["_osm_username"] = users(:public_user).display_name
|
||||||
|
|
||||||
|
user = users(:public_user)
|
||||||
|
node = current_nodes(:visible_node)
|
||||||
|
|
||||||
|
get :edit, { :node => node.id }, { 'user' => user.id }
|
||||||
|
assert_equal 1.0, assigns(:lat)
|
||||||
|
assert_equal 1.0, assigns(:lon)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_edit_with_way
|
||||||
|
@request.cookies["_osm_username"] = users(:public_user).display_name
|
||||||
|
|
||||||
|
user = users(:public_user)
|
||||||
|
way = current_ways(:visible_way)
|
||||||
|
|
||||||
|
get :edit, { :way => way.id }, { 'user' => user.id }
|
||||||
|
assert_equal 3.0, assigns(:lat)
|
||||||
|
assert_equal 3.0, assigns(:lon)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_edit_with_gpx
|
||||||
|
@request.cookies["_osm_username"] = users(:public_user).display_name
|
||||||
|
|
||||||
|
user = users(:public_user)
|
||||||
|
gpx = gpx_files(:public_trace_file)
|
||||||
|
|
||||||
|
get :edit, { :gpx => gpx.id }, { 'user' => user.id }
|
||||||
|
assert_equal 1.0, assigns(:lat)
|
||||||
|
assert_equal 1.0, assigns(:lon)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue