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
Introduce custom_field_values_to_validate method to control section based validation
Dombi Attila0b3059928285
diff --git a/app/models/projects/acts_as_customizable_patches.rb b/app/models/projects/acts_as_customizable_patches.rbindex 772d07a2f7a..dd63a7c89e8 100644--- a/app/models/projects/acts_as_customizable_patches.rb+++ b/app/models/projects/acts_as_customizable_patches.rb@@ -163,14 +163,15 @@ module Projects::ActsAsCustomizablePatcheswith_all_available_custom_fields { available_custom_fields }end- def custom_fields_to_validate- custom_fields = available_custom_fields+ def custom_field_values_to_validate# Limit the set of available custom fields when the validation is limited to a sectionif _limit_custom_fields_validation_to_section_id- custom_fields =- custom_fields.where(custom_field_section_id: _limit_custom_fields_validation_to_section_id)+ custom_field_values.select do |cfv|+ cfv.custom_field.custom_field_section_id == _limit_custom_fields_validation_to_section_id+ end+ else+ custom_field_valuesend- custom_fieldsend# we need to query the available custom fields on a global level when updating custom field valuesdiff --git a/lib_static/plugins/acts_as_customizable/lib/acts_as_customizable.rb b/lib_static/plugins/acts_as_customizable/lib/acts_as_customizable.rbindex 197fd31b8ad..e95c846b5b2 100644--- a/lib_static/plugins/acts_as_customizable/lib/acts_as_customizable.rb+++ b/lib_static/plugins/acts_as_customizable/lib/acts_as_customizable.rb@@ -233,14 +233,13 @@ module Redmineself.custom_field_values = new_valuesend- def custom_fields_to_validate+ def custom_field_values_to_validatecustom_field_valuesenddef validate_custom_valuesset_default_values! if new_record?-- custom_fields_to_validate+ custom_field_values_to_validate.reject(&:marked_for_destruction?).select(&:invalid?).each { |custom_value| add_custom_value_errors! custom_value }