Files
growstuff/app/views/seeds/_facts.html.haml
T
Brenda Wallace acfaa2a880 feat: add tesseract.js dependency and implement photo association tests
- Added `tesseract.js` as a dependency in `package.json`.
- Created a new spec file for `PhotosHelper` to test `packet_image_urls` method.
- Enhanced `Crop` model tests to ensure packet photos do not interfere with crop photos.
- Introduced validation tests for `Seed` model, covering row spacing and variety constraints.
- Updated API response in `seeds_request_spec.rb` to include variety, batch number, and row spacing.
- Updated `yarn.lock` to reflect new dependencies and versions.
2026-10-28 19:37:09 +13:00

102 lines
4.1 KiB
Plaintext

-# Each fact card fills the same slots: an h3 naming the fact with its edit
-# pencil, then the value. The value sits in a .fact-value wrapper so opening
-# the inline form hides the whole of it — the unit word included — rather
-# than leaving "seeds" or "days" stranded beside the form.
.index-cards.facts.seedfacts
.card{ class: seed.quantity.present? ? '' : 'text-muted' }
%h3
Quantity
= editable :text_field, seed, :quantity, display_field: '.seedfacts--quantity'
.fact-value.seedfacts--quantity
%strong= seed.quantity.presence || "not specified"
%span seeds
-# What the packet prints besides the crop.
.card{ class: seed.variety.present? ? '' : 'text-muted' }
%h3
Variety
= editable :text_field, seed, :variety, display_field: '.seedfacts--variety'
.fact-value.seedfacts--variety
%strong= seed.variety.presence || 'not specified'
.card{ class: seed.row_spacing.present? ? '' : 'text-muted' }
%h3
Row spacing
= editable :number_field, seed, :row_spacing, display_field: '.seedfacts--rowspacing'
.fact-value.seedfacts--rowspacing
%strong= seed.row_spacing.presence || 'not specified'
%span cm
-# A packet records the year its seed was saved, like a hand-written one.
.card{ class: seed.saved_at.present? ? '' : 'text-muted' }
%h3
Year saved
= editable :date, seed, :saved_at, display_field: '.seedfacts--savedat'
.fact-value.seedfacts--savedat
%strong= seed.saved_at.present? ? seed.saved_at.year : 'Unknown'
.card{ class: seed.plant_before.present? ? '' : 'text-muted' }
%h3
Plant before
= editable :number_field, seed, :plant_before_year,
display_field: '.seedfacts--plantbefore', values: Seed::PLANT_BEFORE_YEARS
.fact-value.seedfacts--plantbefore
%strong= seed.plant_before.present? ? seed.plant_before.year : 'Unknown'
.card{ class: seed.days_until_maturity_max.present? ? '' : 'text-muted' }
%h3
Days until maturity
= editable :number_range, seed, %i(days_until_maturity_min days_until_maturity_max),
display_field: '.seedfacts--maturity'
.fact-value.seedfacts--maturity
%strong= render partial: 'days_until_maturity', locals: { seed: seed }
%span days
-# Where the packet came from. 'other/unknown' is the model's own "don't
-# know", so it reads as quietly as a blank one would.
- source_known = seed.source.present? && seed.source != 'other/unknown'
.card{ class: source_known ? '' : 'text-muted' }
%h3
Seed source
= editable :select, seed, :source,
values: Seed::SOURCE_VALUES, display_field: '.seedfacts--source'
.fact-value.seedfacts--source
%strong= source_known ? seed.source : 'Unknown'
-# Whether it is an heirloom or a hybrid; 'unknown' is the model's own "don't
-# know", so it reads as quietly as a blank one would.
.card{ class: seed.heirloom_kind ? '' : 'text-muted' }
%h3
Heirloom or hybrid
= editable :select, seed, :heirloom,
values: Seed::HEIRLOOM_VALUES, display_field: '.seedfacts--heirloom'
.fact-value.seedfacts--heirloom
%strong= seed.heirloom_kind&.capitalize || 'Unknown'
.card
%h3
Will trade
= editable :select, seed, :tradable_to,
values: Seed::TRADABLE_TO_VALUES, display_field: '.seedfacts--tradableto'
.fact-value.seedfacts--tradableto
%strong= seed.tradable_to
%span
- if seed.owner.location.blank?
(from unspecified location)
- if current_member == seed.owner
= link_to "Set Location", edit_registration_path(current_member), class: 'btn btn-outline-secondary btn-sm'
- else
(from #{link_to seed.owner.location, place_path(seed.owner.location, anchor: "seeds")})
- if seed.finished_at.present? || seed.finished?
.card
%h3 Finished
.fact-value
%strong
- if seed.finished_at.present?
= I18n.t('date.abbr_month_names')[seed.finished_at.month]
- elsif seed.finished?
= finished_icon
- if seed.finished_at.present?
%span= seed.finished_at.year