Skip to content

Commit

Permalink
Merge pull request #5729 from skateman/explorer-tree-init-object
Browse files Browse the repository at this point in the history
Do not let angular parse the treeview data as it can be 🐒 HUGE 🐌
  • Loading branch information
himdel authored Jun 21, 2019
2 parents c83052a + 02a4883 commit 6d088fe
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions app/assets/javascripts/controllers/tree_view_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
};

Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/miq_global.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ if (!window.ManageIQ) {
checkUrl: null,
clickUrl: null,
expandAll: true,
data: {},
},
widget: {
dashboardUrl: null, // set dashboard widget drag drop url
Expand Down
4 changes: 3 additions & 1 deletion app/views/layouts/listnav/_explorer.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
Expand Down

0 comments on commit 6d088fe

Please sign in to comment.