DEV: Allow setting max_length for field types using the plugin API (#24635)
This commit is contained in:
parent
384a8b17a1
commit
eef93ac926
|
@ -114,7 +114,9 @@ module HasCustomFields
|
|||
get_custom_field_descriptor(key).append_field(target, key, value)
|
||||
end
|
||||
|
||||
def register_custom_field_type(name, type, max_length: DEFAULT_FIELD_DESCRIPTOR.max_length)
|
||||
def register_custom_field_type(name, type, max_length: nil)
|
||||
max_length ||= DEFAULT_FIELD_DESCRIPTOR.max_length
|
||||
|
||||
if Array === type
|
||||
Discourse.deprecate(
|
||||
"Array types for custom fields are deprecated, use type :json instead",
|
||||
|
|
|
@ -552,28 +552,38 @@ class Plugin::Instance
|
|||
end
|
||||
|
||||
# Applies to all sites in a multisite environment. Ignores plugin.enabled?
|
||||
def register_category_custom_field_type(name, type)
|
||||
reloadable_patch { |plugin| Category.register_custom_field_type(name, type) }
|
||||
def register_category_custom_field_type(name, type, max_length: nil)
|
||||
reloadable_patch do |plugin|
|
||||
Category.register_custom_field_type(name, type, max_length: max_length)
|
||||
end
|
||||
end
|
||||
|
||||
# Applies to all sites in a multisite environment. Ignores plugin.enabled?
|
||||
def register_topic_custom_field_type(name, type)
|
||||
reloadable_patch { |plugin| ::Topic.register_custom_field_type(name, type) }
|
||||
def register_topic_custom_field_type(name, type, max_length: nil)
|
||||
reloadable_patch do |plugin|
|
||||
::Topic.register_custom_field_type(name, type, max_length: max_length)
|
||||
end
|
||||
end
|
||||
|
||||
# Applies to all sites in a multisite environment. Ignores plugin.enabled?
|
||||
def register_post_custom_field_type(name, type)
|
||||
reloadable_patch { |plugin| ::Post.register_custom_field_type(name, type) }
|
||||
def register_post_custom_field_type(name, type, max_length: nil)
|
||||
reloadable_patch do |plugin|
|
||||
::Post.register_custom_field_type(name, type, max_length: max_length)
|
||||
end
|
||||
end
|
||||
|
||||
# Applies to all sites in a multisite environment. Ignores plugin.enabled?
|
||||
def register_group_custom_field_type(name, type)
|
||||
reloadable_patch { |plugin| ::Group.register_custom_field_type(name, type) }
|
||||
def register_group_custom_field_type(name, type, max_length: nil)
|
||||
reloadable_patch do |plugin|
|
||||
::Group.register_custom_field_type(name, type, max_length: max_length)
|
||||
end
|
||||
end
|
||||
|
||||
# Applies to all sites in a multisite environment. Ignores plugin.enabled?
|
||||
def register_user_custom_field_type(name, type)
|
||||
reloadable_patch { |plugin| ::User.register_custom_field_type(name, type) }
|
||||
def register_user_custom_field_type(name, type, max_length: nil)
|
||||
reloadable_patch do |plugin|
|
||||
::User.register_custom_field_type(name, type, max_length: max_length)
|
||||
end
|
||||
end
|
||||
|
||||
def register_seedfu_fixtures(paths)
|
||||
|
|
Loading…
Reference in New Issue