demarches-normaliennes/app/components/editable_champ/editable_champ_base_component.rb

39 lines
751 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class EditableChamp::EditableChampBaseComponent < ApplicationComponent
2023-05-05 09:13:05 +02:00
include Dsfr::InputErrorable
attr_reader :attribute
def initialize(form:, champ:, seen_at: nil, opts: {})
@form, @champ, @seen_at, @opts = form, champ, seen_at, opts
@attribute = :value
end
def dsfr_champ_container
:div
end
def dsfr_input_classname
nil
end
def describedby_id
@champ.describedby_id
end
2024-11-27 18:06:48 +01:00
def fieldset_aria_opts
if dsfr_champ_container == :fieldset
labelledby = [@champ.labelledby_id]
labelledby << describedby_id if @champ.description.present?
{
2024-11-28 10:14:01 +01:00
aria: { labelledby: labelledby.join(' ') },
role: 'group'
2024-11-27 18:06:48 +01:00
}
else
{}
end
end
end