mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-02 02:11:33 +00:00
Only call confirmRefresh() on time, on date range change
Previously, when changing the date range, we had several modals that opened. Now, the `confirmRefresh()` method should be open only one time. Update specs as well: - use the method `accept_confirm` - Removing pending and sleep as the spec is now green
This commit is contained in:
@@ -38,6 +38,8 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
|
||||
|
||||
return unless moment($scope.formattedStartDate).isValid() and moment($scope.formattedEndDate).isValid()
|
||||
|
||||
return unless $scope.confirmRefresh()
|
||||
|
||||
$scope.loadOrders()
|
||||
$scope.loadLineItems()
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
%br
|
||||
%div{ data: { controller: "flatpickr", "flatpickr-mode-value": "range", "flatpickr-default-date": "{{ [startDate, endDate] }}" } }
|
||||
%input.datepicker.fullwidth{ class: "datepicker", data: { "flatpickr-target": "instance" } }
|
||||
%input{ type: "text", id: 'start_date_filter', 'ng-model': "startDate", data: { "flatpickr-target": "start" }, style: "display: none;", "confirm-change": "confirmRefresh()" }
|
||||
%input{ type: "text", id: 'end_date_filter', 'ng-model': "endDate", data: { "flatpickr-target": "end" }, style: "display: none;", "confirm-change": "confirmRefresh()"}
|
||||
%input{ type: "text", id: 'start_date_filter', 'ng-model': "startDate", data: { "flatpickr-target": "start" }, style: "display: none;" }
|
||||
%input{ type: "text", id: 'end_date_filter', 'ng-model': "endDate", data: { "flatpickr-target": "end" }, style: "display: none;" }
|
||||
.one.column
|
||||
.filter_select{ :class => "three columns" }
|
||||
%label{ :for => 'supplier_filter' }
|
||||
|
||||
@@ -612,8 +612,7 @@ describe '
|
||||
end
|
||||
|
||||
it "shows a dialog and ignores changes when confirm dialog is accepted" do
|
||||
page.driver.accept_modal :confirm,
|
||||
text: "Unsaved changes exist and will be lost if you continue." do
|
||||
accept_confirm "Unsaved changes exist and will be lost if you continue." do
|
||||
find("input.datepicker").click
|
||||
select_dates_from_daterangepicker(today - 9.days, today)
|
||||
end
|
||||
@@ -624,14 +623,10 @@ describe '
|
||||
end
|
||||
|
||||
it "shows a dialog and keeps changes when confirm dialog is rejected" do
|
||||
pending "https://github.com/openfoodfoundation/openfoodnetwork/issues/9757"
|
||||
|
||||
page.driver.dismiss_modal :confirm,
|
||||
text: "Unsaved changes exist and will be lost if you continue." do
|
||||
dismiss_confirm "Unsaved changes exist and will be lost if you continue." do
|
||||
find("input.datepicker").click
|
||||
select_dates_from_daterangepicker(today - 9.days, today)
|
||||
end
|
||||
sleep 2
|
||||
expect(page).to have_selector "#save-bar"
|
||||
within("tr#li_#{li2.id} td.quantity") do
|
||||
expect(page).to have_selector "input[name=quantity].ng-dirty"
|
||||
|
||||
Reference in New Issue
Block a user