Add css class to show finished/zombie/harvesting etc

This commit is contained in:
Brenda Wallace
2018-04-21 14:17:50 +12:00
parent 548fb3d3fd
commit 2e4378f025
3 changed files with 15 additions and 1 deletions

View File

@@ -101,6 +101,10 @@ p.stats
.badge-harvest
background-color: $blue
.planting-zombie
.planting-predicted-finished
background-color: $beige
.planting
.planting-badges
position: absolute

View File

@@ -42,4 +42,14 @@ module PlantingsHelper
return unless planting.planted_at.present? && planting.first_harvest_predicted_at.present?
(planting.first_harvest_predicted_at - Time.zone.today).to_i
end
def planting_classes(planting)
classes = []
classes << 'planting-growing' if planting.growing?
classes << 'planting-finished' if planting.finished?
classes << 'planting-harvest-time' if planting.harvest_time?
classes << 'planting-predicted-finished' if planting.should_be_finished?
classes << 'planting-zombie' if planting.zombie?
classes.join(' ')
end
end

View File

@@ -3,7 +3,7 @@
= render 'plantings/badges', planting: planting
.hover-wrapper
.thumbnail
.planting-thumbnail
.planting-thumbnail{class: planting_classes(planting)}
= link_to image_tag(planting_image_path(planting), alt: planting.crop.name, class: 'img'), planting_path(planting)
= render 'plantings/progress', planting: planting, show_explanation: false
.planting-name