Skip to content

Commit

Permalink
Better bread crumb
Browse files Browse the repository at this point in the history
  • Loading branch information
fd committed Apr 29, 2010
1 parent 2ff6464 commit 51ab8e8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 21 deletions.
25 changes: 12 additions & 13 deletions app/helpers/application_helper.rb
Expand Up @@ -137,7 +137,7 @@ def css_class(class_name='', value=nil, check=nil)
end
end
end

def abbreviation(value=nil)
unless value.nil?
abbreviation = value
Expand All @@ -148,19 +148,18 @@ def abbreviation(value=nil)
return abbreviation
end
end

def breadcrumb_root
unless @breadcrumb_root
if @user or @users
@breadcrumb_root = { :text => 'Users', :link => admin_users_path }
elsif @project or @projects
@breadcrumb_root = { :text => 'Projects', :link => root_path }
elsif @user_session
@breadcrumb_root = { :text => 'Login', :link => new_user_session_path }
else
@breadcrumb_root = { :text => 'Home', :link => root_path }
end
return @breadcrumb_root if @breadcrumb_root
if @user or @users and request.path.starts_with?('/admin')
@breadcrumb_root = { :text => 'Users', :link => admin_users_path }
elsif @project or @projects
@breadcrumb_root = { :text => 'Projects', :link => root_path }
elsif @user_session
@breadcrumb_root = { :text => 'Login', :link => new_user_session_path }
else
@breadcrumb_root = { :text => 'Home', :link => root_path }
end
end

end
28 changes: 20 additions & 8 deletions app/views/shared/_breadcrumb.html.haml
@@ -1,11 +1,23 @@
- breadcrumb_root

- menu_block do |link|
- link.to(@breadcrumb_root[:text], @breadcrumb_root[:link])
- @error = @occurence.error if @occurence and !@error
- @project = @error.project if @error and !@project
- link.to(@project.name, @project,:class => "action2") { true } if @project and !@project.new_record?
- link.to(@error.id, @error,:class => "open") {true} if @error
- link.to(@occurence.id, @occurence,:class => "action2") {true} if @occurence

- link.to("edit my account",{:action => "edit"},:class => "action2") {true} if params[:action]=="edit" and !@error and !@project
- if @breadcrumb_root
- link.to(@breadcrumb_root[:text], @breadcrumb_root[:link])

- @error ||= (@occurence.error if @occurence)
- @project ||= (@error.project if @error)

- if @project and !@project.new_record?
- link.to(@project.name, @project,:class => "action2") { true }

- if @error
- link.to(@error.id, @error,:class => "open") {true}

- if @occurence
- link.to(@occurence.id, @occurence,:class => "action2") {true}

- if @user and request.path.starts_with?('/admin')
- link.to(@user.name, admin_user_path(@user), :class => "action2")

- elsif @user
- link.to("edit my account",{:action => "edit"}, :class => "action2") {true}

0 comments on commit 51ab8e8

Please sign in to comment.