From: Christopher Schmidt Date: Sun, 20 Apr 2008 21:44:05 +0000 (+0000) Subject: add navigation link X-Git-Tag: live~7715^2~34 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/4ca38904dc11fa7329e186bd675e15e3c401ca86 add navigation link --- diff --git a/app/controllers/browse_controller.rb b/app/controllers/browse_controller.rb index 97daaa268..3ecec6348 100644 --- a/app/controllers/browse_controller.rb +++ b/app/controllers/browse_controller.rb @@ -16,6 +16,8 @@ class BrowseController < ApplicationController 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 }] ) rescue ActiveRecord::RecordNotFound render :nothing => true, :status => :not_found end @@ -46,6 +48,8 @@ class BrowseController < ApplicationController 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 }] ) rescue ActiveRecord::RecordNotFound render :nothing => true, :status => :not_found end @@ -76,6 +80,8 @@ class BrowseController < ApplicationController 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 }] ) rescue ActiveRecord::RecordNotFound render :nothing => true, :status => :not_found end diff --git a/app/views/browse/_navigation.rhtml b/app/views/browse/_navigation.rhtml new file mode 100644 index 000000000..269184e02 --- /dev/null +++ b/app/views/browse/_navigation.rhtml @@ -0,0 +1,13 @@ +
+<% if @prev %> +< +<%= link_to @prev.id.to_s, :action => type, :id => @prev.id %> +<% end %> +<% if @prev and @next %> +| +<% end %> +<% if @next %> +<%= link_to @next.id.to_s, :action => type, :id => @next.id %> +> +<% end %> +
diff --git a/app/views/browse/node.rhtml b/app/views/browse/node.rhtml index fcfd7cfd7..c050cf002 100644 --- a/app/views/browse/node.rhtml +++ b/app/views/browse/node.rhtml @@ -1,3 +1,4 @@ +<%= render :partial => 'navigation', :locals => { :type => "node" } %>

Node Browser: <%= h(@name) %>

<%= render :partial => 'common', :locals => { :obj => @node, :type => "node" } %> <%= render :partial => 'tag_table', :locals => { :tags => @node.tags_as_hash } %> diff --git a/app/views/browse/relation.rhtml b/app/views/browse/relation.rhtml index 5dc06f10a..574a4ea2b 100644 --- a/app/views/browse/relation.rhtml +++ b/app/views/browse/relation.rhtml @@ -1,3 +1,4 @@ +<%= render :partial => 'navigation', :locals => { :type => "relation" } %>

Relation Browser: <%= h(@name) %>

<%= render :partial => 'common', :locals => { :obj => @relation, :type => "relation" } %> <%= render :partial => 'tag_table', :locals => { :tags => @relation.tags } %> diff --git a/app/views/browse/way.rhtml b/app/views/browse/way.rhtml index c12a422cb..e1c306071 100644 --- a/app/views/browse/way.rhtml +++ b/app/views/browse/way.rhtml @@ -1,3 +1,4 @@ +<%= render :partial => 'navigation', :locals => { :type => "way" } %>

Way Browser: <%= h(@name) %>

<%= render :partial => 'common', :locals => { :obj => @way, :type => "way" } %> <%= render :partial => 'tag_table', :locals => { :tags => @way.tags } %>