2020-11-09 07:50:17 +01:00
|
|
|
module CustomWizardCustomFieldPreloader
|
|
|
|
def preload_custom_fields(objects, fields)
|
2020-12-01 08:20:02 +01:00
|
|
|
if objects.present? && cw_fields_enabled?
|
2020-11-09 07:50:17 +01:00
|
|
|
@cw_klass = objects.first.class.name.underscore
|
|
|
|
if cw_fields.any?
|
|
|
|
cw_fields.each do |field|
|
|
|
|
fields << field.name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
super(objects, fields)
|
|
|
|
end
|
|
|
|
|
2020-12-01 08:20:02 +01:00
|
|
|
def cw_fields_enabled?
|
|
|
|
SiteSetting.custom_wizard_enabled && CustomWizard::CustomField.enabled?
|
|
|
|
end
|
|
|
|
|
2020-11-09 07:50:17 +01:00
|
|
|
def cw_fields
|
2020-11-09 08:48:55 +01:00
|
|
|
CustomWizard::CustomField.list_by(:klass, @cw_klass)
|
2020-11-09 07:50:17 +01:00
|
|
|
end
|
|
|
|
end
|