Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Ticket #100. Menu problem in admin site

  • Loading branch information...
commit 4c7b56ee75bf6bbba461554ff6d14982a241e7b5 1 parent 9d4b12b
@salicio salicio authored
View
1  CHANGELOG.md
@@ -1,5 +1,6 @@
Edge
----
+* Ticket #100. Menu problem in admin site
* Ticket #99. Link to commentable in comment notification mail
0.3.0
View
2  app/helpers/interface_helper.rb
@@ -24,7 +24,7 @@ def links_for_navigation(section)
end
def nav_link_to(tab)
- if current_url?(tab.url)
+ if tab.include_url?(request.request_uri)
content_tag(:li, %{#{link_to tab.name, tab.url} #{sub_nav_links_to(tab.items)}}, :class=>"on")
else
content_tag(:li, link_to(tab.name, tab.url))
View
32 app/models/tog/interface.rb
@@ -5,7 +5,7 @@ def self.sections(section=:site)
case section
when :site
@site_tabset ||= TabSet.new
- when :member
+ when :member
@member_tabset ||= TabSet.new
when :admin
@admin_tabset ||= TabSet.new
@@ -14,26 +14,30 @@ def self.sections(section=:site)
class Tab
attr_accessor :name, :url, :items
-
+
def initialize(name, url, options = {})
@name, @url = name, url
@items = []
@visibility = [options[:for], options[:visibility]].flatten.compact
@visibility = [:all] if @visibility.empty?
end
-
+
def shown_for?(user)
visibility.include?(:all) or
visibility.any? { |role| user.send("#{role}?") }
end
-
+
def add_item(name, url)
@items << [name, url]
end
-
+
+ def include_url?(url)
+ @url==url || @items.flatten.include?(url)
+ end
+
end
-
-
+
+
class TabSet
include Enumerable
@@ -58,15 +62,15 @@ def add(name, url, options = {})
end
end
end
-
+
def remove(name)
@tabs.delete(tabs(name))
end
-
+
def size
@tabs.size
end
-
+
def tabs(name = :all_tabs)
if name==:all_tabs
@tabs
@@ -74,11 +78,11 @@ def tabs(name = :all_tabs)
@tabs.find { |tab| tab.name == name }
end
end
-
+
def clear
@tabs.clear
end
-
+
end
-
-end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.