From 7965845ab28c8ee387dfeab09cf03cc254a78ca7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sat, 8 Jun 2019 09:24:18 +1200 Subject: [PATCH] crops show sidebar tidy up harvests and plantings --- app/views/crops/_harvests.html.haml | 41 ++++++++++++++------------- app/views/crops/_plantings.html.haml | 25 ++++++++++------ app/views/crops/_wrangle.html.haml | 33 ++++++++++----------- app/views/crops/show.html.haml | 4 +-- app/views/harvests/show.html.haml | 1 - app/views/members/_location.html.haml | 2 +- app/views/members/_tiny.haml | 2 ++ app/views/seeds/_card.html.haml | 4 +-- 8 files changed, 60 insertions(+), 52 deletions(-) create mode 100644 app/views/members/_tiny.haml diff --git a/app/views/crops/_harvests.html.haml b/app/views/crops/_harvests.html.haml index 6e19723ef..23b071e69 100644 --- a/app/views/crops/_harvests.html.haml +++ b/app/views/crops/_harvests.html.haml @@ -1,20 +1,21 @@ -%h3 #{crop.name.capitalize} harvests -- if crop.harvests.empty? - %p - Nobody has harvested this crop yet. -- else - %ul.list-group.list-group-flush - - crop.harvests.order(harvested_at: :desc).limit(3).each do |harvest| - %li.list-group-item - = link_to "#{harvest.owner} harvested #{display_quantity(harvest)}.", harvest_path(harvest) - = render 'members/location', member: harvest.owner - %small - = distance_of_time_in_words(harvest.harvested_at, Time.zone.now) - ago. - %p - = link_to "View all #{crop.name} harvests", crop_harvests_path(crop) -- if crop.approved? - - if current_member - %p= link_to "Harvest #{crop.name}", new_harvest_path(crop_id: crop.id), class: 'btn' - - else - = render partial: 'shared/signin_signup', locals: { to: "track your #{crop.name} harvests" } +.card + .card-body + %h3 #{crop.name.capitalize} harvests + - if crop.harvests.empty? + %p Nobody has harvested this crop yet. + - unless crop.harvests.empty? + %ul.list-group.list-group-flush + - crop.harvests.order(harvested_at: :desc).limit(3).each do |harvest| + %li.list-group-item + = harvest_icon + = link_to "#{harvest.owner} harvested #{display_quantity(harvest)}.", harvest_path(harvest) + .float-right= render 'members/location', member: harvest.owner + .harvest-timeago + %small #{distance_of_time_in_words(harvest.harvested_at, Time.zone.now)} ago. + .card-footer + %p= link_to "View all #{crop.name} harvests", crop_harvests_path(crop) + - if crop.approved? + - if current_member + %p= link_to "Harvest #{crop.name}", new_harvest_path(crop_id: crop.id), class: 'btn' + - else + = render partial: 'shared/signin_signup', locals: { to: "track your #{crop.name} harvests" } diff --git a/app/views/crops/_plantings.html.haml b/app/views/crops/_plantings.html.haml index d0359ec89..611f2d081 100644 --- a/app/views/crops/_plantings.html.haml +++ b/app/views/crops/_plantings.html.haml @@ -1,9 +1,16 @@ -%h3 See who's planted #{crop.name.pluralize} -%ul.list-group.list-group-flush - - crop.plantings.order(planted_at: :desc).limit(5).each do |planting| - %li.list-group-item - = planting_icon - = link_to planting do - = planting - - if planting.owner.location.present? - %small=planting.owner.location \ No newline at end of file +.card + .card-body + %h3 See who's planted #{crop.name.pluralize} + - unless crop.plantings.empty? + %ul.list-group.list-group-flush + - crop.plantings.order(planted_at: :desc).limit(5).each do |planting| + %li.list-group-item + = planting_icon + = link_to planting, planting + .float-right= render 'members/location', member: planting.owner + .card-footer + - if crop.approved? + - if current_member + %p= link_to "Plant #{crop.name}", new_planting_path(crop_id: crop.id), class: 'btn' + - else + = render partial: 'shared/signin_signup', locals: { to: "track your #{crop.name} plantings" } diff --git a/app/views/crops/_wrangle.html.haml b/app/views/crops/_wrangle.html.haml index 243332574..c56a7b8c8 100644 --- a/app/views/crops/_wrangle.html.haml +++ b/app/views/crops/_wrangle.html.haml @@ -1,18 +1,19 @@ - if can?(:edit, crop) || can?(:destroy, crop) - %h4 Crop wrangling - %p - You are a - = succeed "." do - %strong CROP WRANGLER - .dropdown.crop-actions - %button#crop-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions - .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "crop-actions-button"} - = link_to edit_crop_path(crop), class: 'dropdown-item' do - = edit_icon - = t('.edit') + .alert.alert-success{role: "alert"} + %h4 Crop wrangling + %p + You are a + = succeed "." do + %strong CROP WRANGLER + .dropdown.crop-actions + %button#crop-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"} Actions + .dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "crop-actions-button"} + = link_to edit_crop_path(crop), class: 'dropdown-item' do + = edit_icon + = t('.edit') - - if can? :destroy, crop - .dropdown-divider - = link_to crop, method: :delete, class: 'dropdown-item text-danger' do - = delete_icon - Delete + - if can? :destroy, crop + .dropdown-divider + = link_to crop, method: :delete, class: 'dropdown-item text-danger' do + = delete_icon + Delete diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml index 8ad280206..0d134d86c 100644 --- a/app/views/crops/show.html.haml +++ b/app/views/crops/show.html.haml @@ -106,9 +106,9 @@ .card-body = render 'scientific_names', crop: @crop = render 'alternate_names', crop: @crop - = render 'plantings', crop: @crop - = render 'harvests', crop: @crop + = render 'plantings', crop: @crop + = render 'harvests', crop: @crop = render 'find_seeds', crop: @crop .card diff --git a/app/views/harvests/show.html.haml b/app/views/harvests/show.html.haml index 002e256eb..82411246f 100644 --- a/app/views/harvests/show.html.haml +++ b/app/views/harvests/show.html.haml @@ -11,7 +11,6 @@ -content_for(:buttonbar) do = render 'harvests/actions', harvest: @harvest - .row .col-md-8 %h1 diff --git a/app/views/members/_location.html.haml b/app/views/members/_location.html.haml index eff2aa6d9..46dec9fac 100644 --- a/app/views/members/_location.html.haml +++ b/app/views/members/_location.html.haml @@ -1,4 +1,4 @@ -.member-location +%span.badge.badge-light.member-location - if member.location.blank? unknown location - else diff --git a/app/views/members/_tiny.haml b/app/views/members/_tiny.haml new file mode 100644 index 000000000..dd7d78fda --- /dev/null +++ b/app/views/members/_tiny.haml @@ -0,0 +1,2 @@ += link_to member do + = image_tag(avatar_uri(member, 50), alt: '', class: 'img img-responsive avatar rounded') \ No newline at end of file diff --git a/app/views/seeds/_card.html.haml b/app/views/seeds/_card.html.haml index 4de268684..97376e1ca 100644 --- a/app/views/seeds/_card.html.haml +++ b/app/views/seeds/_card.html.haml @@ -40,6 +40,4 @@ %span.badge.badge-pill.badge-secondary Will trade #{seed.tradable_to} .card-footer %span.badge.badge-pill.badge-secondary=seed.owner.location - %p.float-right - = link_to seed.owner do - = image_tag(avatar_uri(seed.owner, 50), alt: '', class: 'img img-responsive avatar rounded') \ No newline at end of file + %p.float-right= render 'members/tiny', member: seed.owner \ No newline at end of file