diff --git a/app/views/activities/_form.html.haml b/app/views/activities/_form.html.haml
index a428c6dd78..02a89abcd4 100644
--- a/app/views/activities/_form.html.haml
+++ b/app/views/activities/_form.html.haml
@@ -39,9 +39,7 @@
= link_to "Add a planting.", new_planting_path
.col-md-4
- = f.date_field :due_date,
- value: @activity.due_date ? @activity.due_date.to_fs(:ymd) : '',
- label: 'When?'
+ = f.date_field :due_date, value: @activity.due_date ? @activity.due_date.to_fs(:ymd) : '', label: 'When?'
%hr
diff --git a/app/views/harvests/_form.html.haml b/app/views/harvests/_form.html.haml
index 5e9d9cd702..4a9b205ab5 100644
--- a/app/views/harvests/_form.html.haml
+++ b/app/views/harvests/_form.html.haml
@@ -30,7 +30,7 @@
= 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?'
+ = f.date_field :harvested_at, value: @harvest.harvested_at ? @harvest.harvested_at.to_fs(:ymd) : '', label: 'When?', required: true
.col-12
= f.form_group :plant_part_id, label: { text: "Harvested Plant Part" } do
.row
diff --git a/app/views/plantings/_form.html.haml b/app/views/plantings/_form.html.haml
index fbc94c54db..57672605c4 100644
--- a/app/views/plantings/_form.html.haml
+++ b/app/views/plantings/_form.html.haml
@@ -32,7 +32,7 @@
label: 'Where did you plant it?')
= link_to "Add a garden.", new_garden_path
.col-md-4
- = f.text_field :planted_at,
+ = f.date_field :planted_at,
value: @planting.planted_at ? @planting.planted_at.to_fs(:ymd) : '',
class: 'add-datepicker', label: 'When?'
%span.help-inline
@@ -52,11 +52,9 @@
= f.check_box :finished, label: 'Mark as finished'
%span.help-block= t('.finish_helper')
.col-md-6
- = f.text_field :finished_at,
+ = f.date_field :finished_at,
value: @planting.finished_at ? @planting.finished_at.to_fs(:ymd) : '',
- class: 'add-datepicker',
- label: 'Finished date',
- placeholder: 'optional'
+ label: 'Finished date (if known)'
.card-footer
.text-right= f.submit 'Save'
diff --git a/app/views/seeds/_form.html.haml b/app/views/seeds/_form.html.haml
index b83b1f3633..d008443e50 100644
--- a/app/views/seeds/_form.html.haml
+++ b/app/views/seeds/_form.html.haml
@@ -28,23 +28,23 @@
= link_to "Request new crops.", new_crop_path
.row
.col-12.col-md-4
- = f.text_field :saved_at,
+ = f.date_field :saved_at,
value: @seed.saved_at ? @seed.saved_at.to_fs(:ymd) : '',
- class: 'add-datepicker', label: 'When were the seeds harvested/saved?'
+ label: 'When were the seeds harvested/saved?'
.col-12.col-md-4= f.number_field :quantity, label: 'Quantity', min: 1
.col-12.col-md-4
- = f.text_field :plant_before, class: 'add-datepicker',
- value: @seed.plant_before ? @seed.plant_before.to_fs(:ymd) : ''
+ = f.date_field :plant_before, value: @seed.plant_before ? @seed.plant_before.to_fs(:ymd) : ''
.row
.col-12.col-md-4
= f.check_box :finished, label: 'Mark as finished'
.col-12.col-md-4
- = f.text_field :finished_at, class: 'add-datepicker', value: @seed.finished_at ? @seed.finished_at.to_fs(:ymd) : ''
+ = f.date_field :finished_at, value: @seed.finished_at ? @seed.finished_at.to_fs(:ymd) : ''
.col-12.col-md-4
%span.help-inline= t('.finish_helper')
.row
+ -# TODO: Range control?
.col-md-6= f.number_field :days_until_maturity_min, label_as_placeholder: true, label: 'min', prepend: 'Days until maturity', min: 1
.col-md-6= f.number_field :days_until_maturity_max, label_as_placeholder: true, label: 'max', prepend: 'to', append: "days", min: 1
@@ -54,7 +54,7 @@
.col-md-4
= f.select(:gmo, Seed::GMO_VALUES, {label: 'GMO?', wrapper: { class: 'required'}, required: true}, default: 'unknown')
.col-md-4
- = f.select(:heirloom, Seed::HEIRLOOM_VALUES, {label: 'Heirloom?', wrapper: { class: 'required'}, required: true}, default: 'unknown')
+ = f.select(:heirloom, Seed::HEIRLOOM_VALUES, {label: 'Heirloom?', wrapper: { class: 'required' }, required: true}, default: 'unknown')
= f.text_area :description, rows: 6
%hr/
diff --git a/app/views/shared/editable/_date.html.haml b/app/views/shared/editable/_date.html.haml
index 47bc016603..881936e6b3 100644
--- a/app/views/shared/editable/_date.html.haml
+++ b/app/views/shared/editable/_date.html.haml
@@ -5,6 +5,5 @@
= edit_icon
.hide{id: "date--#{model.id}-#{field.to_s}"}
= bootstrap_form_for(model) do |f|
- = f.date_field field,
- value: model.send(field) ? model.send(field).to_fs(:ymd) : '', label: 'When?'
+ = f.date_field field, value: model.send(field) ? model.send(field).to_fs(:ymd) : '', label: 'When?'
= f.submit :save
diff --git a/app/views/shared/editable/_form.html.haml b/app/views/shared/editable/_form.html.haml
index c009aa62af..058cf409bc 100644
--- a/app/views/shared/editable/_form.html.haml
+++ b/app/views/shared/editable/_form.html.haml
@@ -12,6 +12,5 @@
- elsif field_type == :select
= f.select field, collection
- elsif field_type == :date
- = f.date_field field,
- value: model.send(field) ? model.send(field).to_fs(:ymd) : '', label: 'When?'
+ = f.date_field field, value: model.send(field) ? model.send(field).to_fs(:ymd) : '', label: 'When?'
= f.submit :save
diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb
index 68032bb438..9ab4fe7bde 100644
--- a/spec/features/plantings/planting_a_crop_spec.rb
+++ b/spec/features/plantings/planting_a_crop_spec.rb
@@ -62,9 +62,9 @@
before do
visit new_planting_path
- @a_past_date = 15.days.ago.strftime("%Y-%m-%d")
- @right_now = Time.zone.today.strftime("%Y-%m-%d")
- @a_future_date = 1.year.from_now.strftime("%Y-%m-%d")
+ @a_past_date = 15.days.ago
+ @right_now = Time.zone.today
+ @a_future_date = 1.year.from_now
end
it "shows that it is not planted yet" do
@@ -111,7 +111,7 @@
fill_in "How many?", with: 42
select "cutting", from: "Planted from"
select "semi-shade", from: "Sun or shade?"
- fill_in "When?", with: '2013-03-10'
+ fill_in "When?", with: Time.new(2013, 3, 10)
fill_in "Tell us more about it", with: "It's rad."
fill_in "Finished date", with: @a_future_date
click_button "Save"
@@ -185,7 +185,7 @@
click_link 'Actions'
click_link "Edit"
check "finished"
- fill_in "Finished date", with: "2015-06-25"
+ fill_in "Finished date", with: Time.new(2015, 06, 25)
click_button "Save"
expect(page).to have_content "planting was successfully updated"
expect(page).to have_content "Finished"
@@ -196,9 +196,9 @@
select_from_autocomplete "maize"
choose(member.gardens.first.name)
within "form#new_planting" do
- fill_in "When?", with: "2014-07-01"
+ fill_in "When?", with: Time.new(2014, 7, 1)
check "Mark as finished"
- fill_in "Finished date", with: "2014-08-30"
+ fill_in "Finished date", with: Time.new(2014, 8, 30)
uncheck 'Mark as finished'
end
@@ -253,7 +253,7 @@
fill_autocomplete "crop", with: "mai"
select_from_autocomplete "maize"
within "form#new_planting" do
- fill_in "When", with: "2015-10-15"
+ fill_in "When", with: Time.new(2015, 10, 15)
fill_in "How many?", with: 42
select "cutting", from: "Planted from"
select "sun", from: "Sun or shade?"
diff --git a/spec/features/seeds/adding_seeds_spec.rb b/spec/features/seeds/adding_seeds_spec.rb
index 01b42ea570..40542113d8 100644
--- a/spec/features/seeds/adding_seeds_spec.rb
+++ b/spec/features/seeds/adding_seeds_spec.rb
@@ -33,7 +33,7 @@
select_from_autocomplete "maize"
within "form#new_seed" do
fill_in "Quantity", with: 42
- fill_in "Plant before", with: "2014-06-15"
+ fill_in "Plant before", with: TIme.new(2014, 6, 15)
fill_in "min", with: 999
fill_in "max", with: 1999
select "certified organic", from: "Organic?"
diff --git a/spec/views/plantings/_form.html.haml_spec.rb b/spec/views/plantings/_form.html.haml_spec.rb
index 0dc7a5a1a8..8634b19e19 100644
--- a/spec/views/plantings/_form.html.haml_spec.rb
+++ b/spec/views/plantings/_form.html.haml_spec.rb
@@ -22,6 +22,6 @@
end
it "has a free-form text field containing the planting date in ISO format" do
- assert_select "input#planting_planted_at[type='text'][value='2013-03-01']"
+ assert_select "input#planting_planted_at[type='date'][value='2013-03-01']"
end
end