Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add menu_click and sb_controller for additional data in report data #2740

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add menu_click and sb_controller for additional data in report data
  • Loading branch information
karelhala committed Nov 15, 2017
commit 7bb97f763ccd782351cdcf5198b17d9d2bf54095
12 changes: 7 additions & 5 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1500,7 +1500,8 @@ def get_view(db, options = {}, fetch_data = false)
params[:type] # gtl type
)
refresh_view = true
session[:menu_click] = params[:menu_click] # Creating a new view, remember if came from a menu_click
# Creating a new view, remember if came from a menu_click
session[:menu_click] = params[:menu_click] || options[:menu_click]
session[:bc] = params[:bc] # Remember incoming breadcrumb as well
end

@@ -1574,7 +1575,7 @@ def get_view(db, options = {}, fetch_data = false)
:supported_features_filter => options[:supported_features_filter],
:page => options[:all_pages] ? 1 : @current_page,
:per_page => options[:all_pages] ? ONE_MILLION : @items_per_page,
:where_clause => get_view_where_clause(options[:where_clause]),
:where_clause => get_view_where_clause(options[:where_clause], options[:sb_controller]),
:named_scope => options[:named_scope],
:display_filter_hash => options[:display_filter_hash],
:userid => session[:userid],
@@ -1609,10 +1610,11 @@ def grid_hash_conditions(view)
!@force_no_grid_xml && (@gtl_type == "list" || @force_grid_xml)
end

def get_view_where_clause(default_where_clause)
def get_view_where_clause(default_where_clause, sb_controller = nil)
# If doing charts, limit the records to ones showing in the chart
if session[:menu_click] && session[:sandboxes][params[:sb_controller]][:chart_reports]
chart_reports = session[:sandboxes][params[:sb_controller]][:chart_reports]
sb_controller = params[:sb_controller] if sb_controller.nil?
if !sb_controller.nil? && session[:menu_click] && session[:sandboxes][sb_controller][:chart_reports]
chart_reports = session[:sandboxes][sb_controller][:chart_reports]
chart_click = parse_chart_click(Array(session[:menu_click]).first)
model_downcase = chart_click.model.downcase

Original file line number Diff line number Diff line change
@@ -11,6 +11,8 @@ class ApplicationController
:view_suffix,

:row_button,
:menu_click,
:sb_controller,

:listicon,
:embedded,
@@ -42,6 +44,14 @@ def with_row_button(row_button)
self.row_button = row_button
end

def with_menu_click(menu_click)
self.menu_click = menu_click
end

def with_sb_controller(sb_controller)
self.sb_controller = sb_controller
end

def with_model(curr_model)
self.model = curr_model.kind_of?(String) ? curr_model : curr_model.name
end
2 changes: 2 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1639,6 +1639,8 @@ def process_show_list_options(options, curr_model = nil)
:policy_sim => @policy_sim
)
@report_data_additional_options.with_row_button(@row_button) if @row_button
@report_data_additional_options.with_menu_click(params[:menu_click]) if params[:menu_click]
@report_data_additional_options.with_sb_controller(params[:sb_controller]) if params[:sb_controller]
@report_data_additional_options.with_model(curr_model) if curr_model
@report_data_additional_options.freeze
end