diff --git a/app/controllers/instructeurs/export_templates_controller.rb b/app/controllers/instructeurs/export_templates_controller.rb index 9065b2d21..cc41c0108 100644 --- a/app/controllers/instructeurs/export_templates_controller.rb +++ b/app/controllers/instructeurs/export_templates_controller.rb @@ -79,7 +79,7 @@ module Instructeurs end def set_all_pj - @all_pj ||= @procedure.pieces_jointes_exportables_list + @all_pj ||= @procedure.exportables_pieces_jointes end def export_params diff --git a/app/models/concerns/pieces_jointes_list_concern.rb b/app/models/concerns/pieces_jointes_list_concern.rb index 263b01e9f..05ba4b2da 100644 --- a/app/models/concerns/pieces_jointes_list_concern.rb +++ b/app/models/concerns/pieces_jointes_list_concern.rb @@ -3,17 +3,17 @@ module PiecesJointesListConcern included do def public_wrapped_partionned_pjs - pieces_jointes_list(public_only: true, wrap_with_parent: true) + pieces_jointes(public_only: true, wrap_with_parent: true) .partition { |(pj, _)| pj.condition.nil? } end - def pieces_jointes_exportables_list - pieces_jointes_list(exclude_titre_identite: true) + def exportables_pieces_jointes + pieces_jointes(exclude_titre_identite: true) end private - def pieces_jointes_list( + def pieces_jointes( exclude_titre_identite: false, public_only: false, wrap_with_parent: false diff --git a/app/models/export_template.rb b/app/models/export_template.rb index 52b983f7f..136a75999 100644 --- a/app/models/export_template.rb +++ b/app/models/export_template.rb @@ -13,7 +13,7 @@ class ExportTemplate < ApplicationRecord content["pdf_name"] = tiptap_json("export_") content["pjs"] = [] - procedure.pieces_jointes_exportables_list.each do |pj| + procedure.exportables_pieces_jointes.each do |pj| content["pjs"] << { "stable_id" => pj.stable_id.to_s, "path" => tiptap_json("#{pj.libelle.parameterize}-") } end end diff --git a/app/validators/export_template_validator.rb b/app/validators/export_template_validator.rb index 1f3475040..2a1158ed6 100644 --- a/app/validators/export_template_validator.rb +++ b/app/validators/export_template_validator.rb @@ -38,7 +38,7 @@ class ExportTemplateValidator < ActiveModel::Validator def validate_pjs(record) record.content["pjs"]&.each do |pj| pj_sym = pj.symbolize_keys - libelle = record.groupe_instructeur.procedure.pieces_jointes_exportables_list.find { _1.stable_id.to_s == pj_sym[:stable_id] }&.libelle&.to_sym + libelle = record.groupe_instructeur.procedure.exportables_pieces_jointes.find { _1.stable_id.to_s == pj_sym[:stable_id] }&.libelle&.to_sym validate_content(record, pj_sym[:path], libelle) end end diff --git a/app/views/instructeurs/export_templates/_form.html.haml b/app/views/instructeurs/export_templates/_form.html.haml index 8363e50e2..18a108ce7 100644 --- a/app/views/instructeurs/export_templates/_form.html.haml +++ b/app/views/instructeurs/export_templates/_form.html.haml @@ -82,7 +82,7 @@ %span#preview_default_dossier_directory= @export_template.tiptap_convert(sample_dossier, "default_dossier_directory") %ul %li#preview_pdf_name= @export_template.tiptap_convert(sample_dossier, "pdf_name") - - @procedure.pieces_jointes_exportables_list.each do |pj| + - @procedure.exportables_pieces_jointes.each do |pj| %li{ id: "preview_pj_#{pj.stable_id}" }= @export_template.tiptap_convert_pj(sample_dossier, pj.stable_id) %ul %li diff --git a/spec/models/concerns/pieces_jointes_list_concern_spec.rb b/spec/models/concerns/pieces_jointes_list_concern_spec.rb index bc4bdcd47..0356a52c9 100644 --- a/spec/models/concerns/pieces_jointes_list_concern_spec.rb +++ b/spec/models/concerns/pieces_jointes_list_concern_spec.rb @@ -44,7 +44,7 @@ describe PiecesJointesListConcern do end it "returns the list of pieces jointes with private, without parent repetition, without titre identite" do - expect(procedure.pieces_jointes_exportables_list.map(&:libelle)).to match_array([pj1, pj2, pjcond, pj5, pjcond2, pj6].map(&:libelle)) + expect(procedure.exportables_pieces_jointes.map(&:libelle)).to match_array([pj1, pj2, pjcond, pj5, pjcond2, pj6].map(&:libelle)) end end end