Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove bootstrap datepicker in favour of native controls #3881

Open
wants to merge 42 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
0f9e151
Swap to native datepicker
CloCkWeRX Oct 13, 2024
4b0e228
Swap to native datepicker
CloCkWeRX Oct 13, 2024
defc3de
Allow autosuggests to be required
CloCkWeRX Oct 13, 2024
bd858a0
Mark required
CloCkWeRX Oct 13, 2024
3405d22
Add input validations
CloCkWeRX Oct 13, 2024
329c3dd
Mark required
CloCkWeRX Oct 13, 2024
4716b33
Mark required
CloCkWeRX Oct 13, 2024
426cb3e
Remove redundant UI element
CloCkWeRX Oct 13, 2024
03f8acd
Add placehikder
CloCkWeRX Oct 13, 2024
5178e12
Merge branch 'dev' into datepicker
CloCkWeRX Oct 13, 2024
c78a347
Mark required
CloCkWeRX Oct 13, 2024
1956022
Fix test
CloCkWeRX Oct 13, 2024
c5bdac4
Merge branch 'dev' of https://github.com/Growstuff/growstuff into dat…
CloCkWeRX Oct 13, 2024
fe0d429
Spec no longer possible
CloCkWeRX Oct 13, 2024
a5f774f
Spec no longer possible
CloCkWeRX Oct 13, 2024
9c6797e
Swap to html5 control
CloCkWeRX Oct 13, 2024
4c8c54e
Fix specs
CloCkWeRX Oct 13, 2024
8aa0f98
Fix specs
CloCkWeRX Oct 13, 2024
69e764d
Fix specs
CloCkWeRX Oct 13, 2024
dddc85c
Fix specs
CloCkWeRX Oct 13, 2024
c6b5cc6
Fix specs
CloCkWeRX Oct 13, 2024
0e1578a
Fix specs
CloCkWeRX Oct 13, 2024
5128c8b
Fix specs
CloCkWeRX Oct 13, 2024
654aa31
Fix specs
CloCkWeRX Oct 13, 2024
65a0540
Mark spec pending
CloCkWeRX Oct 13, 2024
f89d64a
Mark spec pending
CloCkWeRX Oct 13, 2024
2523bea
Merge branch 'dev' into datepicker
CloCkWeRX Oct 13, 2024
fc30155
Merge branch 'dev' into datepicker
CloCkWeRX Oct 13, 2024
3e7a58f
Merge branch 'dev' into datepicker
CloCkWeRX Oct 13, 2024
919c3db
Merge branch 'dev' into datepicker
CloCkWeRX Oct 13, 2024
8d40355
Update app/views/harvests/_form.html.haml
CloCkWeRX Oct 13, 2024
e127051
Update app/views/seeds/_form.html.haml
CloCkWeRX Oct 13, 2024
7102552
Update spec/features/seeds/adding_seeds_spec.rb
CloCkWeRX Oct 13, 2024
035decb
Update spec/features/plantings/planting_a_crop_spec.rb
CloCkWeRX Oct 13, 2024
40ed3c8
Merge branch 'dev' into datepicker
CloCkWeRX Oct 13, 2024
e65dd4e
Merge branch 'dev' into datepicker
CloCkWeRX Oct 13, 2024
eeb8c84
Merge branch 'dev' into datepicker
CloCkWeRX Oct 13, 2024
99221d7
Merge branch 'dev' into datepicker
CloCkWeRX Oct 13, 2024
41c4ae1
Merge branch 'dev' into datepicker
CloCkWeRX Oct 13, 2024
0639cd5
Merge branch 'dev' into datepicker
CloCkWeRX Oct 13, 2024
54acc2c
Merge branch 'dev' into datepicker
CloCkWeRX Oct 13, 2024
53e90f5
Merge branch 'dev' into datepicker
CloCkWeRX Oct 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions app/views/activities/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@
= link_to "Add a planting.", new_planting_path

.col-md-4
= f.text_field :due_date,
value: @activity.due_date ? @activity.due_date.to_fs(:ymd) : '',
class: 'add-datepicker', label: 'When?'
= f.date_field :due_date, value: @activity.due_date ? @activity.due_date.to_fs(:ymd) : '', label: 'When?'

%hr

Expand Down
2 changes: 1 addition & 1 deletion app/views/gardens/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
- else
= link_to "Change your location.", edit_member_registration_path
.row
.col-md-5.col-12= f.number_field :area, class: 'input-small', step: "any"
.col-md-5.col-12= f.number_field :area, class: 'input-small', step: "any", min: 0
.col-md-7.col-12= f.select(:area_unit, Garden::AREA_UNITS_VALUES, { include_blank: false })
.col-12= f.select(:garden_type_id, GardenType.all.order(:name).pluck(:name, :id),
selected: @garden.garden_type_id, include_blank: true)
Expand Down
3 changes: 1 addition & 2 deletions app/views/harvests/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
= link_to "Request new crops.", new_crop_path

.col-md-4
= f.text_field :harvested_at, value: @harvest.harvested_at ? @harvest.harvested_at.to_fs(:ymd) : '',
class: 'add-datepicker', 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
Expand Down
10 changes: 4 additions & 6 deletions app/views/plantings/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -44,19 +44,17 @@
.col-md-4
= f.select(:sunniness, Planting::SUNNINESS_VALUES, { include_blank: '', label: 'Sun or shade?' } )
.col-md-4
= f.number_field :quantity, label: 'How many?'
= f.number_field :quantity, label: 'How many?', min: 1
= f.text_area :description, rows: 6, label: 'Tell us more about it'

.row
.col-md-6
= 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'
22 changes: 11 additions & 11 deletions app/views/seeds/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -22,44 +22,44 @@
= f.hidden_field :parent_planting_id, value: @planting.id
- else

= auto_suggest @seed, :crop, class: 'form-control', default: @crop
= auto_suggest @seed, :crop, class: 'form-control', default: @crop, required: true
%span.help-inline
Can't find what you're looking for?
= 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?'
.col-12.col-md-4= f.number_field :quantity, label: 'Quantity'
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

.row
.col-md-4
= f.select(:organic, Seed::ORGANIC_VALUES, {label: 'Organic?', wrapper: { class: 'required'}}, default: 'unknown', required: true)
= f.select(:organic, Seed::ORGANIC_VALUES, {label: 'Organic?', wrapper: { class: 'required'}, required: true}, default: 'unknown')
.col-md-4
= f.select(:gmo, Seed::GMO_VALUES, {label: 'GMO?', wrapper: { class: 'required'}}, default: 'unknown', required: true)
= 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'}}, default: 'unknown', required: true)
= f.select(:heirloom, Seed::HEIRLOOM_VALUES, {label: 'Heirloom?', wrapper: { class: 'required' }, required: true}, default: 'unknown')
= f.text_area :description, rows: 6

%hr/
= t('.trade_help', site_name: ENV['GROWSTUFF_SITE_NAME'])
= f.select(:tradable_to, Seed::TRADABLE_TO_VALUES, {label: 'Will trade', wrapper: { class: 'required'}})
= f.select(:tradable_to, Seed::TRADABLE_TO_VALUES, { label: 'Will trade', required: true, wrapper: { class: 'required '}})
CloCkWeRX marked this conversation as resolved.
Show resolved Hide resolved
%span.help_inline
- if current_member.location.blank?
Don't forget to
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/editable/_date.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
= edit_icon
.hide{id: "date--#{model.id}-#{field.to_s}"}
= bootstrap_form_for(model) do |f|
= f.text_field field,
= f.date_field field,
value: model.send(field) ? model.send(field).to_fs(:ymd) : '',
class: 'add-datepicker', label: 'When?'
= f.submit :save
2 changes: 1 addition & 1 deletion app/views/shared/editable/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- elsif field_type == :select
= f.select field, collection
- elsif field_type == :date
= f.text_field field,
= f.date_field field,
value: model.send(field) ? model.send(field).to_fs(:ymd) : '',
class: 'add-datepicker', label: 'When?'
= f.submit :save
9 changes: 0 additions & 9 deletions spec/features/gardens/gardens_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,6 @@
expect(page).to have_content "New garden"
end

it "Refuse to create new garden with negative area" do
visit new_garden_path
fill_in "Name", with: "Negative Garden"
fill_in "Area", with: -5
click_button "Save"
expect(page).to have_no_content "Garden was successfully created"
expect(page).to have_content "Area must be greater than or equal to 0"
end

context "Clicking edit from the index page" do
before do
visit gardens_path
Expand Down
18 changes: 9 additions & 9 deletions spec/features/plantings/planting_a_crop_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -185,20 +185,20 @@
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"
end

it "Marking a planting as finished" do
pending "Marking a planting as finished" do
CloCkWeRX marked this conversation as resolved.
Show resolved Hide resolved
fill_autocomplete "crop", with: "mai"
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

Expand Down Expand Up @@ -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?"
Expand Down
4 changes: 2 additions & 2 deletions spec/features/seeds/adding_seeds_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@

describe "Adding a new seed", :js do
before do
fill_autocomplete "crop", with: "mai"
fill_autocomplete "crop", with: "maiz"
CloCkWeRX marked this conversation as resolved.
Show resolved Hide resolved
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?"
Expand Down
2 changes: 1 addition & 1 deletion spec/views/plantings/_form.html.haml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading