Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 29 additions & 14 deletions app/views/foreman_puppet/puppetclasses/_classes.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,36 @@
<div class="col-md-6 classes">
<% group.each do |list| %>
<% next if list.nil? %>
<ul class="puppetclass_group">
<li><%= puppetclass_group_with_icon(list, selected_puppet_classes) %>
<ul id="pc_<%= list.first %>" style="display: none;">
<% for klass in list.last.sort %>
<% unless authorized_for(controller: :host_editing, action: :edit_classes) %>
<li data-original-title="<%= _('Not authorized to edit classes') %>" rel="twipsy"><%= h klass.name %></li>
<% else %>
<li id="puppetclass_<%= klass.id %>" class="puppetclass<%= ' hide' if selected_puppet_classes.include?(klass) %>">
<%= link_to_add_puppetclass(klass, resource_type) %>
</li>

<div class="panel-group paneless puppetclass_group" id="<%= list.first %>-avail-classes" style="margin-bottom: 1px;">
<div class="panel-heading" style="padding-top: 2px; padding-bottom: 2px;">
<p class="panel-title">
<a data-toggle="collapse" data-parent="#<%= list.first %>-avail-classes" href="#<%= list.first %>-avail-classes-list" class="collapsed">
<%= h list.first %>
</a>
</p>
</div>
<div id="<%= list.first %>-avail-classes-list" class="panel-collapse collapse">
<div class="panel-body">
<ul style="margin-bottom: 1px;">
<% for klass in list.last.sort %>
<% unless authorized_for(:controller => :host_editing, :action => :edit_classes) %>
<li data-original-title="<%= _('Not authorized to edit classes') %>" rel="twipsy">
<%= h klass.name %>
</li>
<% else %>
<% style = ["puppetclass",
selected_puppet_classes.include?(klass) ? "hide" : "",
].join(' ') %>
<%= content_tag(:li, klass, :id => "puppetclass_#{klass.id}", :class => style) do %>
<%= link_to_add_puppetclass(klass, type) %>
<% end %>
<% end %>
<% end %>
<% end %>
</ul>
</li>
</ul>
</ul>
</div>
</div>
</div>
<% end %>
</div>
<% end %>
13 changes: 11 additions & 2 deletions webpack/src/foreman_class_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,18 @@ export function filterPuppetClasses(item) {
classElems
.hide()
.has(`[data-class-name*="${term}"]`)
.show();
.show()
.filter('div')
.find('a.collapsed')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the collapsed class being set on a <a>?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really know.
I used the developers pane to find out how the attributes changed with some hints from the _classes.html.erb file.
The code was created by changing/playing with the left menu pane code in an older foreman version (probably before parternfly 5)

.attr('aria-expanded','true')
.click();
} else {
classElems.show();
classElems
.show()
.has('.collapse')
.find('a[aria-expanded]')
.attr('aria-expanded','false')
.click();
}
}

Expand Down