0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-10 04:12:53 +01:00
discourse-custom-wizard/lib/custom_wizard/field.rb
Angus McLeod d26744cf56 Schema handling updates
- support custom field types
- move client schema to seperate helper
- handle schema defaults properly
2020-04-16 12:04:27 +10:00

59 Zeilen
1 KiB
Ruby

class CustomWizard::Field
def self.types
@types ||= {
text: {
min_length: nil
},
textarea: {
min_length: nil
},
composer: {
min_length: nil
},
text_only: {},
number: {},
checkbox: {},
url: {
min_length: nil
},
upload: {
file_types: '.jpg,.png'
},
dropdown: {
prefill: nil,
content: nil
},
tag: {
limit: nil,
prefill: nil,
content: nil
},
category: {
limit: 1,
property: 'id',
prefill: nil,
content: nil
},
group: {
prefill: nil,
content: nil
},
user_selector: {}
}
end
def self.require_assets
@require_assets ||= {}
end
def self.add_assets(type, plugin = nil, asset_paths = [], opts={})
if type
types[type] ||= {}
types[type] = opts[:type_opts] if opts[:type_opts].present?
end
if plugin && asset_paths
require_assets[plugin] = asset_paths
end
end
end