Skip to content

Commit

Permalink
Rename replace_trees_by_presenter to reload_trees_by_presenter
Browse files Browse the repository at this point in the history
  • Loading branch information
skateman committed Sep 6, 2017
1 parent 029971b commit 9f67c25
Show file tree
Hide file tree
Showing 15 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions app/controllers/application_controller.rb
Expand Up @@ -2220,10 +2220,10 @@ def controller_for_common_methods
end
end

def replace_trees_by_presenter(presenter, trees)
trees.each_pair do |name, tree|
def reload_trees_by_presenter(presenter, trees)
trees.each_pair do |_, tree|
next unless tree.present?
presenter.reload_tree(name, tree)
presenter.reload_tree(tree.name, tree.locals_for_render[:bs_tree])
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/catalog_controller.rb
Expand Up @@ -1967,7 +1967,7 @@ def replace_right_cell(options = {})
:active_tree => x_active_tree,
:add_nodes => add_nodes
)
replace_trees_by_presenter(presenter, trees)
reload_trees_by_presenter(presenter, trees)

if @sb[:buttons_node]
if action == "group_reorder"
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/chargeback_controller.rb
Expand Up @@ -838,7 +838,7 @@ def replace_right_cell(options = {})
presenter = ExplorerPresenter.new(
:active_tree => x_active_tree,
)
replace_trees_by_presenter(presenter, :cb_rates => cb_rates_build_tree) if replace_trees.include?(:cb_rates)
reload_trees_by_presenter(presenter, :cb_rates => cb_rates_build_tree) if replace_trees.include?(:cb_rates)

# FIXME
# if params[:action].ends_with?("_delete")
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/miq_ae_class_controller.rb
Expand Up @@ -280,7 +280,7 @@ def replace_right_cell(options = {})
:add_nodes => add_nodes,
)

replace_trees_by_presenter(presenter, :ae => build_ae_tree) unless replace_trees.blank?
reload_trees_by_presenter(presenter, :ae => build_ae_tree) unless replace_trees.blank?

if @sb[:action] == "miq_ae_field_seq"
presenter.update(:class_fields_div, r[:partial => "fields_seq_form"])
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/miq_ae_customization_controller.rb
Expand Up @@ -248,7 +248,7 @@ def replace_right_cell(options = {})
@explorer = true
presenter = ExplorerPresenter.new(:active_tree => x_active_tree)

replace_trees_by_presenter(presenter, trees)
reload_trees_by_presenter(presenter, trees)
presenter[:osf_node] = x_node unless @in_a_form

if ['dialog_edit', 'dialog_copy'].include?(params[:pressed])
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/miq_policy_controller.rb
Expand Up @@ -522,7 +522,7 @@ def replace_right_cell(options = {})
raise _("unknown tree in replace_trees: %{name}") % {name => name}
end
end
replace_trees_by_presenter(presenter, trees)
reload_trees_by_presenter(presenter, trees)

if params[:action].ends_with?('_delete') &&
!x_node.starts_with?('p') &&
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/mixins/manager_controller_mixin.rb
Expand Up @@ -310,7 +310,7 @@ def replace_right_cell(options = {})
update_partials(record_showing, presenter)
replace_search_box(presenter)
handle_bottom_cell(presenter)
replace_trees_by_presenter(presenter, trees)
reload_trees_by_presenter(presenter, trees)
rebuild_toolbars(record_showing, presenter)
presenter[:right_cell_text] = @right_cell_text
presenter[:osf_node] = x_node # Open, select, and focus on this node
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/ops_controller.rb
Expand Up @@ -774,7 +774,7 @@ def replace_explorer_trees(replace_trees, presenter)
trees[:diagnostics] = diagnostics_build_tree if replace_trees.include?(:diagnostics)
trees[:vmdb] = db_build_tree if replace_trees.include?(:vmdb)
end
replace_trees_by_presenter(presenter, trees)
reload_trees_by_presenter(presenter, trees)
end

# Build the audit object when a profile is saved
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/pxe_controller.rb
Expand Up @@ -117,7 +117,7 @@ def replace_right_cell(options = {})
c_tb = build_toolbar(center_toolbar_filename) unless @in_a_form
h_tb = build_toolbar('x_history_tb')

replace_trees_by_presenter(presenter, trees)
reload_trees_by_presenter(presenter, trees)

# Rebuild the toolbars
presenter.reload_toolbars(:history => h_tb)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/report_controller.rb
Expand Up @@ -690,7 +690,7 @@ def replace_right_cell(options = {}) # :replace_trees key can be an array of tr
v_tb = build_toolbar("report_view_tb") if @report && [:reports_tree, :savedreports_tree].include?(x_active_tree)
end

replace_trees_by_presenter(presenter, trees)
reload_trees_by_presenter(presenter, trees)
presenter[:osf_node] = x_node # Open, select, and focus on this node

session[:changed] = (@edit[:new] != @edit[:current]) if @edit && @edit[:current] # to get save/reset buttons to highlight when something is changed
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/service_controller.rb
Expand Up @@ -326,7 +326,7 @@ def replace_right_cell(options = {})
)

if Array(replace_trees).include?(:svcs)
replace_trees_by_presenter(presenter, :svcs => build_svcs_tree)
reload_trees_by_presenter(presenter, :svcs => build_svcs_tree)
end

# Replace right cell divs
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/storage_controller.rb
Expand Up @@ -396,7 +396,7 @@ def replace_right_cell(options = {})
update_partials(record_showing, presenter)
replace_search_box(presenter)
handle_bottom_cell(presenter)
replace_trees_by_presenter(presenter, trees)
reload_trees_by_presenter(presenter, trees)
rebuild_toolbars(record_showing, presenter)
case x_active_tree
when :storage_tree
Expand Down
4 changes: 2 additions & 2 deletions app/presenters/explorer_presenter.rb
Expand Up @@ -142,8 +142,8 @@ def reload_toolbars(toolbars)
self
end

def reload_tree(_name, tree)
@options[:reload_trees][tree.name] = tree.locals_for_render[:bs_tree]
def reload_tree(name, data)
@options[:reload_trees][name] = data
end

def replace(div_name, content)
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/application_controller_spec.rb
Expand Up @@ -300,7 +300,7 @@
end
end

describe "#replace_trees_by_presenter" do
describe "#reload_trees_by_presenter" do
let(:tree_1) { double(:name => 'tree_1') }
let(:tree_2) { double(:name => 'tree_2') }
let(:trees) { {'tree_1' => tree_1, 'tree_2' => tree_2, 'tree_3' => nil} }
Expand All @@ -310,7 +310,7 @@
allow(tree_1).to receive(:locals_for_render).and_return(:bs_tree => {})
allow(tree_2).to receive(:locals_for_render).and_return(:bs_tree => {})
expect(presenter).to receive(:reload_tree).with(any_args).twice
controller.send(:replace_trees_by_presenter, presenter, trees)
controller.send(:reload_trees_by_presenter, presenter, trees)
end
end
end
2 changes: 1 addition & 1 deletion spec/controllers/miq_ae_class_controller_spec.rb
Expand Up @@ -97,7 +97,7 @@
:trees => {:ae_tree => {:active_node => node}})
controller.instance_variable_set(:@_params, :button => "reset", :id => cls1.id)
allow(controller).to receive(:open_parent_nodes)
expect(controller).to_not receive(:replace_trees_by_presenter)
expect(controller).to_not receive(:reload_trees_by_presenter)
expect(controller).to receive(:render)
controller.send(:copy_objects)
expect(controller.send(:flash_errors?)).not_to be_truthy
Expand Down

0 comments on commit 9f67c25

Please sign in to comment.