Skip to content

Commit

Permalink
Merge pull request #13308 from kbrock/config_groups_euwe
Browse files Browse the repository at this point in the history
[EUWE] Don't lookup category names if tag tree view all
  • Loading branch information
simaishi authored Jan 11, 2017
2 parents 302472a + c6fb39b commit cea5f55
Showing 1 changed file with 15 additions and 8 deletions.
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
# 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)
{:id => kid.id,
:image => 'tag',
:text => kid.description,
Expand Down

0 comments on commit cea5f55

Please sign in to comment.