Skip to content

Commit

Permalink
Make the explorer listnavs more compact and drop the explorer_tree
Browse files Browse the repository at this point in the history
  • Loading branch information
skateman committed Aug 24, 2017
1 parent df06897 commit 850363f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 25 deletions.
7 changes: 5 additions & 2 deletions app/assets/javascripts/miq_application.js
Original file line number Diff line number Diff line change
Expand Up @@ -1231,8 +1231,11 @@ function miqAccordSelect(e) {
return false;
}

var url = '/' + $('body').data('controller') + '/accordion_select?id=' + $(e.target).attr('id');
miqJqueryRequest(url, {beforeSend: true, complete: true});
// No need to load anything if only a single accordion is present
if ($('#accordion > .panel').length > 1) {
var url = '/' + $('body').data('controller') + '/accordion_select?id=' + $(e.target).attr('id');
miqJqueryRequest(url, {beforeSend: true, complete: true});
}
return true;
}

Expand Down
25 changes: 10 additions & 15 deletions app/views/layouts/listnav/_explorer.html.haml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
#accordion.panel-group
- if @accords.present? && @accords.length == 1 # there is no need for JavaScript if only one accordion is present
.panel.panel-default
.panel-heading
%h4.panel-title
%a{:href => '#'}
= @accords.first[:title]
.panel-collapse.collapse.in
.panel-body{:id => @accords.first[:container]}
= render :partial => 'shared/explorer_tree', :locals => {:name => @accords.first[:name]}
- elsif @accords.present? && @accords.length > 1
- accord_names = @accords.map { |accord| accord[:name].to_sym }
- @accords.each_with_index do |a, i|
= miq_accordion_panel(a[:title], accord_names.include?(@sb[:active_accord]) ? a[:name].to_sym == @sb[:active_accord] : i == 0, a[:container]) do
= render :partial => 'shared/explorer_tree', :locals => {:name => a[:name]}
- if @accords
#accordion.panel-group
-# 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.type == accord[:name].to_sym }
= render :partial => 'shared/tree', :locals => {:tree => tree, :name => tree.name.to_s}

:javascript
$('#accordion').on('show.bs.collapse', miqAccordSelect);
8 changes: 0 additions & 8 deletions app/views/shared/_explorer_tree.html.haml

This file was deleted.

0 comments on commit 850363f

Please sign in to comment.