mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-11 09:17:20 -04:00
* Update planting rating when recording a harvest - Added virtual attribute `overall_rating` to `Harvest` model. - Updated `HarvestsController` to permit `overall_rating` and synchronize it to the associated `Planting`. - Added a rating range field (1-5) to the harvest form. - Added controller tests to verify that the planting rating is updated. - Refined feature tests for harvesting. Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com> * I have updated the system to allow for recording a planting rating when a harvest is logged. Here is a summary of the changes: - Added a virtual attribute `overall_rating` to the `Harvest` model. - Updated `HarvestsController` to permit `overall_rating` and synchronize it to the associated `Planting`. - Added a rating range field (1-5) to the harvest form. - Added controller tests to verify that the planting rating is updated correctly. - Updated feature tests to ensure the harvest form functions as expected. Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com> * Update database.yml * Apply suggestions from code review Co-authored-by: Daniel O'Connor <daniel.oconnor@gmail.com> * Adjust wording * Change harvest modal * Fix tests --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
69 lines
2.9 KiB
Plaintext
69 lines
2.9 KiB
Plaintext
.card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2
|
|
|
|
= bootstrap_form_for(@harvest) do |f|
|
|
.card-header
|
|
- if content_for? :title
|
|
%h1.h2-responsive.text-center
|
|
= harvest_icon
|
|
%strong=yield :title
|
|
.card-body
|
|
- if @harvest.errors.any?
|
|
#error_explanation
|
|
%h2 #{pluralize(@harvest.errors.size, "error")} prohibited this harvest from being saved:"
|
|
%ul
|
|
- @harvest.errors.full_messages.each do |msg|
|
|
%li= msg
|
|
|
|
.row
|
|
.col-12
|
|
= f.label :crop, 'What did you harvest?', class: 'required'
|
|
- if @planting
|
|
= link_to @planting.crop.name, planting_path(@planting)
|
|
from
|
|
= link_to @planting.garden.name, garden_path(@planting.garden)
|
|
= f.hidden_field :planting_id, value: @planting.id
|
|
- else
|
|
= auto_suggest @harvest, :crop, class: 'form-control', default: @crop
|
|
- unless @planting
|
|
%span.help-block.col-md-8
|
|
Can't find what you're looking for?
|
|
= link_to "Request new crops.", new_crop_path
|
|
|
|
.col-md-4
|
|
= f.date_field :harvested_at, value: @harvest.harvested_at ? @harvest.harvested_at.to_fs(:ymd) : '', label: 'When?'
|
|
.col-12
|
|
= f.form_group :plant_part_id, label: { text: "Harvested Plant Part" } do
|
|
.row
|
|
- PlantPart.all.order(:name).pluck(:id, :name).each do |id, name|
|
|
.col-4.col-md-3= f.radio_button :plant_part_id, id, label: name, checked: (id == @harvest.plant_part_id)
|
|
|
|
-# Some browsers (eg Firefox for Android) assume "number" means
|
|
-# "integer" unless you specify step="any":
|
|
-# http://blog.isotoma.com/2012/03/html5-input-typenumber-and-decimalsfloats-in-chrome/
|
|
.row
|
|
.col-md-4
|
|
= f.number_field :quantity, class: 'input-small form-control', step: 'any', label: 'How many?', min: 1
|
|
.col-md-8
|
|
= f.select(:unit, Harvest::UNITS_VALUES, { include_blank: false }, class: 'input-medium form-control')
|
|
.row
|
|
.col-md-4
|
|
= f.number_field :weight_quantity, class: 'input-small form-control', step: 'any', label: 'Weighing (in total)'
|
|
.col-md-8
|
|
= f.select(:weight_unit, Harvest::WEIGHT_UNITS_VALUES, { include_blank: false }, class: 'form-control')
|
|
= f.text_area :description, rows: 6, label: 'Notes'
|
|
|
|
- if @planting.present?
|
|
.row
|
|
.col-md-12
|
|
= f.range_field :overall_rating, min: 1, max: 5, value: @planting.overall_rating, include_blank: 'Leave blank', label: 'Overall Rating - Planting', list: "rating-list", title: "How well is the planting going?"
|
|
%datalist{"id": "rating-list"}
|
|
%option{"value": "1"} Poor
|
|
%option{"value": "2"}
|
|
%option{"value": "3"}
|
|
%option{"value": "4"}
|
|
%option{"value": "5"} Great
|
|
|
|
.card-footer
|
|
.text-right= f.submit 'Save'
|
|
|