Module: Spree::Admin::TaxonsHelper

Defined in:
app/helpers/spree/admin/taxons_helper.rb

Instance Method Summary collapse

Instance Method Details

#taxon_path(taxon) ⇒ Object



4
5
6
# File 'app/helpers/spree/admin/taxons_helper.rb', line 4

def taxon_path(taxon)
  taxon.ancestors.reverse.collect { |ancestor| ancestor.name }.join( " >> ")
end

#taxons_checkbox_tree(root, product) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/helpers/spree/admin/taxons_helper.rb', line 8

def taxons_checkbox_tree(root, product)
  return '' if root.children.blank?
   'ul' do
    root.children.map do |taxon|
       'li' do
        [check_box_tag("taxon_ids[]", taxon.id, product.taxons.include?(taxon), :id => "taxon_ids_#{taxon.id}"),
         label_tag("taxon_ids_#{taxon.id}", taxon.name)].join(' ').html_safe +
        taxons_checkbox_tree(taxon, product)
      end.html_safe
    end.join("\n").html_safe
  end
end