Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EUWE] Don't lookup category names if tag tree view all #13308

Merged
merged 1 commit into from
Jan 11, 2017
Merged
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
23 changes: 15 additions & 8 deletions app/presenters/tree_builder_tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ def tree_init_options(_tree_name)
end

def contain_selected_kid(category)
category.entries.any? do |entry|
path = "#{category.name}-#{entry.name}"
(@edit && @edit[:new][:filters].key?(path)) || (@filters && @filters.key?(path))
end
return false unless @edit || @filters
category.entries.any? { |entry| selected_entry_value(category, entry) }
end

def selected_entry_value(category, entry)
return false unless @edit || @filters
path = "#{category.name}-#{entry.name}"
(@edit && @edit.fetch_path(:new, :filters, path)) || (@filters && @filters.key?(path))
end

def set_locals_for_render
Expand All @@ -44,17 +48,20 @@ def root_options
end

def x_get_tree_roots(count_only, _options)
return @categories.size if count_only
Copy link
Member

Choose a reason for hiding this comment

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

There a reason the return was removed from the "master" version of this PR: https://github.com/ManageIQ/manageiq-ui-classic/pull/57/files

Copy link
Member Author

Choose a reason for hiding this comment

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

That was probably an oversight. May have to put in a PR to get this line into master

# open node if at least one of his kids is selected
@categories.each do |c|
open_node("cl-#{to_cid(c.id)}") if contain_selected_kid(c)
if @edit.present? || @filters.present?
@categories.each do |c|
open_node("cl-#{to_cid(c.id)}") if contain_selected_kid(c)
end
end
count_only_or_objects(count_only, @categories)
end

def x_get_classification_kids(parent, count_only)
return parent.entries.size if count_only
kids = parent.entries.map do |kid|
kid_id = "#{parent.name}-#{kid.name}"
select = (@edit && @edit.fetch_path(:new, :filters, kid_id)) || (@filters && @filters.key?(kid_id))
select = selected_entry_value(parent, kid)
Copy link
Member

Choose a reason for hiding this comment

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

I should have asked this before... was this supposed to be a boolean or the value for that key? Seems like it should have been the value, but not sure.

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks - fixed

{:id => kid.id,
:image => 'tag',
:text => kid.description,
Expand Down