Files
Brenda WallaceandClaude Sonnet 5.5 a2e495a76c Add when to sow, how to sow and germination time to seeds
What a packet says about sowing it. When to sow is the months, as many as the
packet says: a form sends twelve chips to tick, with the seasons as shortcuts
for the grower's hemisphere (none where we do not know it, rather than a
guess), and the list shows them as runs like "Oct-Feb". How to sow is text, in
the packet's words. Germination is a range of days, as maturity is.

A migration adds four columns to seeds. The facts are on the packet sheet, in
the order they happen, and editable from the pencils, from Edit all and from the
standalone form.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-29 19:35:41 +13:00

40 lines
2.0 KiB
Plaintext

-# A field is usually one attribute, but may be a pair edited together — a min
-# and a max. The first of the pair names the form.
- fields = Array(field)
- form_id = editable_form_id(model, field)
- what = fields.one? ? fields.first.to_s : fields.first.to_s.sub(/_(min|max)\z/, '')
- trigger = local_assigns.fetch(:trigger, :pencil)
- if can? :edit, model
- if trigger == :pencil
%small.edit-link
%a.editable{ "data-form" => "##{form_id}", "data-display": display_field, href: "#", name: "##{form_id}" }
-# One muted pencil everywhere, not the orange SVG icon.
= menu_icon(:edit)
%span.visually-hidden Edit #{what.humanize.downcase}
-# The fact card's own h3 already names the field, so the generated label
-# would print it a second time right under it. hide_label keeps the label
-# in the markup for screen readers and takes it off the screen. A pair is
-# the exception: "min" and "max" tell the two apart and the h3 says neither.
.hide{ id: form_id }
= bootstrap_form_for(model) do |f|
- if field_type == :text_area
= f.text_area field, hide_label: true, rows: 4
- elsif field_type == :text_field
= f.text_field field, hide_label: true
- elsif field_type == :select
= f.select field, values, hide_label: true
- elsif field_type == :number_field
= f.number_field field, hide_label: true, min: values&.first, max: values&.last
- elsif field_type == :number_range
.row.g-2
.col-6= f.number_field fields.first, label: 'min', min: 0
.col-6= f.number_field fields.last, label: 'max', min: 0
- elsif field_type.is_a?(String)
-# A field with a partial of its own, given the form and the model.
= render field_type, f: f, model: model, prefix: form_id
- elsif field_type == :date
= f.date_field field,
value: model.send(field) ? model.send(field).to_fs(:ymd) : '', label: 'When?'
= f.submit :save