diff --git a/Gemfile.lock b/Gemfile.lock index 55207bcd2..38dd193b2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/app/assets/stylesheets/_harvests.scss b/app/assets/stylesheets/_harvests.scss index 560983965..b8c317ea5 100644 --- a/app/assets/stylesheets/_harvests.scss +++ b/app/assets/stylesheets/_harvests.scss @@ -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 { diff --git a/app/assets/stylesheets/_plantings.scss b/app/assets/stylesheets/_plantings.scss index 52e204082..a65aeb75c 100755 --- a/app/assets/stylesheets/_plantings.scss +++ b/app/assets/stylesheets/_plantings.scss @@ -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; diff --git a/app/assets/stylesheets/mobile.scss b/app/assets/stylesheets/mobile.scss index c62904e37..760e5eaa7 100644 --- a/app/assets/stylesheets/mobile.scss +++ b/app/assets/stylesheets/mobile.scss @@ -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%; diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 9f83044b0..021460c99 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -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 diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index 25e6b8403..fda3a9c80 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -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 diff --git a/app/views/crops/_thumbnail.html.haml b/app/views/crops/_thumbnail.html.haml index 0338ebfb4..6500d913d 100644 --- a/app/views/crops/_thumbnail.html.haml +++ b/app/views/crops/_thumbnail.html.haml @@ -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') diff --git a/app/views/harvests/_modal.html.haml b/app/views/harvests/_modal.html.haml index bc8b82587..f453e8962 100644 --- a/app/views/harvests/_modal.html.haml +++ b/app/views/harvests/_modal.html.haml @@ -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: ""} diff --git a/app/views/harvests/_thumbnail.html.haml b/app/views/harvests/_thumbnail.html.haml index 5dfe125c3..3c6dca5e4 100644 --- a/app/views/harvests/_thumbnail.html.haml +++ b/app/views/harvests/_thumbnail.html.haml @@ -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 diff --git a/app/views/members/_full_summary.html.haml b/app/views/members/_full_summary.html.haml new file mode 100644 index 000000000..d855d74cb --- /dev/null +++ b/app/views/members/_full_summary.html.haml @@ -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} + + diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml index 62f2e0978..cdfc9ab93 100644 --- a/app/views/members/show.html.haml +++ b/app/views/members/show.html.haml @@ -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 diff --git a/app/views/plantings/_badges.html.haml b/app/views/plantings/_badges.html.haml index 8402aaf36..e01d72d5f 100644 --- a/app/views/plantings/_badges.html.haml +++ b/app/views/plantings/_badges.html.haml @@ -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') diff --git a/app/views/plantings/_thumbnail.html.haml b/app/views/plantings/_thumbnail.html.haml index 60bf071cf..3e105961b 100644 --- a/app/views/plantings/_thumbnail.html.haml +++ b/app/views/plantings/_thumbnail.html.haml @@ -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 diff --git a/spec/features/members/profile_spec.rb b/spec/features/members/profile_spec.rb index 08438efda..e668f28cc 100644 --- a/spec/features/members/profile_spec.rb +++ b/spec/features/members/profile_spec.rb @@ -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