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
45 changes: 30 additions & 15 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>
<% end %>
<% end %>
</ul>
</li>
</ul>

<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;">
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't say I'm exactly happy about inline styling all over the place. Could that be extracted to classes?

<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) %>
Comment on lines +26 to +27
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<%= content_tag(:li, klass, :id=>"puppetclass_#{klass.id}", :class=>style) do %>
<%= link_to_add_puppetclass(klass,type) %>
<%= content_tag(:li, klass, :id => "puppetclass_#{klass.id}", :class => style) do %>
<%= link_to_add_puppetclass(klass, type) %>

<% end %>
<% end %>
<% end %>
</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>?

.attr('aria-expanded','true')
.click();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the click?

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

Expand Down