akkounts/app/components/form_elements/fieldset_resettable_setting_component.rb
Râu Cao fff6dea100
All checks were successful
continuous-integration/drone/push Build is passing
Add support for placeholder attribute to component
2024-06-20 13:54:59 +02:00

22 lines
638 B
Ruby

# frozen_string_literal: true
module FormElements
class FieldsetResettableSettingComponent < ViewComponent::Base
def initialize(tag: "li", key:, type: :text, title:, description: nil, placeholder: nil)
@tag = tag
@positioning = :vertical
@title = title
@description = description
@key = key.to_sym
@type = type
@resettable = is_resettable?(@key)
@placeholder = placeholder
end
def is_resettable?(key)
default_value = Setting.get_field(key)[:default]
default_value.present? && (default_value != Setting.send(key))
end
end
end