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

Disable the start date when a previous phase defines a finish date.

Dombi Attilad2b6b41986fc
diff --git a/app/forms/projects/life_cycles/form.rb b/app/forms/projects/life_cycles/form.rb
index 4fc9ae2e4e7..b8be000f47f 100644
--- a/app/forms/projects/life_cycles/form.rb
+++ b/app/forms/projects/life_cycles/form.rb
@@ -55,13 +55,17 @@ module Projects::LifeCycles
def start_date_input(form)
data = datepicker_attributes[:data]
- value = model.start_date || model.start_date_before_type_cast
+ value = model.start_date || default_start_date || model.start_date_before_type_cast
+ disabled = default_start_date.present?
+ caption = disabled ? I18n.t("activerecord.attributes.project/phase.start_date_caption") : nil
input_attributes = {
name: :start_date,
label: attribute_name(:start_date),
+ disabled:,
+ caption:,
value:,
data: data.merge("overview--project-life-cycles-form-target": "startDate"),
- show_clear_button: value.present?
+ show_clear_button: value.present? && !disabled
}
form.text_field **datepicker_attributes, **input_attributes
end
@@ -85,12 +89,20 @@ module Projects::LifeCycles
label: attribute_name(:duration),
type: :number,
inset: true,
+ disabled: true,
value: model.duration,
trailing_visual: { text: { text: I18n.t("datetime.units.day", count: model.duration) } },
- data: { "overview--project-life-cycles-form-target": "duration" },
- show_clear_button: model.duration.present?
+ data: { "overview--project-life-cycles-form-target": "duration" }
}
form.text_field **input_attributes
end
+
+ def default_start_date
+ model.project
+ .available_phases
+ .select { it.position < model.position }
+ .filter_map(&:start_date)
+ .last
+ end
end
end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 1440d7047ee..c1303313b1a 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1052,6 +1052,7 @@ en:
definition: "Definition"
duration: "Duration"
start_date: "Start date"
+ start_date_caption: "Follows the previous phase."
finish_date: "Finish date"
project/phase_definition:
name: "Name"
@@ -1367,11 +1368,9 @@ en:
attributes:
start_date:
must_be_before_finish_date: "must be before the finish date."
+ non_continuous_dates: "can't be earlier than the previous phase's end date."
finish_date:
must_be_after_start_date: "must be after the start date."
- date_range:
- non_continuous_dates: "can't be earlier than the previous phase's end date."
- incomplete: "is incomplete."
query:
attributes:
project: