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
[#64530] API renders formula for calculated values
Tobias Dillmannceee1e83823b
diff --git a/docs/api/apiv3/tags/schemas.yml b/docs/api/apiv3/tags/schemas.ymlindex b42c134a3e9..ef1de2cb830 100644--- a/docs/api/apiv3/tags/schemas.yml+++ b/docs/api/apiv3/tags/schemas.yml@@ -51,6 +51,7 @@ description: |-| minLength | The value of the property must at least contain the specified amount of characters | Integer | 0 || maxLength | The value of the property must at most contain the specified amount of characters | Integer | ∞ || regularExpression | The value of the property must match the given regular expression (if not null) | String | null |+ | formula | If present, contains a formula that is used to calculate the value of the property | String | null || location | If present, contains a reference to the location of the property in the JSON | String | null || description | If present, contains a formattable, human readable description | Formattable | null || deprecated | If present, the client should consider the existence of the property deprecated | Boolean | false |diff --git a/lib/api/decorators/property_schema_representer.rb b/lib/api/decorators/property_schema_representer.rbindex 22bdd291b78..e6928f2106a 100644--- a/lib/api/decorators/property_schema_representer.rb+++ b/lib/api/decorators/property_schema_representer.rb@@ -69,6 +69,7 @@ module API:max_length,:regular_expression,:options,+ :formula,:location,:description,:deprecated@@ -84,6 +85,7 @@ module APIproperty :regular_expression, exec_context: :decoratorproperty :deprecated, exec_context: :decoratorproperty :options, exec_context: :decorator+ property :formula, exec_context: :decorator, render_nil: falseproperty :location, exec_context: :decoratordiff --git a/lib/api/decorators/schema_representer.rb b/lib/api/decorators/schema_representer.rbindex 3ab74e36bbd..f1b116cb902 100644--- a/lib/api/decorators/schema_representer.rb+++ b/lib/api/decorators/schema_representer.rb@@ -63,6 +63,7 @@ module APImax_length: nil,regular_expression: nil,options: {},+ formula: nil,show_if: true,description: nil,deprecated: nil)@@ -77,6 +78,7 @@ module APImax_length,regular_expression,options,+ formula,location,description,deprecated)@@ -299,6 +301,7 @@ module APImax_length,regular_expression,options,+ formula,location,description,deprecated)@@ -317,6 +320,7 @@ module APIschema.max_length = max_lengthschema.regular_expression = regular_expressionschema.options = options+ schema.formula = formulaschemaenddiff --git a/lib/api/v3/utilities/custom_field_injector.rb b/lib/api/v3/utilities/custom_field_injector.rbindex a44c9942073..8a0d2fcce96 100644--- a/lib/api/v3/utilities/custom_field_injector.rb+++ b/lib/api/v3/utilities/custom_field_injector.rb@@ -45,7 +45,8 @@ module API"version" => "Version","list" => "CustomOption","hierarchy" => "CustomField::Hierarchy::Item",- "scored_list" => "CustomField::Hierarchy::Item"+ "scored_list" => "CustomField::Hierarchy::Item",+ "calculated_value" => "CalculatedValue"}.freezeLINK_FORMATS = %w(list user version hierarchy scored_list).freeze@@ -199,7 +200,8 @@ module APImin_length: cf_min_length(custom_field),max_length: cf_max_length(custom_field),regular_expression: cf_regexp(custom_field),- options: cf_options(custom_field)+ options: cf_options(custom_field),+ formula: cf_formula(custom_field)enddef inject_link_value(custom_field, config)@@ -326,6 +328,12 @@ module APIcustom_field.regexp.presenceend+ def cf_formula(custom_field)+ if custom_field.field_format_calculated_value?+ custom_field.formula_string+ end+ end+def cf_options(custom_field){rtl: ("true" if custom_field.content_right_to_left)