Revision 452d6329
Added by Paul Kelly almost 14 years ago
- ID 452d63292a366794bedff9a16a1f7364786b52c2
app/controllers/application_controller.rb | ||
---|---|---|
helper 'layout'
|
||
|
||
before_filter :require_ssl, :require_login
|
||
before_filter :load_tabs, :manage_tabs
|
||
|
||
def self.active_scaffold_controller_for(klass)
|
||
return FactNamesController if klass == Puppet::Rails::FactName
|
||
... | ... | |
end
|
||
|
||
private
|
||
def active_tab=(value); @active_tab = session[:controller_active_tabs][controller_name] = value; end
|
||
|
||
def load_tabs
|
||
@tabs = session[:tabs] ||= {}
|
||
@active_tab = session[:active_tab]
|
||
controller_tabs = session[:controller_tabs] ||= {}
|
||
@tabs = controller_tabs[controller_name] ||= {}
|
||
controller_active_tabs = session[:controller_active_tabs] ||= {}
|
||
@active_tab = controller_active_tabs[controller_name] ||= ""
|
||
end
|
||
|
||
def manage_tabs
|
||
return if params[:tab_name].empty? or params[:tab_name] == "Reset"
|
||
# Clear the active tab if jumping between different controller's
|
||
@controller_changed = session[:last_controller] != controller_name
|
||
session[:last_controller] = controller_name
|
||
self.active_tab = "" if @controller_changed
|
||
|
||
return if params[:tab_name].empty? or params[:action] != "index"
|
||
|
||
if params[:remove_me] and @tabs.has_key? params[:tab_name]
|
||
if params[:tab_name] == "Reset"
|
||
self.active_tab = ""
|
||
elsif params[:remove_me] and @tabs.has_key? params[:tab_name]
|
||
@tabs.delete params[:tab_name]
|
||
@active_tab = session[:active_tab] = @tabs.keys.sort.first
|
||
# If we delete the active tab then clear the active tab selection
|
||
if @active_tab == params[:tab_name]
|
||
self.active_tab = ""
|
||
else
|
||
# And redirect back as we do not want to perform the deleted tab's search
|
||
redirect_to :back
|
||
end
|
||
else
|
||
@active_tab = session[:active_tab] = params[:tab_name]
|
||
self.active_tab = params[:tab_name]
|
||
@tabs[@active_tab] = params[:search]
|
||
end
|
||
end
|
Also available in: Unified diff
Fixes #248 - Generalise tab management and search facility
The search facility is now available from all controllers.
The search bar is only displayed if there is a partial
<controller_name>/_search_line.html.erb available.This partial also
describes and implements the possible search parameters for this controller
Active tab management is also improved
The appearence of the searchbar and other page elements has also been improved.