mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-11 09:17:20 -04:00
Merge pull request #2219 from Br3nda/feature-2207
Group previous plantings by year
This commit is contained in:
@@ -20,9 +20,7 @@ class GardensController < ApplicationController
|
||||
@current_plantings = @garden.plantings.current
|
||||
.includes(:crop, :owner)
|
||||
.order(planted_at: :desc)
|
||||
@finished_plantings = @garden.plantings.finished
|
||||
.includes(:crop)
|
||||
.order(finished_at: :desc)
|
||||
@finished_plantings = @garden.plantings.finished.includes(:crop)
|
||||
respond_with(@garden)
|
||||
end
|
||||
|
||||
|
||||
13
app/views/gardens/_previously.haml
Normal file
13
app/views/gardens/_previously.haml
Normal file
@@ -0,0 +1,13 @@
|
||||
%h2 Previously planted in this garden
|
||||
|
||||
- if @finished_plantings.size.positive?
|
||||
- year = nil
|
||||
- @finished_plantings.order(planted_at: :desc).each do |planting|
|
||||
- if year != planting.planted_at.year
|
||||
- year = planting.planted_at.year
|
||||
%h4= year
|
||||
= render "plantings/tiny", planting: planting
|
||||
- else
|
||||
.col-md-12
|
||||
%p Nothing has been planted here.
|
||||
|
||||
@@ -56,15 +56,9 @@
|
||||
- else
|
||||
.col-md-12
|
||||
%p Nothing is currently planted here.
|
||||
%section
|
||||
%h2 Previously planted in this garden
|
||||
.index-cards
|
||||
- if @finished_plantings.size.positive?
|
||||
- @finished_plantings.each do |planting|
|
||||
= render "plantings/tiny", planting: planting
|
||||
- else
|
||||
.col-md-12
|
||||
%p Nothing has been planted here.
|
||||
|
||||
%section= render 'previously'
|
||||
|
||||
.col-md-3
|
||||
.card
|
||||
.card-image
|
||||
|
||||
Reference in New Issue
Block a user