Skip to content

Commit

Permalink
Move #show_dashboard support to mixins.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpovolny committed Feb 22, 2017
1 parent f91751f commit a3b8c9c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
21 changes: 1 addition & 20 deletions app/controllers/ems_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def textual_group_list
end

def show_props
drop_breadcrumb(:name => @ems.name + _(" (Properties)"), :url => show_link(@ems, :display => "props"))
drop_breadcrumb(:name => @ems.name + _(" (Properties)"), :url => show_link(@ems, :display => "props"))
end

def show_ems_folders
Expand All @@ -35,19 +35,6 @@ def show_ems_folders
self.x_active_tree = :vat_tree
end

def show_dashboard
@showtype = "dashboard"
@lastaction = "show_dashboard"
drop_breadcrumb(:name => @ems.name + _(" (Dashboard)"), :url => show_link(@ems))
@sb[:summary_mode] = 'dashboard' unless @sb[:summary_mode] == 'dashboard'
render :action => "show_dashboard"
end

def show_main
@sb[:summary_mode] = 'textual' unless @sb[:summary_mode] == 'textual'
super
end

def show_ad_hoc_metrics
@showtype = "ad_hoc_metrics"
@lastaction = "show_ad_hoc_metrics"
Expand Down Expand Up @@ -1141,12 +1128,6 @@ def permission_prefix
self.class.permission_prefix
end

def show_link(ems, options = {})
url_for(options.merge(:controller => @table_name,
:action => "show",
:id => ems.id))
end

def show_list_link(ems, options = {})
url_for(options.merge(:controller => @table_name,
:action => "show_list",
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/mixins/dashboard_view_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,13 @@ def dashboard_view
(@settings.fetch_path(:views, :summary_mode) || "dashboard") == 'dashboard'
end
end

def show_dashboard
@showtype = "dashboard"
@lastaction = "show_dashboard"
drop_breadcrumb(:name => @record.name + _(" (Dashboard)"), :url => show_link(@record))
@sb[:summary_mode] = 'dashboard' unless @sb[:summary_mode] == 'dashboard'
render :action => "show_dashboard"
end
end
end
16 changes: 13 additions & 3 deletions app/controllers/mixins/generic_show_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,28 @@ def show_download
end

def show_main
# remember dashboard mode if dashboard is supported for this controller
@sb[:summary_mode] = 'textual' if respond_to?(:dashboard_view)

get_tagdata(@record) if @record.try(:taggings)
drop_breadcrumb({:name => breadcrumb_name(nil),
:url => "/#{controller_name}/show_list?page=#{@current_page}&refresh=y"},
true)

show_url = restful? ? "/#{controller_name}/" : "/#{controller_name}/show/"

drop_breadcrumb(:name => _("%{name} (Summary)") % {:name => @record.name},
:url => "#{show_url}#{@record.id}")
:url => show_link(@record))
@showtype = "main"
end

def show_link(record, options = {})
opts = options.merge(
:controller => self.class.table_name,
:id => record.id,
:action => restful? ? :index : :show
)
url_for(opts)
end

def gtl_url
restful? ? '/' : '/show'
end
Expand Down

0 comments on commit a3b8c9c

Please sign in to comment.