fix(input): don't show success feedback when value was not set
This commit is contained in:
parent
8dc47c1b93
commit
21dc77e587
5 changed files with 16 additions and 8 deletions
|
@ -6,6 +6,8 @@ class Dsfr::InputComponent < ApplicationComponent
|
||||||
delegate :object, to: :@form
|
delegate :object, to: :@form
|
||||||
delegate :errors, to: :object
|
delegate :errors, to: :object
|
||||||
|
|
||||||
|
attr_reader :attribute
|
||||||
|
|
||||||
# use it to indicate detailed about the inputs, ex: https://www.systeme-de-design.gouv.fr/elements-d-interface/modeles-et-blocs-fonctionnels/demande-de-mot-de-passe
|
# use it to indicate detailed about the inputs, ex: https://www.systeme-de-design.gouv.fr/elements-d-interface/modeles-et-blocs-fonctionnels/demande-de-mot-de-passe
|
||||||
# it uses aria-describedby on input and link it to yielded content
|
# it uses aria-describedby on input and link it to yielded content
|
||||||
renders_one :describedby
|
renders_one :describedby
|
||||||
|
|
|
@ -23,7 +23,7 @@ module Dsfr
|
||||||
|
|
||||||
{
|
{
|
||||||
"#{dsfr_group_classname}--error" => errors_on_attribute?,
|
"#{dsfr_group_classname}--error" => errors_on_attribute?,
|
||||||
"#{dsfr_group_classname}--valid" => !errors_on_attribute? && errors_on_another_attribute?
|
"#{dsfr_group_classname}--valid" => !errors_on_attribute? && errors_on_another_attribute? && object.public_send(attribute).present?
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -51,9 +51,9 @@ module Dsfr
|
||||||
def attribute_or_rich_body
|
def attribute_or_rich_body
|
||||||
case @input_type
|
case @input_type
|
||||||
when :rich_text_area
|
when :rich_text_area
|
||||||
@attribute.to_s.sub(/\Arich_/, '').to_sym
|
attribute.to_s.sub(/\Arich_/, '').to_sym
|
||||||
else
|
else
|
||||||
@attribute
|
attribute
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
class EditableChamp::ChampLabelComponent < ApplicationComponent
|
class EditableChamp::ChampLabelComponent < ApplicationComponent
|
||||||
include Dsfr::InputErrorable
|
include Dsfr::InputErrorable
|
||||||
|
|
||||||
|
attr_reader :attribute
|
||||||
|
|
||||||
def initialize(form:, champ:, seen_at: nil)
|
def initialize(form:, champ:, seen_at: nil)
|
||||||
@form, @champ, @seen_at = form, champ, seen_at
|
@form, @champ, @seen_at = form, champ, seen_at
|
||||||
@attribute = :value
|
@attribute = :value
|
||||||
|
|
|
@ -4,6 +4,8 @@ class EditableChamp::ChampLabelContentComponent < ApplicationComponent
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
include Dsfr::InputErrorable
|
include Dsfr::InputErrorable
|
||||||
|
|
||||||
|
attr_reader :attribute
|
||||||
|
|
||||||
def initialize(form:, champ:, seen_at: nil)
|
def initialize(form:, champ:, seen_at: nil)
|
||||||
@form, @champ, @seen_at = form, champ, seen_at
|
@form, @champ, @seen_at = form, champ, seen_at
|
||||||
@attribute = :value
|
@attribute = :value
|
||||||
|
|
|
@ -3,6 +3,13 @@
|
||||||
class EditableChamp::EditableChampBaseComponent < ApplicationComponent
|
class EditableChamp::EditableChampBaseComponent < ApplicationComponent
|
||||||
include Dsfr::InputErrorable
|
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
|
def dsfr_champ_container
|
||||||
:div
|
:div
|
||||||
end
|
end
|
||||||
|
@ -14,9 +21,4 @@ class EditableChamp::EditableChampBaseComponent < ApplicationComponent
|
||||||
def describedby_id
|
def describedby_id
|
||||||
@champ.describedby_id
|
@champ.describedby_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(form:, champ:, seen_at: nil, opts: {})
|
|
||||||
@form, @champ, @seen_at, @opts = form, champ, seen_at, opts
|
|
||||||
@attribute = :value
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue