2022-11-07 13:45:10 +01:00
|
|
|
class Procedure::PublicationWarningComponent < ApplicationComponent
|
|
|
|
def initialize(procedure:)
|
|
|
|
@procedure = procedure
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def render?
|
|
|
|
@procedure.validate(:publication)
|
|
|
|
@procedure.errors.delete(:path)
|
|
|
|
@procedure.errors.any?
|
|
|
|
end
|
|
|
|
|
|
|
|
def error_messages
|
|
|
|
@procedure.errors
|
|
|
|
.to_hash(full_messages: true)
|
|
|
|
.map do |attribute, messages|
|
|
|
|
[messages, error_correction_page(attribute)]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def error_correction_page(attribute)
|
|
|
|
case attribute
|
|
|
|
when :draft_revision
|
|
|
|
champs_admin_procedure_path(@procedure)
|
2022-11-09 12:10:19 +01:00
|
|
|
when :attestation_template
|
|
|
|
edit_admin_procedure_attestation_template_path(@procedure)
|
2023-11-08 14:41:22 +01:00
|
|
|
when :initiated_mail, :received_mail, :closed_mail, :refused_mail, :without_continuation_mail, :re_instructed_mail
|
2022-11-07 13:45:10 +01:00
|
|
|
admin_procedure_mail_templates_path(@procedure)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|