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

Correctly touch and untouch fields when duration is edited. Thereby it makes a differences whether the fields have been changed or deleted. Depending on that, the fields is either preserved or overwritten

Henriette Darge9b4b022f267d
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/date-picker/preview.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/date-picker/preview.controller.ts
index 1c0b3cc3b52..941769ff029 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/date-picker/preview.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/date-picker/preview.controller.ts
@@ -499,11 +499,19 @@ export default class PreviewController extends DialogPreviewController {
}
private untouchFieldsWhenDurationIsEdited():void {
- if (this.areBothTouched('start_date', 'due_date')) {
+ if (this.isTouched('start_date')) {
if (this.isValueSet('start_date')) {
this.markUntouched('due_date');
- } else if (this.isValueSet('due_date')) {
+ } else {
+ this.markUntouched('start_date');
+ this.markTouched('due_date');
+ }
+ } else if (this.isTouched('due_date')) {
+ if (this.isValueSet('due_date')) {
this.markUntouched('start_date');
+ } else {
+ this.markUntouched('due_date');
+ this.markTouched('start_date');
}
}
}
diff --git a/spec/features/work_packages/datepicker/datepicker_single_date_mode_logic_spec.rb b/spec/features/work_packages/datepicker/datepicker_single_date_mode_logic_spec.rb
index 7b70ad19ce4..ba931f95a82 100644
--- a/spec/features/work_packages/datepicker/datepicker_single_date_mode_logic_spec.rb
+++ b/spec/features/work_packages/datepicker/datepicker_single_date_mode_logic_spec.rb
@@ -845,36 +845,36 @@ RSpec.describe "Datepicker: Single-date mode logic test cases (WP #61146)", :js,
end
context "and start date is cleared and a duration is set (scenario 23a)" do
- it "preserves the start date" do
+ it "calculates the start date" do
datepicker.expect_start_date "2025-02-12"
datepicker.expect_due_date "2025-02-14"
datepicker.expect_duration "3"
datepicker.set_start_date ""
datepicker.focus_duration
- datepicker.set_duration "3"
+ datepicker.set_duration "2"
- datepicker.expect_start_date "2025-02-12"
+ datepicker.expect_start_date "2025-02-13"
datepicker.expect_due_date "2025-02-14"
- datepicker.expect_duration "3"
+ datepicker.expect_duration "2"
datepicker.expect_duration_highlighted
end
end
context "and finish date is cleared and a duration is set (scenario 23b)" do
- it "preserves the finish date" do
+ it "calculates the finish date" do
datepicker.expect_start_date "2025-02-12"
datepicker.expect_due_date "2025-02-14"
datepicker.expect_duration "3"
datepicker.set_due_date ""
datepicker.focus_duration
- datepicker.set_duration "3"
+ datepicker.set_duration "2"
datepicker.expect_start_date "2025-02-12"
- datepicker.expect_due_date "2025-02-14"
- datepicker.expect_duration "3"
+ datepicker.expect_due_date "2025-02-13"
+ datepicker.expect_duration "2"
datepicker.expect_duration_highlighted
end
@@ -895,7 +895,7 @@ RSpec.describe "Datepicker: Single-date mode logic test cases (WP #61146)", :js,
end
it "can open the datepicker" do
- start_field = wp_table.edit_field(work_package, :start_date)
+ start_field = wp_table.edit_field(work_package, :startDate)
start_field.activate!
start_field.expect_active!
@@ -906,7 +906,7 @@ RSpec.describe "Datepicker: Single-date mode logic test cases (WP #61146)", :js,
datepicker.expect_due_highlighted
datepicker.cancel!
- due_field = wp_table.edit_field(work_package, :due_field)
+ due_field = wp_table.edit_field(work_package, :dueDate)
due_field.activate!
due_field.expect_active!