]> git.openstreetmap.org Git - rails.git/commitdiff
add navigation link
authorChristopher Schmidt <crschmidt@crschmidt.net>
Sun, 20 Apr 2008 21:44:05 +0000 (21:44 +0000)
committerChristopher Schmidt <crschmidt@crschmidt.net>
Sun, 20 Apr 2008 21:44:05 +0000 (21:44 +0000)
app/controllers/browse_controller.rb
app/views/browse/_navigation.rhtml [new file with mode: 0644]
app/views/browse/node.rhtml
app/views/browse/relation.rhtml
app/views/browse/way.rhtml

index 97daaa268d844527b40b5a895d20f1d20dfdd8aa..3ecec6348a35363ea9ba58a9ea2749f48bed0420 100644 (file)
@@ -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 (file)
index 0000000..269184e
--- /dev/null
@@ -0,0 +1,13 @@
+<div style="float:right; text-align:center; width: 250px;">
+<% 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 %>
+</div>
index fcfd7cfd7fbbe6fa3b022eaf9ffafa8df840578f..c050cf00269983835f7239282494d05c4014eb49 100644 (file)
@@ -1,3 +1,4 @@
+<%= render :partial => 'navigation', :locals => { :type => "node" } %>
 <h2>Node Browser: <%= h(@name) %></h2>
 <%= render :partial => 'common', :locals => { :obj => @node, :type => "node" } %>
 <%= render :partial => 'tag_table', :locals => { :tags => @node.tags_as_hash } %>
index 5dc06f10a45a9afdba479e03bde50b67fcc32b8b..574a4ea2b66b9715f3d757f3ce0b81757b805bfa 100644 (file)
@@ -1,3 +1,4 @@
+<%= render :partial => 'navigation', :locals => { :type => "relation" } %>
 <h2>Relation Browser: <%= h(@name) %></h2>
 <%= render :partial => 'common', :locals => { :obj => @relation, :type => "relation" } %>
 <%= render :partial => 'tag_table', :locals => { :tags => @relation.tags } %>
index c12a422cb97da4fc9bd2018006f1ec5927b964f3..e1c306071549ab3e5e6ab82ca7b530abbef8961c 100644 (file)
@@ -1,3 +1,4 @@
+<%= render :partial => 'navigation', :locals => { :type => "way" } %>
 <h2>Way Browser: <%= h(@name) %></h2>
 <%= render :partial => 'common', :locals => { :obj => @way, :type => "way" } %>
 <%= render :partial => 'tag_table', :locals => { :tags => @way.tags } %>