mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-30 18:58:39 -04:00
The dialog is mounted once in the layout and any link marked data-photo-dialog opens it, naming its record in the heading. The gardens and posts menus, the old planting card and add_photo_button now use it instead of going to the new-photo page. Part of #4933 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
122 lines
5.5 KiB
Plaintext
122 lines
5.5 KiB
Plaintext
- harvest_title = "#{@harvest.crop} harvested by #{@harvest.owner}"
|
|
= render 'shared/record_meta',
|
|
title: harvest_title,
|
|
description: @harvest.description.presence || "#{harvest_title}.",
|
|
image: harvest_image_path(@harvest),
|
|
user_generated: true
|
|
|
|
-# The edit and add-photo dialogs; the latter is a React island.
|
|
- content_for :scripts do
|
|
= javascript_include_tag 'react_islands', defer: true
|
|
|
|
%script{type: "application/ld+json"}
|
|
= crop_jsonld_data(@harvest.crop, full_attributes: false).to_json.html_safe
|
|
|
|
-# A harvest is a picking off a planting, so the trail descends through
|
|
-# plantings: Home > Plantings > that planting > Harvest. Without a planting
|
|
-# there is no such parent, so it falls back to the owner's harvests. The last
|
|
-# crumb is the word, not the harvest itself, whose to_s is a whole sentence
|
|
-# ("50 individual apples, weighing 3lb").
|
|
- content_for :breadcrumbs do
|
|
- if @harvest.planting.present?
|
|
%li.breadcrumb-item= link_to 'Plantings', plantings_path
|
|
%li.breadcrumb-item= link_to @harvest.planting.display_name, @harvest.planting
|
|
- else
|
|
%li.breadcrumb-item= link_to 'Harvests', harvests_path
|
|
%li.breadcrumb-item= link_to @harvest.owner, member_harvests_path(@harvest.owner)
|
|
%li.breadcrumb-item.active Harvest
|
|
|
|
.harvest-show.record-page
|
|
.row
|
|
.col-md-8.col-12
|
|
-# Everything that is the harvest, inside one border; the sidebar is
|
|
-# context and sits outside it. See DESIGN.md.
|
|
.record-panel.harvest-detail
|
|
-# A photo of the harvest if there is one, otherwise of the planting it
|
|
-# came off, otherwise of the crop. Never the placeholder: that says
|
|
-# nothing worth 260px.
|
|
- hero_photo = @harvest.default_photo || @harvest.crop.default_photo
|
|
- if hero_photo
|
|
= link_to harvest_path(@harvest), class: 'record-hero-photo' do
|
|
= image_tag(hero_photo.source == 'flickr' ? hero_photo.fullsize_url : hero_photo.thumbnail_url,
|
|
alt: "#{@harvest.crop.name} harvested by #{@harvest.owner}")
|
|
.jumbotron
|
|
.d-flex.justify-content-between.align-items-start
|
|
.record-identity
|
|
= render 'shared/record_owner', owner: @harvest.owner
|
|
.record-identity-text
|
|
.record-title
|
|
%h1.display-3
|
|
= harvest_icon
|
|
%strong= t('harvests.show.heading', crop: @harvest.crop.name.titleize)
|
|
= render 'likes/likes', object: @harvest
|
|
%p.lead.mb-0
|
|
harvested by
|
|
%strong.record-grower-name= link_to @harvest.owner, @harvest.owner
|
|
- if @harvest.harvested_at.present?
|
|
%span.text-muted
|
|
·
|
|
= I18n.l @harvest.harvested_at
|
|
- if @harvest.planting.present?
|
|
= render 'shared/record_parent', planting: @harvest.planting, verb: 'picked from'
|
|
= render 'harvests/actions', harvest: @harvest
|
|
|
|
- if @harvest.description.present?
|
|
:markdown
|
|
#{strip_tags markdownify(@harvest.description)}
|
|
|
|
= render partial: 'planting'
|
|
|
|
%section.harvest-facts
|
|
.index-cards.facts
|
|
- if @harvest.plant_part
|
|
.card.fact-card
|
|
%h3
|
|
Plant part
|
|
= editable :select, @harvest, :plant_part_id, values: PlantPart.all.pluck(:name, :id), display_field: '.harvest-plantpart'
|
|
%strong.harvest-plantpart= @harvest.plant_part
|
|
.card.fact-card
|
|
%h3
|
|
Harvested
|
|
= editable :date, @harvest, :harvested_at, display_field: '.fact-harvested'
|
|
.fact-value.fact-harvested
|
|
%strong.harvested_at= standard_time_distance @harvest.harvested_at, Time.zone.now.to_date
|
|
%span.harvested_at= I18n.l @harvest.harvested_at
|
|
.card.fact-card{ class: @harvest.quantity.present? ? '' : 'text-muted' }
|
|
%h3
|
|
Quantity
|
|
= editable :text_field, @harvest, :quantity, display_field: '.fact-quantity'
|
|
.fact-value.fact-quantity
|
|
%strong.quantity= display_quantity(@harvest)
|
|
|
|
%section#photos
|
|
.section-header
|
|
%h2 Photos
|
|
- if can?(:edit, @harvest) && can?(:create, Photo)
|
|
= link_to new_photo_path(id: @harvest.id, type: 'harvest'), class: 'btn btn-sm section-add', data: photo_dialog_data(@harvest) do
|
|
= icon 'fas', 'plus'
|
|
add
|
|
- if @harvest.photos.any?
|
|
= render 'photos/gallery', photos: @harvest.photos.order(date_taken: :desc)
|
|
- else
|
|
%p.text-muted.mb-0 No photos yet.
|
|
|
|
-# Somebody grew this before they picked it. Show the planting as its
|
|
-# own card — photo, how it is doing, who grows it — so the reader is
|
|
-# tempted to go and look, rather than handed a bare link.
|
|
- if @harvest.planting.present?
|
|
%section.harvest-from
|
|
.section-header
|
|
%h2 The planting this came from
|
|
.index-cards
|
|
= render 'plantings/card', planting: @harvest.planting
|
|
%p.text-muted.small.mb-0
|
|
See how #{@harvest.owner}'s #{@harvest.crop.name} is getting on.
|
|
|
|
.col-md-4.col-12
|
|
%section.harvest-crop
|
|
.section-header
|
|
%h2 Crop
|
|
= render 'plantings/crop', crop: @harvest.crop
|
|
= render 'crops/nutritional_data', crop: @harvest.crop
|