Redmine 4.1.1

This commit is contained in:
Manuel Cillero 2020-11-22 21:20:06 +01:00
parent 33e7b881a5
commit 3d976f1b3b
1593 changed files with 36180 additions and 19489 deletions

View file

@ -1,2 +1,4 @@
# frozen_string_literal: true
require File.dirname(__FILE__) + '/lib/acts_as_customizable'
ActiveRecord::Base.send(:include, Redmine::Acts::Customizable)

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006-2017 Jean-Philippe Lang
# Copyright (C) 2006-2019 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -27,7 +29,7 @@ module Redmine
return if self.included_modules.include?(Redmine::Acts::Customizable::InstanceMethods)
cattr_accessor :customizable_options
self.customizable_options = options
has_many :custom_values, lambda {includes(:custom_field).order("#{CustomField.table_name}.position")},
has_many :custom_values, lambda {includes(:custom_field)},
:as => :customized,
:inverse_of => :customized,
:dependent => :delete_all,
@ -104,6 +106,12 @@ module Redmine
@custom_field_values_changed == true
end
# Should the default custom field value be set for the given custom_value?
# By default, default custom field value is set for new objects only
def set_custom_field_default?(custom_value)
new_record?
end
def custom_value_for(c)
field_id = (c.is_a?(CustomField) ? c.id : c.to_i)
custom_values.detect {|v| v.custom_field_id == field_id }