Skip to content

Commit

Permalink
Refactored Tabs code to avoid duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Dvorkin committed Sep 4, 2009
1 parent 8fbfeaf commit fb08567
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Thu, Sep 3, 2009
---------------------------------------------------------------------
- Make sure [rake crm:setup:admin] can actually assign admin attribute (thanks Rit!)
- Correctly assign and revoke admin rights in Admin/Users (thanks Rit!)
- Refactored Tabs code to avoid duplication.

Tue, Sep 1, 2009
---------------------------------------------------------------------
Expand Down
8 changes: 1 addition & 7 deletions app/helpers/admin/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@
module Admin::ApplicationHelper

def tabs
@current_tab ||= :users
tabs = FatFreeCRM::Tabs.admin
if tabs
tabs.each { |tab| tab[:active] = (tab[:text].downcase.to_sym == @current_tab) }
else
raise RuntimeError.new("Admin Tab settings are missing, please run 'rake crm:setup'")
end
super(FatFreeCRM::Tabs.admin)
end

#----------------------------------------------------------------------------
Expand Down
5 changes: 2 additions & 3 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@

module ApplicationHelper

def tabs
@current_tab ||= :home
tabs = FatFreeCRM::Tabs.main
def tabs(tabs = FatFreeCRM::Tabs.main)
if tabs
@current_tab ||= tabs.first[:text].downcase.to_sym # Select first tab by default.
tabs.each { |tab| tab[:active] = (tab[:text].downcase.to_sym == @current_tab || tab[:url][:controller].to_sym == @current_tab) }
else
raise RuntimeError.new("Tab settings are missing, please run 'rake crm:setup'")
Expand Down

0 comments on commit fb08567

Please sign in to comment.