mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-31 03:09:06 -04:00
134 lines
5.9 KiB
Plaintext
134 lines
5.9 KiB
Plaintext
-# The fields of a crop's form, in the edit dialog and on the form page.
|
|
-# Handy link to crop wrangling policy/style guide, shown to wranglers only
|
|
- if can? :wrangle, crop
|
|
%p
|
|
%span.form-text
|
|
For detailed crop wrangling guidelines, please consult the
|
|
= link_to "crop wrangling guide", "https://github.com/Growstuff/growstuff/wiki/Crop-Wrangling"
|
|
on the Growstuff wiki.
|
|
|
|
-# Everyone (wranglers and requesters) sees the basic info section
|
|
%h2 Basic information
|
|
|
|
.mb-3#new_crop
|
|
= f.text_field :name, required: true
|
|
%span.form-text
|
|
The common name for the crop, in English (required).
|
|
- if can? :wrangle, crop
|
|
Wranglers: please ensure this is singular, and capitalize
|
|
proper nouns only.
|
|
|
|
%h2 Lifespan
|
|
%p
|
|
= f.radio_button(:perennial, false, label: 'Annual')
|
|
%span.form-text Living and reproducing in a single year or less
|
|
%p
|
|
= f.radio_button(:perennial, true, label: "Perennial")
|
|
%span.form-text Living more than two years
|
|
|
|
%h2 Data
|
|
- if crop.description.blank? || can?(:wrangle, crop)
|
|
= f.text_area :description, label: 'Description'
|
|
- if crop.parent
|
|
%span.form-text Parent: #{crop.parent.description}
|
|
- if crop.row_spacing.blank? || can?(:wrangle, crop)
|
|
= f.number_field :row_spacing, label: 'Row Spacing (cm)', min: 0
|
|
- if crop.parent
|
|
%span.form-text Parent: #{crop.parent.row_spacing}
|
|
- if crop.spread.blank? || can?(:wrangle, crop)
|
|
= f.number_field :spread, label: 'Spread (cm)', min: 0
|
|
- if crop.parent
|
|
%span.form-text Parent: #{crop.parent.spread}
|
|
- if crop.height.blank? || can?(:wrangle, crop)
|
|
= f.number_field :height, label: 'Height (cm)', min: 0
|
|
- if crop.parent
|
|
%span.form-text Parent: #{crop.parent.height}
|
|
- if crop.sowing_method.blank? || can?(:wrangle, crop)
|
|
= f.text_field :sowing_method
|
|
- if crop.parent
|
|
%span.form-text Parent: #{crop.parent.sowing_method}
|
|
- if crop.sun_requirements.blank? || can?(:wrangle, crop)
|
|
= f.text_field :sun_requirements
|
|
- if crop.parent
|
|
%span.form-text Parent: #{crop.parent.sun_requirements}
|
|
- if crop.growing_degree_days.blank? || can?(:wrangle, crop)
|
|
= f.number_field :growing_degree_days, min: 0
|
|
- if crop.parent
|
|
%span.form-text Parent: #{crop.parent.growing_degree_days}
|
|
= f.text_field :public_food_key, label: 'Australian Food Composition Database Public Food Key'
|
|
|
|
- unless crop.approved?
|
|
= link_to 'Search wikipedia', "https://en.wikipedia.org/w/index.php?search=#{crop.name}", target: '_blank'
|
|
- if crop.en_wikipedia_url.blank? || can?(:wrangle, crop)
|
|
= f.url_field :en_wikipedia_url, id: "en_wikipedia_url", label: 'Wikipedia URL'
|
|
%span.form-text
|
|
Link to the crop's page on the English language Wikipedia (required).
|
|
- if crop.en_youtube_url.blank? || can?(:wrangle, crop)
|
|
= f.url_field :en_youtube_url, label: 'YouTube URL'
|
|
%span.form-text
|
|
Link to a YouTube video about the crop in English.
|
|
|
|
-# Only crop wranglers see the crop hierarchy (for now)
|
|
- if can? :wrangle, crop
|
|
= f.select(:parent_id, Crop.order(:name).pluck(:name, :id),
|
|
{ include_blank: true, label: 'Parent crop'})
|
|
%span.form-text Optional. For setting up crop hierarchies for varieties etc.
|
|
|
|
- icon_choices = Crop.icon_names.map { |icon| [icon.humanize, icon] }
|
|
= f.select(:icon, icon_choices, { include_blank: "None: use the parent crop's", label: 'Icon' })
|
|
%span.form-text
|
|
Optional. Shown for this crop and any varieties of it that don't have their own.
|
|
- if crop.persisted? && crop.svg_icon.present?
|
|
Currently:
|
|
= image_tag crop_path(crop, format: 'svg'), class: 'crop-icon', alt: ''
|
|
|
|
|
|
- content_for :scripts do
|
|
= javascript_include_tag 'react_islands', defer: true
|
|
|
|
-# Everyone (wranglers and requesters) gets to add scientific names
|
|
-# The scientific name fields are a React island, which adds and removes rows
|
|
-# and suggests names from GBIF; the plain fields inside are what shows until it
|
|
-# mounts, or without JavaScript.
|
|
%h2 Scientific names
|
|
= react_component 'ScientificNames', { names: crop.scientific_names.map(&:name), suggest_url: gbif_suggest_scientific_names_path } do
|
|
.mb-3
|
|
- crop.scientific_names.each.with_index do |sci, index|
|
|
.mb-2
|
|
= label_tag "sci_name[#{index + 1}]", "Scientific name #{index + 1}:", class: 'form-label'
|
|
= text_field_tag "sci_name[#{index + 1}]", sci.name, id: "sci_name[#{index + 1}]", class: 'form-control'
|
|
%span.form-text Searches GBIF to determine scientific name of crop.
|
|
|
|
-# The alternate name fields are a React island too.
|
|
%h2 Alternate names
|
|
= react_component 'AlternateNames', { names: crop.alternate_names.map(&:name) } do
|
|
.mb-3
|
|
- crop.alternate_names.each.with_index do |alt, index|
|
|
.mb-2
|
|
= label_tag "alt_name[#{index + 1}]", "Alternate name #{index + 1}:", class: 'form-label'
|
|
= text_field_tag "alt_name[#{index + 1}]", alt.name, id: "alt_name[#{index + 1}]", class: 'form-control'
|
|
%span.form-text Alternate name of crop.
|
|
|
|
-# This is used for comments from crop requesters. We need to show it
|
|
-# to everyone, but we don't include it on new crops from wranglers.
|
|
|
|
- if (can?(:wrangle, crop) && crop.requester) || (cannot?(:wrangle, crop) && crop.new_record?)
|
|
%h2 Crop request notes
|
|
= f.text_area :request_notes, rows: 3, id: 'request_notes', label: 'Comments'
|
|
|
|
-# A final explanation of what's going to happen next, for crop requesters
|
|
- unless can? :wrangle, crop
|
|
%p
|
|
When you submit this form, your suggestion will be sent to our team of
|
|
volunteer crop wranglers for review. We'll let you know the outcome as soon as we can.
|
|
|
|
-# Now, for crop wranglers, let's have approval/rejection at the bottom of the page
|
|
- if can?(:wrangle, crop) && crop.requester
|
|
-# %h2 Approve or reject pending crops
|
|
-# = f.select(:approval_status, crop.approval_statuses, {})
|
|
= f.select(:reason_for_rejection, crop.reasons_for_rejection, include_blank: true)
|
|
|
|
= f.text_area :rejection_notes, rows: 3
|
|
%span.form-text
|
|
Please provide additional notes why this crop request was rejected if the above reasons do not apply.
|