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

Initial changes to WorkPackage

Marcello Rocha1aec8e766a6e
diff --git a/modules/backlogs/config/locales/en.yml b/modules/backlogs/config/locales/en.yml
index d11f42e823b..418f195dfe1 100644
--- a/modules/backlogs/config/locales/en.yml
+++ b/modules/backlogs/config/locales/en.yml
@@ -34,6 +34,8 @@ en:
position: "Position"
remaining_hours: "Remaining hours"
remaining_time: "Remaining hours"
+ derived_remaining_hours: "Derived remaining hours"
+ derived_remaining_time: "Derived remaining hours"
story_points: "Story Points"
backlogs_work_package_type: "Backlog type"
diff --git a/modules/backlogs/lib/open_project/backlogs/patches/work_package_patch.rb b/modules/backlogs/lib/open_project/backlogs/patches/work_package_patch.rb
index c77f5c2350f..77e28aaa470 100644
--- a/modules/backlogs/lib/open_project/backlogs/patches/work_package_patch.rb
+++ b/modules/backlogs/lib/open_project/backlogs/patches/work_package_patch.rb
@@ -33,9 +33,10 @@ module OpenProject::Backlogs::Patches::WorkPackagePatch
prepend InstanceMethods
extend ClassMethods
- before_validation :backlogs_before_validation, if: lambda { backlogs_enabled? }
+ before_validation :backlogs_before_validation, if: -> { backlogs_enabled? }
register_journal_formatted_fields(:fraction, 'remaining_hours')
+ register_journal_formatted_fields(:fraction, 'derived_remaining_hours')
register_journal_formatted_fields(:decimal, 'story_points')
register_journal_formatted_fields(:decimal, 'position')
@@ -43,12 +44,17 @@ module OpenProject::Backlogs::Patches::WorkPackagePatch
allow_nil: true,
greater_than_or_equal_to: 0,
less_than: 10_000,
- if: lambda { backlogs_enabled? }
+ if: -> { backlogs_enabled? }
validates_numericality_of :remaining_hours, only_integer: false,
allow_nil: true,
greater_than_or_equal_to: 0,
- if: lambda { backlogs_enabled? }
+ if: -> { backlogs_enabled? }
+
+ validates_numericality_of :derived_remaining_hours, only_integer: false,
+ allow_nil: true,
+ greater_than_or_equal_to: 0,
+ if: -> { backlogs_enabled? }
include OpenProject::Backlogs::List
end
@@ -106,9 +112,7 @@ module OpenProject::Backlogs::Patches::WorkPackagePatch
if is_story?
Story.find(id)
elsif is_task?
- ancestors
- .where(type_id: Story.types)
- .first
+ ancestors.where(type_id: Story.types).first
end
end