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

Revert commit d2a6ba2a04fe038f4f008214997e931091971cea

Henriette Darge1f99c6b0b7e0
diff --git a/app/components/work_packages/date_picker/dialog_content_component.html.erb b/app/components/work_packages/date_picker/dialog_content_component.html.erb
index 58f5a997798..96124d1026c 100644
--- a/app/components/work_packages/date_picker/dialog_content_component.html.erb
+++ b/app/components/work_packages/date_picker/dialog_content_component.html.erb
@@ -62,7 +62,7 @@
first_row.with_column(mb: 1) do
render(Primer::Alpha::CheckBox.new(name: "work_package[ignore_non_working_days]",
label: I18n.t("work_packages.datepicker_modal.ignore_non_working_days.title"),
- checked: !ignore_non_working_days?,
+ checked: !work_package.ignore_non_working_days,
disabled: disabled?,
value: 0,
unchecked_value: 1,
@@ -77,18 +77,15 @@
work_package:,
focused_field:,
touched_field_map:,
- disabled: disabled?,
- start_date:,
- due_date:,
- duration:))
+ disabled: disabled?))
end
body.with_row(mb: 3) do
helpers.angular_component_tag "opce-wp-modal-date-picker",
inputs: {
- start_date: start_date,
- due_date: due_date,
- ignore_non_working_days: ignore_non_working_days?,
+ start_date: work_package.start_date,
+ due_date: work_package.due_date,
+ ignore_non_working_days: work_package.ignore_non_working_days,
schedule_manually:,
is_schedulable: !disabled?
}
diff --git a/app/components/work_packages/date_picker/dialog_content_component.rb b/app/components/work_packages/date_picker/dialog_content_component.rb
index 4916005679a..fe83b97af4f 100644
--- a/app/components/work_packages/date_picker/dialog_content_component.rb
+++ b/app/components/work_packages/date_picker/dialog_content_component.rb
@@ -64,38 +64,6 @@ module WorkPackages
!schedule_manually
end
- def ignore_non_working_days?
- if params[:work_package].present? && params[:work_package][:ignore_non_working_days].present?
- ActiveModel::Type::Boolean.new.cast((params[:work_package][:ignore_non_working_days]))
- else
- work_package.ignore_non_working_days
- end
- end
-
- def start_date
- if params[:work_package].present? && params[:work_package][:start_date].present?
- params[:work_package][:start_date]
- else
- work_package.start_date
- end
- end
-
- def due_date
- if params[:work_package].present? && params[:work_package][:due_date].present?
- params[:work_package][:due_date]
- else
- work_package.due_date
- end
- end
-
- def duration
- if params[:work_package].present? && params[:work_package][:duration].present?
- params[:work_package][:duration]
- else
- work_package.duration
- end
- end
-
def show_banner?
true # TODO
end
diff --git a/app/forms/work_packages/date_picker/form.rb b/app/forms/work_packages/date_picker/form.rb
index 09c979982ee..174763ee43f 100644
--- a/app/forms/work_packages/date_picker/form.rb
+++ b/app/forms/work_packages/date_picker/form.rb
@@ -49,9 +49,6 @@ module WorkPackages
attr_reader :work_package
def initialize(work_package:,
- start_date:,
- due_date:,
- duration:,
disabled:,
focused_field: :start_date,
touched_field_map: {})
@@ -60,17 +57,14 @@ module WorkPackages
@work_package = work_package
@focused_field = focused_field_by_selection(focused_field)
@touched_field_map = touched_field_map
- @start_date = start_date
- @due_date = due_date
- @duration = duration
@disabled = disabled
end
form do |query_form|
query_form.group(layout: :horizontal) do |group|
- text_field(group, name: :start_date, label: I18n.t("attributes.start_date"), value: @start_date)
- text_field(group, name: :due_date, label: I18n.t("attributes.due_date"), value: @due_date)
- text_field(group, name: :duration, label: I18n.t("activerecord.attributes.work_package.duration"), value: @duration)
+ text_field(group, name: :start_date, label: I18n.t("attributes.start_date"))
+ text_field(group, name: :due_date, label: I18n.t("attributes.due_date"))
+ text_field(group, name: :duration, label: I18n.t("activerecord.attributes.work_package.duration"))
hidden_touched_field(group, name: :start_date)
hidden_touched_field(group, name: :due_date)
@@ -91,11 +85,10 @@ module WorkPackages
def text_field(group,
name:,
- label:,
- value:)
+ label:)
text_field_options = default_field_options(name).merge(
name:,
- value: field_value(name, value),
+ value: field_value(name),
disabled: @disabled,
label:,
validation_message: validation_message(name)
@@ -131,12 +124,10 @@ module WorkPackages
@touched_field_map["#{name}_touched"] || false
end
- def field_value(name, value = nil)
+ def field_value(name)
errors = @work_package.errors.where(name)
if (user_value = errors.map { |error| error.options[:value] }.find { !_1.nil? })
user_value
- elsif value.present?
- value
else
@work_package.public_send(name)
end