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

Force start date before end date with range mode flatpickr #12094

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 5 additions & 4 deletions app/views/admin/reports/_date_range_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
.row.date-range-filter
.alpha.two.columns= label_tag nil, t(:date_range)
.omega.fourteen.columns
= f.text_field "#{field}_gt", :class => 'datetimepicker datepicker-from', :placeholder => t(:start), data: { controller: "flatpickr", "flatpickr-enable-time-value": true, "flatpickr-default-date-value": "startOfDay" }, value: start_date
%span.range-divider
%i.icon-arrow-right
= f.text_field "#{field}_lt", :class => 'datetimepicker datepicker-to', :placeholder => t(:stop), data: { controller: "flatpickr", "flatpickr-enable-time-value": true, "flatpickr-default-date-value": "endOfDay" }, value: end_date
.field-block.omega.four.columns
.date-range-fields{ data: { controller: "flatpickr", "flatpickr-mode-value": "range", "flatpickr-enable-time-value": true , "flatpickr-default-hour": 0 } }
= text_field_tag nil, nil, class: "datepicker fullwidth", data: { "flatpickr-target": "instance", action: "flatpickr_clear@window->flatpickr#clear" }
= text_field_tag "q[#{field}_gt]", nil, data: { "flatpickr-target": "start" }, style: "display: none", value: start_date
= text_field_tag "q[#{field}_lt]", nil, data: { "flatpickr-target": "end" }, style: "display: none", value: end_date
8 changes: 5 additions & 3 deletions spec/system/admin/reports/orders_and_fulfillment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@
it "is precise to time of day, not just date" do
# When I generate a customer report
# with a timeframe that includes one order but not the other
pick_datetime "#q_completed_at_gt", datetime_start1
pick_datetime "#q_completed_at_lt", datetime_end
find("input.datepicker").click
select_dates_from_daterangepicker datetime_start1, datetime_end
find(".shortcut-buttons-flatpickr-button").click # closes flatpickr

find("#display_summary_row").set(false) # hides the summary rows
run_report
Expand All @@ -141,7 +142,8 @@
# 2 rows for order1 + 1 summary row

# setting a time interval to include both orders
pick_datetime "#q_completed_at_gt", datetime_start2
find("input.datepicker").click
select_dates_from_daterangepicker datetime_start2, Time.zone.now
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering why we don't need to close flatpickr here ? Anyway the tests are green, so it's not really important.

run_report
# Then I should see the rows for both orders
expect(all('table.report__table tbody tr').count).to eq(5)
Expand Down
Loading