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
Move Project custom field restriction logic to the JournalChanges module
Dombi Attila8efccef47fef
diff --git a/lib_static/plugins/acts_as_journalized/lib/acts/journalized/journable_differ.rb b/lib_static/plugins/acts_as_journalized/lib/acts/journalized/journable_differ.rbindex 23dbd38f865..51ae9205edf 100644--- a/lib_static/plugins/acts_as_journalized/lib/acts/journalized/journable_differ.rb+++ b/lib_static/plugins/acts_as_journalized/lib/acts/journalized/journable_differ.rb@@ -84,10 +84,6 @@ module Acts::Journalizednew_journals = changed.send(association).map(&:attributes)old_journals = original&.send(association)&.map(&:attributes) || []- journable = changed.journable- new_journals = allowed_attributes(journable, new_journals, key)- old_journals = allowed_attributes(journable, old_journals, key)-changes_on_association(new_journals, old_journals, association_name, key, value)end@@ -101,20 +97,6 @@ module Acts::Journalizedto_changes_format(changes, association_name.to_s)end- def allowed_attributes(journable, journals, key)- # Filter out Project attributes that are not enabled on the project- if journable.class.name == "Project" && key == :custom_field_id- allowed_custom_field_ids =- journable.project_custom_field_project_mappings.pluck(:custom_field_id)-- journals.select! do |attributes|- attributes["custom_field_id"].in?(allowed_custom_field_ids)- end- end-- journals- end-def added_references(merged_references)merged_references.select { |_, (old_value, new_value)| old_value.to_s.empty? && new_value.present? }diff --git a/lib_static/plugins/acts_as_journalized/lib/journal_changes.rb b/lib_static/plugins/acts_as_journalized/lib/journal_changes.rbindex 5371fa17773..06a7c7a65cc 100644--- a/lib_static/plugins/acts_as_journalized/lib/journal_changes.rb+++ b/lib_static/plugins/acts_as_journalized/lib/journal_changes.rb@@ -49,8 +49,7 @@ module JournalChangesendif journable&.customizable?- @changes.merge!(- ::Acts::Journalized::JournableDiffer.association_changes(+ customizable_changes = ::Acts::Journalized::JournableDiffer.association_changes(predecessor,self,'customizable_journals',@@ -58,7 +57,12 @@ module JournalChanges:custom_field_id,:value)- )++ if journable.class.name == "Project"+ remove_disabled_project_custom_fields!(customizable_changes)+ end++ @changes.merge!(customizable_changes)endif has_file_links?@@ -84,4 +88,14 @@ module JournalChangesend@changesend++ private++ def remove_disabled_project_custom_fields!(customizable_changes)+ allowed_custom_field_keys = journable+ .project_custom_field_project_mappings+ .map{ |c| "custom_fields_#{c.custom_field_id}" }++ customizable_changes.delete_if { |key| !key.in?(allowed_custom_field_keys) }+ endend