class Maglev::Editor::Settings::BaseComponent
def after_initialize
def after_initialize # to be overridden by subclasses end
def call
def call content_tag(:div, "Unknown setting type: #{definition.type} / #{definition.options}", class: 'bg-red-500 text-white p-4 rounded-md') end
def default_placeholder
def default_placeholder ::I18n.t("maglev.editor.settings.#{definition.type}.placeholder") end
def fetch_path(name, context = {})
def fetch_path(name, context = {}) path_or_proc = paths.fetch(name, nil) path_or_proc.is_a?(Proc) ? path_or_proc.call(definition, context) : path_or_proc end
def initialize(definition:, value:, paths:, scope:)
def initialize(definition:, value:, paths:, scope:) @definition = definition @value = value @paths = paths @input_scope = scope[:input] @i18n_scope = scope[:i18n] after_initialize end
def input_name
def input_name "#{input_scope}[#{definition.id}]" end
def input_source
def input_source input_name.parameterize.underscore end
def label
def label ::I18n.t("#{i18n_scope}.settings.#{definition.id}", default: definition.label) end
def placeholder
def placeholder ::I18n.t("#{i18n_scope}.settings.#{definition.id}_placeholder", default: default_placeholder) end