Growstuff/growstuff

View on GitHub
app/views/plantings/index.html.haml

Summary

Maintainability
Test Coverage
- content_for :title, title('plantings', @owner, @crop, @planting)

- content_for :breadcrumbs do
  - if @owner
    %li.breadcrumb-item= link_to 'Plantings', plantings_path
    %li.breadcrumb-item.active= link_to "#{@owner}'s plantings", plantings_path(owner: @owner)
  - else
    %li.breadcrumb-item.active= link_to 'Plantings', plantings_path

.row
  .col-md-2
    %h1
      = planting_icon
      = title('plantings', @owner, @crop, @planting)
    = render 'layouts/nav', model: Planting
    = link_to show_inactive_tickbox_path('plantings', owner: @owner, crop: @crop, show_all: @show_all) do
      = check_box_tag 'active', 'all', @show_all
      include finished plantings
    %hr
    - if @owner.present?
      = render @owner, cached: true
    - if @crop.present?
      = render @crop, cached: true

    %section.open-data
      %h2 Open Data
      %p= t('label.data')
      - ['csv', 'json', 'rss'].each do |format|
        .badge.badge-info
          = link_to (@owner ? member_plantings_path(@owner, format: format) : plantings_path(format: format)) do
            = icon 'fas', format.to_s
            = format.upcase
      - if @owner
        .badge.badge-info= link_to "iCal", member_plantings_path(@owner, format: 'ics', protocol: 'webcal', only_path: false)
      .badge.badge-success= link_to 'API Methods', '/api-docs'

  .col-md-10

    %section
      %h2= title('plantings', @owner, @crop, @planting)
      = will_paginate @plantings
      - if @plantings.blank?
        %p No plantings recorded yet
      .index-cards
        - @plantings.each do |p|
          = render 'plantings/card', planting: p
      = will_paginate @plantings