diff --git a/app/assets/javascripts/controllers/tree_view_controller.js b/app/assets/javascripts/controllers/tree_view_controller.js index 75f11e6bc5c..6216041fbde 100644 --- a/app/assets/javascripts/controllers/tree_view_controller.js +++ b/app/assets/javascripts/controllers/tree_view_controller.js @@ -86,8 +86,9 @@ vm.selectedNodes[tree] = vm.selectedNodes[tree] || { key: node }; }; - vm.initData = function(tree, data, selected) { - vm.data[tree] = vm.data[tree] || data; + vm.initData = function(tree, selected) { + vm.data[tree] = vm.data[tree] || ManageIQ.tree.data[tree]; + ManageIQ.tree.data.delete(tree); vm.selectedNodes[tree] = vm.selectedNodes[tree] || { key: selected }; }; diff --git a/app/assets/javascripts/miq_global.js b/app/assets/javascripts/miq_global.js index 424951a5353..75d474e4fd9 100644 --- a/app/assets/javascripts/miq_global.js +++ b/app/assets/javascripts/miq_global.js @@ -83,6 +83,7 @@ if (!window.ManageIQ) { checkUrl: null, clickUrl: null, expandAll: true, + data: {}, }, widget: { dashboardUrl: null, // set dashboard widget drag drop url diff --git a/app/views/layouts/listnav/_explorer.html.haml b/app/views/layouts/listnav/_explorer.html.haml index 94746a078b5..3054e78c3d8 100644 --- a/app/views/layouts/listnav/_explorer.html.haml +++ b/app/views/layouts/listnav/_explorer.html.haml @@ -6,10 +6,12 @@ = miq_accordion_panel(accord[:title], selected == accord, accord[:container]) do -# Set the first tree to be rendered if there is a mismatch with the name/type - tree = @trees.find(-> { @trees.first }) { |t| t.name == "#{accord[:name]}_tree".to_sym } + :javascript + ManageIQ.tree.data['#{tree.name}'] = #{tree.locals_for_render[:bs_tree]}; %miq-tree-view{:name => tree.name, :data => "vm.data['#{tree.name}']", :reselect => tree.locals_for_render[:allow_reselect], - "ng-init" => "vm.initData('#{tree.name}', #{tree.locals_for_render[:bs_tree]}, '#{tree.locals_for_render[:select_node]}')", + "ng-init" => "vm.initData('#{tree.name}', '#{tree.locals_for_render[:select_node]}')", 'on-select' => "vm.nodeSelect(node, '/#{request.parameters[:controller]}/tree_select')", 'selected' => "vm.selectedNodes['#{tree.name}']", 'persist' => 'key', diff --git a/app/views/layouts/listnav/_generic_object_definition_show_list_with_treeview.html.haml b/app/views/layouts/listnav/_generic_object_definition_show_list_with_treeview.html.haml index d17c4894ded..82a0ae437f0 100644 --- a/app/views/layouts/listnav/_generic_object_definition_show_list_with_treeview.html.haml +++ b/app/views/layouts/listnav/_generic_object_definition_show_list_with_treeview.html.haml @@ -1,10 +1,12 @@ - return if @display == 'generic_objects' || @display == 'main' = miq_accordion_panel(_("Generic Object Classes"), true, "god") do + :javascript + ManageIQ.tree.data['#{@tree.name}'] = #{@tree.locals_for_render[:bs_tree]}; %tree_div{'ng-controller' => 'treeViewController as vm'} %miq-tree-view{:name => @tree.name, :data => "vm.data['#{@tree.name}']", :reselect => @tree.locals_for_render[:allow_reselect], - "ng-init" => "vm.initData('#{@tree.name}', #{@tree.locals_for_render[:bs_tree]}, '#{@tree.locals_for_render[:select_node]}')", + "ng-init" => "vm.initData('#{@tree.name}', '#{@tree.locals_for_render[:select_node]}')", 'on-select' => "vm.nodeSelect(node, '/#{request.parameters[:controller]}/tree_select')", 'selected' => "vm.selectedNodes['#{@tree.name}']", 'persist' => 'key',