diff --git a/app/assets/javascripts/admin/order_cycles/order_cycles.js.erb.coffee b/app/assets/javascripts/admin/order_cycles/order_cycles.js.erb.coffee index 71ab6b9b18..9241517262 100644 --- a/app/assets/javascripts/admin/order_cycles/order_cycles.js.erb.coffee +++ b/app/assets/javascripts/admin/order_cycles/order_cycles.js.erb.coffee @@ -3,12 +3,18 @@ angular.module('admin.orderCycles', ['ngTagsInput', 'admin.indexUtils', 'admin.e require: "ngModel" link: (scope, element, attrs, ngModel) -> $timeout -> - flatpickr(element, Object.assign({}, + fp = flatpickr(element, Object.assign({}, window.FLATPICKR_DATETIME_DEFAULT, { onOpen: (selectedDates, dateStr, instance) -> instance.setDate(ngModel.$modelValue) instance.input.dispatchEvent(new Event('focus', { bubbles: true })); })); + fp.minuteElement.addEventListener "keyup", (e) -> + if !isNaN(event.target.value) + fp.setDate(fp.selectedDates[0].setMinutes(e.target.value), true) + fp.hourElement.addEventListener "keyup", (e) -> + if !isNaN(event.target.value) + fp.setDate(fp.selectedDates[0].setHours(e.target.value), true) .directive 'ofnOnChange', -> (scope, element, attrs) -> diff --git a/spec/features/admin/order_cycles/simple_spec.rb b/spec/features/admin/order_cycles/simple_spec.rb index 03dea7eae9..ee63ede2bb 100644 --- a/spec/features/admin/order_cycles/simple_spec.rb +++ b/spec/features/admin/order_cycles/simple_spec.rb @@ -604,6 +604,16 @@ feature ' end end + scenario "modify the minute of a order cycle with the keyboard, check that the modifications are taken into account" do + order_cycle = create(:simple_order_cycle, name: "Translusent Berries") + login_as_admin_and_visit admin_order_cycles_path + find("#oc#{order_cycle.id}_orders_close_at").click + datetime = Time.at(Time.zone.local(2040, 10, 17, 0o6, 0o0, 0o0)) + input = find(".flatpickr-calendar.open .flatpickr-minute") + input.send_keys datetime.strftime("%M").to_s.strip + expect(page).to have_content "You have unsaved changes" + end + scenario "deleting an order cycle" do order_cycle = create(:simple_order_cycle, name: "Translusent Berries") login_as_admin_and_visit admin_order_cycles_path