Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Transform negative duration to absolute

Oliver Günther69813a8a90af
diff --git a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
index 3da29a5d8ca..99d8b2fa233 100644
--- a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
+++ b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
@@ -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));
diff --git a/spec/features/work_packages/details/date_editor_spec.rb b/spec/features/work_packages/details/date_editor_spec.rb
index 05cd0f1e438..ed146bb5a31 100644
--- a/spec/features/work_packages/details/date_editor_spec.rb
+++ b/spec/features/work_packages/details/date_editor_spec.rb
@@ -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!