Growstuff/growstuff

View on GitHub
app/views/crops/_hierarchy.html.haml

Summary

Maintainability
Test Coverage
%ul
  - @count ||= 0
  - unless defined? max
    - max = 0 # list all without "show all" toggle button
  - display_crops.each do |c|
    %li.crop-hierarchy{ class: (max != 0 && @count >= max) || !c.approved? ? ['hide', 'toggle'] : [] }
      = render 'crops/tiny', crop: c
      - if c.perennial
        = perennial_icon
      - @count += 1
      - if c.varieties.present?
        - c.varieties.order(:name).each do |v|
          = render partial: 'hierarchy', locals: { display_crops: [v], max: max }