Merge branch 'feature/crop-action-modals' of github.com:Br3nda/growstuff into feature/crop-action-modals

Conflicts:
app/views/harvests/_modal.html.haml
This commit is contained in:
Brenda Wallace committed 2020-02-29 09:38:21 +13:00
commit 5d43575eae
14 files changed
+172 -42

No files matched your search

+9 -7
View File
@@ -68,7 +68,7 @@ GEM
autoprefixer-rails (9.7.3)
execjs
bcrypt (3.1.13)
better_errors (2.5.1)
better_errors (2.6.0)
coderay (>= 1.0.0)
erubi (>= 1.0.0)
rack (>= 0.9.0)
@@ -149,7 +149,7 @@ GEM
csv_shaper (1.3.1)
activesupport (>= 3.0.0)
dalli (2.7.10)
database_cleaner (1.8.2)
database_cleaner (1.8.3)
devise (4.7.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
@@ -316,7 +316,7 @@ GEM
multi_xml (0.6.0)
multipart-post (2.1.1)
nio4r (2.5.2)
nokogiri (1.10.7)
nokogiri (1.10.8)
mini_portile2 (~> 2.4.0)
oauth (0.5.4)
oauth2 (1.4.2)
@@ -355,7 +355,7 @@ GEM
popper_js (1.14.5)
procto (0.0.3)
public_suffix (4.0.3)
puma (4.3.1)
puma (4.3.2)
nio4r (~> 2.0)
query_diet (0.6.2)
rack (2.2.2)
@@ -413,6 +413,7 @@ GEM
responders (3.0.0)
actionpack (>= 5.0)
railties (>= 5.0)
rexml (3.2.4)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
@@ -453,11 +454,12 @@ GEM
rswag-ui (2.2.0)
actionpack (>= 3.1, < 6.1)
railties (>= 3.1, < 6.1)
rubocop (0.79.0)
rubocop (0.80.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.7.0.1)
rainbow (>= 2.2.2, < 4.0)
rexml
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.7)
rubocop-rails (2.4.2)
@@ -491,7 +493,7 @@ GEM
tilt
scout_apm (2.6.6)
parser
searchkick (4.2.1)
searchkick (4.3.0)
activemodel (>= 5)
elasticsearch (>= 6)
hashie
@@ -561,7 +563,7 @@ GEM
websocket-driver (0.7.1)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4)
will_paginate (3.2.1)
will_paginate (3.3.0)
will_paginate-bootstrap4 (0.2.2)
will_paginate (~> 3.0, >= 3.0.0)
xmlrpc (0.3.0)
+13 -5
View File
@@ -2,21 +2,29 @@
.text {
color: $white;
margin: 0;
opacity: .9;
opacity: .8;
position: absolute;
text-align: center;
top: 50%;
top: 30%;
width: 100%;
color: $white;
h3,
h4,
h5 {
margin: 0
}
h3 {
background-color: $green;
font-size: 1em;
}
h4 {
background-color: $black;
}
h5 {
background-color: $brown;
color: $white;
font-size: .7em;
}
a {
-7
View File
@@ -1,5 +1,4 @@
.planting {
.planting-badges {
font-size: 1em;
position: absolute;
@@ -23,12 +22,6 @@
}
}
.planting-full-badges {
.badge {
font-size: 200%;
}
}
.planting-name {
position: relative;
text-align: center;
+6 -1
View File
@@ -1,6 +1,11 @@
// Overrides applying only to mobile view. This must be at the end of the overrides file.
// Extra small devices (portrait phones, less than 576px)
@include media-breakpoint-down(xs) {
@include media-breakpoint-down(md) {
.container {
margin: 2px;
padding: 0;
}
#maincontainer {
width: 100%;
+25 -4
View File
@@ -23,10 +23,31 @@ class MembersController < ApplicationController
@activity = TimelineService.member_query(@member).limit(30)
# The garden form partial is called from the "New Garden" tab;
# it requires a garden to be passed in @garden.
# The new garden is not persisted unless Garden#save is called.
@garden = Garden.new
@late = []
@super_late = []
@harvesting = []
@others = []
@member.plantings.active.annual.each do |planting|
if planting.finish_is_predicatable?
if planting.super_late?
@super_late << planting
elsif planting.late?
@late << planting
elsif planting.harvest_time?
@harvesting << planting
else
@others << planting
end
end
end
@harvests = Harvest.search(
where: { owner_id: @member.id },
boost_by: [:created_at],
limit: 16,
load: false
)
respond_to do |format|
format.html # show.html.haml
+1 -1
View File
@@ -91,7 +91,7 @@ module IconsHelper
icon('fas', 'heart')
end
def plantpart_icon(name)
def plant_part_icon(name)
image_icon "plant_parts/#{name}"
end
+1 -1
View File
@@ -1,7 +1,7 @@
- cache crop do
.card.crop-thumbnail
= link_to crop_path(slug: crop.slug) do
= image_tag(crop.thumbnail_url ? crop.thumbnail_url : placeholder_image,
= image_tag(crop.thumbnail_url.presence || placeholder_image,
alt: crop.name,
class: 'img img-card')
+2 -2
View File
@@ -15,7 +15,7 @@
.card
= link_to @planting ? harvests_path(return: 'planting', harvest: {crop_id: @planting.crop_id, planting_id: @planting.id, plant_part_id: plant_part.id}, method: :post) : harvests_path(harvest: {crop_id: harvest.crop.id, plant_part_id: plant_part.id}, method: :post) do
.card-title.text-center
%h3= plantpart_icon(plant_part.name)
%h3= plant_part_icon(plant_part.name)
%h3= plant_part.name
%hr/
@@ -23,7 +23,7 @@
%nav.nav
- PlantPart.all.order(:name).each do |plant_part|
= link_to @planting ? harvests_path(return: 'planting', harvest: {crop_id: @planting.crop_id, planting_id: @planting.id, plant_part_id: plant_part.id}, method: :post) : harvests_path(harvest: {crop_id: harvest.crop.id, plant_part_id: plant_part.id}, method: :post), class: 'nav-link' do
= plantpart_icon(plant_part.name)
= plant_part_icon(plant_part.name)
= plant_part
%a.btn{"data-target" => "#modelHarvestForm", "data-toggle" => "modal", href: ""}
+11 -7
View File
@@ -1,10 +1,14 @@
- cache harvest do
.card.harvest-thumbnail
= link_to image_tag(harvest_image_path(harvest),
alt: harvest,
class: 'img img-card'),
harvest
= link_to harvest_path(slug: harvest.slug) do
= image_tag(harvest.thumbnail_url ? harvest.thumbnail_url : placeholder_image,
alt: harvest.crop_name,
class: 'img img-card')
.text
%h3.harvest-plant-part= link_to harvest.plant_part, harvest
%h5.harvest-crop= harvest.crop
.card-body
%h3.harvest-crop.card-title
= link_to harvest.crop_name, harvest_path(slug: harvest.slug)
harvest
%h4.harvest-plant-part
= harvest.plant_part_name
%small.text-muted= harvest.harvested_at
+47
View File
@@ -0,0 +1,47 @@
- if @harvesting.size.positive?
%section.harvests
%h2 Ready to harvest
.index-cards
- @harvesting.each do |planting|
= render 'plantings/thumbnail', planting: planting
- if @harvests.any?
%section.havests
%h2 Recent Harvests
.index-cards
- @harvests.each do |harvest|
= render 'harvests/thumbnail', harvest: harvest
- if @others.size.positive?
%section.planting-progress
%h2 Progress report
%p Still growing and not ready for harvesting.
.list-group
- @others.each do |planting|
.list-group-item
%span= render 'plantings/tiny', planting: planting
%span= render 'plantings/progress', planting: planting
- if @late.size.positive?
%section.late
%h2 Late
%p
These plantings are at the end of their lifecycle.
- if member_signed_in? && @member == current_member
%strong When you have removed the planting from your garden, mark the planting as finished in Growstuff.
.index-cards
- @late.each do |planting|
= render 'plantings/thumbnail', planting: planting
- if @super_late.any?
%section.superlate
%h2 Super late
%p
We suspect the following plantings finished long ago and no longer need tracking.
- if member_signed_in? && current_member == @member
%strong You can mark these plantings as finished to stop tracking.
%ul
- @super_late.each do |planting|
%li
= link_to planting.crop_name, planting_url(slug: planting.slug)
planted on #{planting.planted_at.to_date}
+4 -2
View File
@@ -18,8 +18,9 @@
.col-md-2
.card
.card-body
= render "avatar", member: @member
= render "bio", member: @member
.row
.col= render "bio", member: @member
.col= render "avatar", member: @member
%p
- @member.roles.each do |role|
%span.badge.badge-info= role.name.titleize
@@ -61,6 +62,7 @@
.col-md-10
%section= render "map", member: @member
= render 'members/full_summary', member: @member
%section.activity
%h2 Activity
.list-group
-1
View File
@@ -4,7 +4,6 @@
- if planting.finish_is_predicatable?
- if planting.super_late?
%span.badge.badge-info.badge-super-late= t('.super_late')
= planting_finish_button(planting)
- elsif planting.late?
%span.badge.badge-info.badge-late= t('.late_finishing')
+5 -4
View File
@@ -1,11 +1,12 @@
.card.thumbnail
.card.planting.thumbnail
.planting-thumbnail-image
= link_to image_tag(planting_image_path(planting),
alt: planting.crop, class: 'img-card'),
planting
.card-body
%h5.card-title
%h4
= crop_icon(planting.crop)
= link_to planting.crop, planting
%h6.card-subtitle.text-muted=planting.finished_at
= render 'plantings/badges', planting: planting
planting
- if planting.finished_at.present?
%h6.card-subtitle.text-muted=planting.finished_at
+48
View File
@@ -150,6 +150,54 @@ describe "member profile", js: true do
it { expect(page).to have_link href: photo_path(photo) }
it { expect(page).to have_link href: planting_path(planting) }
end
context 'plantings' do
let(:crop) { FactoryBot.create :crop }
before do
# time to harvest = 50 day
# time to finished = 90 days
FactoryBot.create(:harvest,
harvested_at: 50.days.ago,
crop: crop,
planting: FactoryBot.create(:planting,
crop: crop,
planted_at: 100.days.ago,
finished_at: 10.days.ago))
crop.plantings.each(&:update_harvest_days!)
crop.update_lifespan_medians
crop.update_harvest_medians
growing_planting
harvesting_planting
super_late_planting
visit member_path(member)
end
let(:growing_planting) do
FactoryBot.create :planting,
crop: crop,
owner: member,
planted_at: Time.zone.today
end
let(:harvesting_planting) do
FactoryBot.create :planting,
crop: crop,
owner: member,
planted_at: 51.days.ago
end
let(:super_late_planting) do
FactoryBot.create :planting,
crop: crop, owner: member,
planted_at: 260.days.ago
end
it { expect(page).to have_link(href: planting_path(growing_planting)) }
it { expect(page).to have_link(href: planting_path(harvesting_planting)) }
it { expect(page).to have_link(href: planting_path(super_late_planting)) }
end
end
context "not signed in" do