2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-04-24 15:16:04 +02:00
|
|
|
class Dsfr::ToggleComponent < ApplicationComponent
|
2024-11-13 19:05:05 +01:00
|
|
|
attr_reader :target
|
|
|
|
attr_reader :title
|
|
|
|
attr_reader :hint
|
|
|
|
attr_reader :toggle_labels
|
|
|
|
attr_reader :disabled
|
|
|
|
attr_reader :data
|
|
|
|
attr_reader :extra_class_names
|
|
|
|
|
2024-05-28 16:40:15 +02:00
|
|
|
def initialize(form:, target:, title:, disabled: nil, hint: nil, toggle_labels: { checked: 'Activé', unchecked: 'Désactivé' }, opt: nil, extra_class_names: nil)
|
2023-04-24 15:16:04 +02:00
|
|
|
@form = form
|
|
|
|
@target = target
|
|
|
|
@title = title
|
|
|
|
@hint = hint
|
|
|
|
@disabled = disabled
|
2024-02-15 10:58:05 +01:00
|
|
|
@toggle_labels = toggle_labels
|
2024-11-13 19:05:05 +01:00
|
|
|
@data = opt
|
2024-05-28 16:40:15 +02:00
|
|
|
@extra_class_names = extra_class_names
|
2023-04-24 15:16:04 +02:00
|
|
|
end
|
2024-02-15 10:58:05 +01:00
|
|
|
|
2024-11-13 19:05:05 +01:00
|
|
|
private
|
|
|
|
|
|
|
|
def input_id
|
|
|
|
dom_id(@form.object, target)
|
|
|
|
end
|
2023-04-24 15:16:04 +02:00
|
|
|
end
|