Transform negative duration to absolute

https://community.openproject.org/wp/44219
pull/11318/head
Oliver Günther 2 years ago
parent 7c47e070e5
commit 69813a8a90
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 3
      frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
  2. 11
      spec/features/work_packages/details/date_editor_spec.rb

@ -213,7 +213,8 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVi
.pipe(
this.untilDestroyed(),
debounceTime(500),
map((value) => (value === '' ? null : parseInt(value, 10))),
map((value) => (value === '' ? null : Math.abs(parseInt(value, 10)))),
filter((val) => val === null || !Number.isNaN(val)),
filter((val) => val !== this.duration),
)
.subscribe((value) => this.applyDurationChange(value));

@ -233,6 +233,17 @@ describe 'date inplace editor',
start_date.expect_state_text "#{Time.zone.today.strftime('%Y-%m-%d')} - #{Time.zone.today.strftime('%Y-%m-%d')}"
end
it 'can set a negative duration which gets transformed (Regression #44219)' do
start_date.activate!
start_date.expect_active!
start_date.datepicker.expect_visible
start_date.datepicker.set_duration -128
start_date.datepicker.focus_start_date
start_date.datepicker.expect_duration 128
end
it 'saves the date when clearing and then confirming' do
start_date.activate!

Loading…
Cancel
Save