only display not_available error message
This commit is contained in:
parent
5129fedac4
commit
dd7af753fe
1 changed files with 16 additions and 2 deletions
|
@ -6,10 +6,24 @@ class TypesDeChampEditor::ConditionsErrorsComponent < ApplicationComponent
|
||||||
private
|
private
|
||||||
|
|
||||||
def errors
|
def errors
|
||||||
@conditions
|
errors = @conditions
|
||||||
.flat_map { |condition| condition.errors(@upper_tdcs) }
|
.flat_map { |condition| condition.errors(@upper_tdcs) }
|
||||||
.map { |error| humanize(error) }
|
|
||||||
.uniq
|
.uniq
|
||||||
|
|
||||||
|
# if a tdc is not available (has been removed for example)
|
||||||
|
# it causes a lot of errors (incompatible type for example)
|
||||||
|
# only the root cause is displayed
|
||||||
|
messages = if errors.include?({ type: :not_available })
|
||||||
|
[t('not_available', scope: '.errors')]
|
||||||
|
else
|
||||||
|
errors.map { |error| humanize(error) }
|
||||||
|
end
|
||||||
|
|
||||||
|
to_html_list(messages)
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_html_list(messages)
|
||||||
|
messages
|
||||||
.map { |message| tag.li(message) }
|
.map { |message| tag.li(message) }
|
||||||
.then { |lis| tag.ul(lis.reduce(&:+)) }
|
.then { |lis| tag.ul(lis.reduce(&:+)) }
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue