Data browser changes, make links more user friendly, displaying name tag where possible.

Changes to models ok'd (and suggested as temporary solution) by TomH
References #1777
This commit is contained in:
Thomas Wood 2009-05-02 00:26:37 +00:00
parent 5b0e72ec71
commit 22292debda
15 changed files with 58 additions and 60 deletions

View file

@ -9,17 +9,10 @@ class BrowseController < ApplicationController
def relation
def relation
@relation = Relation.find(params[:id])
@name = @relation.tags['name'].to_s
if @name.length == 0:
@name = "#" + @relation.id.to_s
end
@title = 'Relation | ' + (@name)
@next = Relation.find(:first, :order => "id ASC", :conditions => [ "visible = true AND id > :id", { :id => @relation.id }] )
@prev = Relation.find(:first, :order => "id DESC", :conditions => [ "visible = true AND id < :id", { :id => @relation.id }] )
@next = Relation.find(:first, :order => "id ASC", :conditions => [ "visible = true AND id > :id", { :id => @relation.id }] )
@prev = Relation.find(:first, :order => "id DESC", :conditions => [ "visible = true AND id < :id", { :id => @relation.id }] )
rescue ActiveRecord::RecordNotFound
@type = "relation"
render :action => "not_found", :status => :not_found
@ -27,73 +20,38 @@ class BrowseController < ApplicationController
def relation_history
@relation = Relation.find(params[:id])
@name = @relation.tags['name'].to_s
if @name.length == 0:
@name = "#" + @relation.id.to_s
end
@title = 'Relation History | ' + (@name)
rescue ActiveRecord::RecordNotFound
@type = "relation"
render :action => "not_found", :status => :not_found
end
def way
def way
@way = Way.find(params[:id])
@name = @way.tags['name'].to_s
if @name.length == 0:
@name = "#" + @way.id.to_s
end
@title = 'Way | ' + (@name)
@next = Way.find(:first, :order => "id ASC", :conditions => [ "visible = true AND id > :id", { :id => @way.id }] )
@prev = Way.find(:first, :order => "id DESC", :conditions => [ "visible = true AND id < :id", { :id => @way.id }] )
@next = Way.find(:first, :order => "id ASC", :conditions => [ "visible = true AND id > :id", { :id => @way.id }] )
@prev = Way.find(:first, :order => "id DESC", :conditions => [ "visible = true AND id < :id", { :id => @way.id }] )
rescue ActiveRecord::RecordNotFound
@type = "way"
render :action => "not_found", :status => :not_found
end
def way_history
def way_history
@way = Way.find(params[:id])
@name = @way.tags['name'].to_s
if @name.length == 0:
@name = "#" + @way.id.to_s
end
@title = 'Way History | ' + (@name)
rescue ActiveRecord::RecordNotFound
@type = "way"
render :action => "not_found", :status => :not_found
end
def node
def node
@node = Node.find(params[:id])
@name = @node.tags_as_hash['name'].to_s
if @name.length == 0:
@name = "#" + @node.id.to_s
end
@title = 'Node | ' + (@name)
@next = Node.find(:first, :order => "id ASC", :conditions => [ "visible = true AND id > :id", { :id => @node.id }] )
@prev = Node.find(:first, :order => "id DESC", :conditions => [ "visible = true AND id < :id", { :id => @node.id }] )
@next = Node.find(:first, :order => "id ASC", :conditions => [ "visible = true AND id > :id", { :id => @node.id }] )
@prev = Node.find(:first, :order => "id DESC", :conditions => [ "visible = true AND id < :id", { :id => @node.id }] )
rescue ActiveRecord::RecordNotFound
@type = "node"
render :action => "not_found", :status => :not_found
end
def node_history
def node_history
@node = Node.find(params[:id])
@name = @node.tags_as_hash['name'].to_s
if @name.length == 0:
@name = "#" + @node.id.to_s
end
@title = 'Node History | ' + (@name)
rescue ActiveRecord::RecordNotFound
@type = "way"
render :action => "not_found", :status => :not_found

View file

@ -2,4 +2,15 @@ module BrowseHelper
def link_to_page(page, page_param)
return link_to(page, page_param => page)
end
def printable_name(object, version=false)
name = object.id.to_s
if version
name = "#{name}, v#{object.version.to_s}"
end
if object.tags.include? 'name'
name = "#{object.tags['name'].to_s} (#{name})"
end
return name
end
end

View file

@ -3,4 +3,6 @@ class OldRelationMember < ActiveRecord::Base
set_primary_keys :id, :version, :sequence_id
belongs_to :relation, :foreign_key=> :id
# A bit messy, referring to the current tables, should do for the data browser for now
belongs_to :member, :polymorphic => true
end

View file

@ -4,4 +4,7 @@ class OldWayNode < ActiveRecord::Base
set_primary_keys :id, :version, :sequence_id
belongs_to :way, :foreign_key=> :id
# A bit messy, referring to current nodes, should do for the data browser for now
belongs_to :node
end

View file

@ -53,7 +53,7 @@
<td>
<table cellpadding="0">
<% @nodes.each do |node| %>
<tr><td><%= link_to "Node #{node.id.to_s}, version #{node.version.to_s}", :action => "node", :id => node.id.to_s %></td></tr>
<tr><td><%= link_to h(printable_name(node, true)), :action => "node", :id => node.id.to_s %></td></tr>
<% end %>
</table>
</td>
@ -67,7 +67,7 @@
<td>
<table cellpadding="0">
<% @ways.each do |way| %>
<tr><td><%= link_to "Way #{way.id.to_s}, version #{way.version.to_s}", :action => "way", :id => way.id.to_s %></td></tr>
<tr><td><%= link_to h(printable_name(way, true)), :action => "way", :id => way.id.to_s %></td></tr>
<% end %>
<%=
#render :partial => "containing_relation", :collection => changeset_details.containing_relation_members
@ -84,7 +84,7 @@
<td>
<table cellpadding="0">
<% @relations.each do |relation| %>
<tr><td><%= link_to "Relation #{relation.id.to_s}, version #{relation.version.to_s}", :action => "relation", :id => relation.id.to_s %></td></tr>
<tr><td><%= link_to h(printable_name(relation, true)), :action => "relation", :id => relation.id.to_s %></td></tr>
<% end %>
</table>
</td>

View file

@ -1,6 +1,6 @@
<tr>
<td>
<%= link_to "Relation " + containing_relation.relation.id.to_s, :action => "relation", :id => containing_relation.relation.id.to_s %>
<%= link_to "Relation " + h(printable_name(containing_relation.relation)), :action => "relation", :id => containing_relation.relation.id.to_s %>
<% unless containing_relation.member_role.blank? %>
(as <%= h(containing_relation.member_role) %>)
<% end %>

View file

@ -8,7 +8,7 @@
<td>
<table cellpadding="0">
<% node_details.ways.each do |way| %>
<tr><td><%= link_to "Way " + way.id.to_s, :action => "way", :id => way.id.to_s %></td></tr>
<tr><td><%= link_to h(printable_name(way)), :action => "way", :id => way.id.to_s %></td></tr>
<% end %>
<%= render :partial => "containing_relation", :collection => node_details.containing_relation_members %>
</table>

View file

@ -1,7 +1,7 @@
<tr>
<td>
<%= relation_member.member_type.capitalize %>
<%= link_to relation_member.member_id.to_s, :action => relation_member.member_type.downcase, :id => relation_member.member_id %>
<%= link_to h(printable_name(relation_member.member)), :action => relation_member.member_type.downcase, :id => relation_member.member_id.to_s %>
<% unless relation_member.member_role.blank? %>
as
<%= h(relation_member.member_role) %>

View file

@ -7,7 +7,7 @@
<td>
<table cellpadding="0">
<% way_details.way_nodes.each do |wn| %>
<tr><td><%= link_to "Node " + wn.node_id.to_s, :action => "node", :id => wn.node_id.to_s %></td></tr>
<tr><td><%= link_to h(printable_name(wn.node)), :action => "node", :id => wn.node_id.to_s %></td></tr>
<% end %>
</table>
</td>

View file

@ -1,3 +1,7 @@
<%
@name = printable_name @node
@title = 'Node | ' + @name
%>
<table width="100%">
<tr>
<td>

View file

@ -1,3 +1,7 @@
<%
@name = printable_name @node
@title = 'Node History | ' + @name
%>
<h2>Node History: <%= h(@name) %></h2>
<table width="100%">

View file

@ -1,3 +1,7 @@
<%
@name = printable_name @relation
@title = 'Relation | ' + @name
%>
<table width="100%">
<tr>
<td>

View file

@ -1,3 +1,7 @@
<%
@name = printable_name @relation
@title = 'Relation History | ' + @name
%>
<h2>Relation History: <%= h(@name) %></h2>
<table width="100%">

View file

@ -1,3 +1,7 @@
<%
@name = printable_name @way
@title = 'Way | ' + @name
%>
<table width="100%">
<tr>
<td>

View file

@ -1,3 +1,7 @@
<%
@name = printable_name @way
@title = 'Way History | ' + @name
%>
<h2>Way History: <%= h(@name) %></h2>
<table width="100%">