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
Representer patches
Marcello Rocha0b0d226df833
diff --git a/modules/backlogs/lib/open_project/backlogs/patches/api/work_package_representer.rb b/modules/backlogs/lib/open_project/backlogs/patches/api/work_package_representer.rbindex 1d09f055fdd..d84b6df632e 100644--- a/modules/backlogs/lib/open_project/backlogs/patches/api/work_package_representer.rb+++ b/modules/backlogs/lib/open_project/backlogs/patches/api/work_package_representer.rb@@ -41,24 +41,35 @@ module OpenProject::Backlogsproperty :story_points,render_nil: true,- skip_render: ->(*) { !(backlogs_enabled? && type && type.passes_attribute_constraint?(:story_points)) }+ skip_render: ->(*) {+ !(backlogs_enabled? && type && type.passes_attribute_constraint?(:story_points))+ }property :remaining_time,exec_context: :decorator,render_nil: true,- skip_render: ->(represented:, **) { !represented.backlogs_enabled? }+ skip_render: ->(represented:, **) { !represented.backlogs_enabled? },+ getter: ->(*) do+ datetime_formatter.format_duration_from_hours(represented.remaining_hours, allow_nil: true)+ end++ property :derived_remaining_time,+ exec_context: :decorator,+ render_nil: true,+ skip_render: ->(represented:, **) { !represented.backlogs_enabled? },+ getter: ->(*) do+ datetime_formatter.format_duration_from_hours(represented.derived_remaining_hours, allow_nil: true)+ end# cannot use def here as it wouldn't define the method on the representer- define_method :remaining_time do- datetime_formatter.format_duration_from_hours(represented.remaining_hours,- allow_nil: true)+ define_method :remaining_time= do |value|+ represented.remaining_hours = datetime_formatter+ .parse_duration_to_hours(value, 'remainingTime', allow_nil: true)end- define_method :remaining_time= do |value|- remaining = datetime_formatter.parse_duration_to_hours(value,- 'remainingTime',- allow_nil: true)- represented.remaining_hours = remaining+ define_method :derived_remaining_time= do |value|+ represented.derived_remaining_hours = datetime_formatter+ .parse_duration_to_hours(value, 'derivedRemainingTime', allow_nil: true)endendenddiff --git a/modules/backlogs/lib/open_project/backlogs/patches/api/work_package_schema_representer.rb b/modules/backlogs/lib/open_project/backlogs/patches/api/work_package_schema_representer.rbindex 1bba80d03ca..02f1b388516 100644--- a/modules/backlogs/lib/open_project/backlogs/patches/api/work_package_schema_representer.rb+++ b/modules/backlogs/lib/open_project/backlogs/patches/api/work_package_schema_representer.rb@@ -56,6 +56,12 @@ module OpenProject::Backlogsrequired: false,show_if: ->(*) { represented.project && represented.project.backlogs_enabled? }+ schema :derived_remaining_time,+ type: 'Duration',+ name_source: :derived_remaining_hours,+ required: false,+ show_if: ->(*) { represented.project && represented.project.backlogs_enabled? }+define_method :backlogs_constraint_passed? do |attribute|represented.project&.backlogs_enabled? &&(!represented.type || represented.type.passes_attribute_constraint?(attribute))