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
Restore adding array-style accessing
Oliver Günther3eff4f1ace54
diff --git a/app/models/user_preference.rb b/app/models/user_preference.rbindex d925a72dcee..97e7245fdd1 100644--- a/app/models/user_preference.rb+++ b/app/models/user_preference.rb@@ -55,9 +55,6 @@ class UserPreference < ApplicationRecordendend- # Allow previous array-style accessing as well- # delegate :[], :[]=, to: :settings-### We respond to all methods as we retrieve# the key from settings@@ -65,6 +62,22 @@ class UserPreference < ApplicationRecordtrueend+ def [](attr_name)+ if attribute?(attr_name)+ super+ else+ send attr_name+ end+ end++ def []=(attr_name, value)+ if attribute?(attr_name)+ super+ else+ send :"#{attr_name}=", value+ end+ end+def comments_sortingsettings.fetch(:comments_sorting, OpenProject::Configuration.default_comment_sort_order)end@@ -96,7 +109,7 @@ class UserPreference < ApplicationRecordalias :auto_hide_popups :auto_hide_popups?def comments_in_reverse_order=(value)- others[:comments_sorting] = to_boolean(value) ? 'desc' : 'asc'+ settings[:comments_sorting] = to_boolean(value) ? 'desc' : 'asc'enddef time_zone@@ -116,6 +129,10 @@ class UserPreference < ApplicationRecordActiveRecord::Type::Boolean.new.cast(value)end+ def attribute?(name)+ %i[user user_id].include?(name.to_sym)+ end+def init_settingsself.settings ||= {}end