diff --git a/app/models/dossier.rb b/app/models/dossier.rb index c643ddc14..8f345fb4f 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -1406,6 +1406,10 @@ class Dossier < ApplicationRecord end.flat_map { champs_index[_1.stable_id] || [] } end + def has_annotations? + revision.revision_types_de_champ_private.present? + end + private def create_missing_traitemets diff --git a/app/views/administrateurs/procedures/apercu.html.haml b/app/views/administrateurs/procedures/apercu.html.haml index aa55c2b81..5941fdbb4 100644 --- a/app/views/administrateurs/procedures/apercu.html.haml +++ b/app/views/administrateurs/procedures/apercu.html.haml @@ -7,7 +7,7 @@ = tab_item('le dossier', apercu_admin_procedure_path(@dossier.procedure, tab: 'dossier'), active: @tab == 'dossier') - - if @dossier.champs_private.size > 0 + - if @dossier.has_annotations? = tab_item('les annotations privées', apercu_admin_procedure_path(@dossier.procedure, tab: 'annotations-privees'), active: @tab == 'annotations-privees') diff --git a/app/views/dossiers/show.pdf.prawn b/app/views/dossiers/show.pdf.prawn index cde96074b..eaf32db3b 100644 --- a/app/views/dossiers/show.pdf.prawn +++ b/app/views/dossiers/show.pdf.prawn @@ -349,7 +349,7 @@ prawn_document(page_size: "A4") do |pdf| add_title(pdf, 'Formulaire') add_champs(pdf, @dossier.champs_public) - if @acls[:include_infos_administration] && @dossier.champs_private.present? + if @acls[:include_infos_administration] && @dossier.has_annotations? add_title(pdf, "Annotations privées") add_champs(pdf, @dossier.champs_private) end diff --git a/app/views/shared/dossiers/_edit_annotations.html.haml b/app/views/shared/dossiers/_edit_annotations.html.haml index 48644a34e..7cef69996 100644 --- a/app/views/shared/dossiers/_edit_annotations.html.haml +++ b/app/views/shared/dossiers/_edit_annotations.html.haml @@ -1,5 +1,5 @@ .container.dossier-edit - - if dossier.champs_private.present? + - if dossier.has_annotations? %section.counter-start-header-section = render NestedForms::FormOwnerComponent.new = form_for dossier, url: annotations_instructeur_dossier_path(dossier.procedure, dossier), html: { class: 'form', multipart: true } do |f|