0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-25 02:30:28 +01:00
discourse-custom-wizard/lib/custom_wizard/extensions/custom_field/preloader.rb

19 Zeilen
522 B
Ruby

2021-03-11 07:30:15 +01:00
# frozen_string_literal: true
module CustomWizardCustomFieldPreloader
def preload_custom_fields(objects, fields)
if objects.present? && cw_fields_enabled?
@cw_klass = objects.first.class.name.underscore
2024-10-16 13:52:03 +02:00
cw_fields.each { |field| fields << field[:name] } if cw_fields.any?
end
super(objects, fields)
end
2021-03-11 07:30:15 +01:00
def cw_fields_enabled?
SiteSetting.custom_wizard_enabled && CustomWizard::CustomField.enabled?
end
2021-03-11 07:30:15 +01:00
def cw_fields
CustomWizard::CustomField.list_by(:klass, @cw_klass)
end
2021-03-11 07:30:15 +01:00
end