ManageIQ/manageiq-ui-classic

View on GitHub
app/views/layouts/listnav/_explorer.html.haml

Summary

Maintainability
Test Coverage
- if @accords
  #accordion.panel-group{'role' => 'tablist', 'ng-controller' => 'treeViewController as vm'}
    -# Set the first accordion as selected if there is no active_accord in the sandbox
    - selected = @accords.find(-> { @accords.first }) { |accord| accord[:name].to_sym == @sb[:active_accord] }
    - @accords.each do |accord|
      = 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[:select_node]}')",
                       'on-select' => "vm.nodeSelect(node, '/#{request.parameters[:controller]}/tree_select')",
                       'selected'  => "vm.selectedNodes['#{tree.name}']",
                       'persist'   => 'key',
                       'lazy-load' => "(vm.lazyLoad(node, '#{tree.name}', '/#{request.parameters[:controller]}/tree_autoload'))"}
  :javascript
    miq_bootstrap('#accordion');
    $('#accordion').on('show.bs.collapse', miqAccordSelect);