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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Keep current due date when changing "Working days only"
Christophe Bliard405ee097f098
diff --git a/app/services/work_packages/set_attributes_service.rb b/app/services/work_packages/set_attributes_service.rbindex aab4b85e677..fe4588b7b6a 100644--- a/app/services/work_packages/set_attributes_service.rb+++ b/app/services/work_packages/set_attributes_service.rb@@ -416,14 +416,22 @@ class WorkPackages::SetAttributesService < BaseServices::SetAttributes# this method is only called by #update_dates_from_self when there are no childrenif work_package.due_date_came_from_user?work_package.due_date- elsif work_package.duration- days.due_date(min_start, work_package.duration)- elsif work_package.due_date+ elsif reuse_current_due_date?# if due date is before start date, then start is used as due date.[min_start, work_package.due_date].max+ elsif work_package.duration+ days.due_date(min_start, work_package.duration)endend+ def reuse_current_due_date?+ return false if work_package.due_date.nil?+ return true if work_package.ignore_non_working_days_came_from_user?++ # use due date only if duration cannot be used+ work_package.duration.nil?+ end+def work_packagemodelenddiff --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.tsindex 5baa293a8d8..29686e62a0e 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@@ -461,11 +461,6 @@ export default class PreviewController extends DialogPreviewController {return;}- if (!this.scheduleManuallyValue) {- // Fix the start date to avoid that it gets changed accidentally- this.markTouched('start_date');- }-if (this.isBeingEdited('start_date')) {this.untouchFieldsWhenStartDateIsEdited();} else if (this.isBeingEdited('due_date')) {diff --git a/spec/features/work_packages/datepicker/datepicker_follows_relation_spec.rb b/spec/features/work_packages/datepicker/datepicker_follows_relation_spec.rbindex f84f70eedfc..e39e0896fc9 100644--- a/spec/features/work_packages/datepicker/datepicker_follows_relation_spec.rb+++ b/spec/features/work_packages/datepicker/datepicker_follows_relation_spec.rb@@ -92,7 +92,7 @@ RSpec.describe "Datepicker logic on follow relationships", :js, with_settings: {datepicker.expect_working_days_only falsedatepicker.expect_start_date "2024-02-03", disabled: true- datepicker.expect_due_date "2024-02-06"+ datepicker.expect_due_date "2024-02-08" # did not changedatepicker.expect_disabled Date.parse("2024-02-01")datepicker.expect_disabled Date.parse("2024-02-02") # predecessor's due datedatepicker.expect_not_disabled Date.parse("2024-02-03") # Saturday is non-working day but ignoreddiff --git a/spec/services/work_packages/set_attributes_service_spec.rb b/spec/services/work_packages/set_attributes_service_spec.rbindex 83b99119f1c..781d27f7267 100644--- a/spec/services/work_packages/set_attributes_service_spec.rb+++ b/spec/services/work_packages/set_attributes_service_spec.rb@@ -2002,7 +2002,7 @@ RSpec.describe WorkPackages::SetAttributesService,let(:expected_attributes) do{start_date: next_monday,- due_date: next_monday + 7.days+ due_date: WorkPackages::Shared::WorkingDays.new.soonest_working_day(Time.zone.today + 5.days)}endenddiff --git a/spec/services/work_packages/update_service_integration_spec.rb b/spec/services/work_packages/update_service_integration_spec.rbindex 19efb856ea4..126a49524dd 100644--- a/spec/services/work_packages/update_service_integration_spec.rb+++ b/spec/services/work_packages/update_service_integration_spec.rb@@ -1317,13 +1317,13 @@ RSpec.describe WorkPackages::UpdateService, "integration", type: :model dolet(:attributes) { { ignore_non_working_days: true } }it "moves the start date earlier to start on a non-working day " \- "and moves the due date too to keep same duration" do+ "and keeps the current due date and updates the duration accordingly" doexpect(subject).to be_successexpect_work_packages_after_reload([work_package, predecessor], <<~TABLE)| subject | MTWTFSSmtwtfss | scheduling mode | days counting| predecessor | XX | manual | working days only- | work_package | XXX | automatic | all days+ | work_package | XXXXX | automatic | all daysTABLEendend@@ -1367,14 +1367,13 @@ RSpec.describe WorkPackages::UpdateService, "integration", type: :model dolet(:attributes) { { ignore_non_working_days: false } }- it "moves the start date earlier to start on a non-working day " \- "and moves the due date too to keep same duration" do+ it "moves the dates to the next working day and adjusts the duration accordingly" doexpect(subject).to be_successexpect_work_packages_after_reload([work_package, predecessor], <<~TABLE)- | subject | MTWTFSSmtwtfss | duration | scheduling mode | days counting- | predecessor | XX | 2 | manual | working days only- | work_package | XXXXX..XXX | 8 | automatic | working days only+ | subject | MTWTFSSmtwtfss | duration | scheduling mode | days counting+ | predecessor | XX | 2 | manual | working days only+ | work_package | XXXXX..X | 6 | automatic | working days onlyTABLEendend