From 99c27e15cb74c66888bf513f34e4bd7c55c9a4e3 Mon Sep 17 00:00:00 2001 From: Martin Hradil Date: Fri, 21 Jun 2019 11:25:56 +0000 Subject: [PATCH] Merge pull request #5729 from skateman/explorer-tree-init-object MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not let angular parse the treeview data as it can be 🐢 HUGE 🐌 (cherry picked from commit 6d088fe4db708aad3506d0b097a64f2b3c041ef1) https://bugzilla.redhat.com/show_bug.cgi?id=1727443 --- app/assets/javascripts/controllers/tree_view_controller.js | 5 +++-- app/assets/javascripts/miq_global.js | 1 + app/views/layouts/listnav/_explorer.html.haml | 4 +++- ...neric_object_definition_show_list_with_treeview.html.haml | 4 +++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/controllers/tree_view_controller.js b/app/assets/javascripts/controllers/tree_view_controller.js index 056a9087e51..09914f17e96 100644 --- a/app/assets/javascripts/controllers/tree_view_controller.js +++ b/app/assets/javascripts/controllers/tree_view_controller.js @@ -81,8 +81,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 56df727187b..86af0c6b6d0 100644 --- a/app/assets/javascripts/miq_global.js +++ b/app/assets/javascripts/miq_global.js @@ -88,6 +88,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 b004db08b5c..f01c1b761ce 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.type == accord[:name].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',