diff --git a/app/components/procedure/card/modifications_component/modifications_component.fr.yml b/app/components/procedure/card/modifications_component/modifications_component.fr.yml index be0495fd5..e46fc4f3c 100644 --- a/app/components/procedure/card/modifications_component/modifications_component.fr.yml +++ b/app/components/procedure/card/modifications_component/modifications_component.fr.yml @@ -1,3 +1,5 @@ --- fr: - title: Modifications + title: + one: Modification + other: Modifications diff --git a/app/components/procedure/card/modifications_component/modifications_component.html.haml b/app/components/procedure/card/modifications_component/modifications_component.html.haml index 7b2e02b9b..fae8f9670 100644 --- a/app/components/procedure/card/modifications_component/modifications_component.html.haml +++ b/app/components/procedure/card/modifications_component/modifications_component.html.haml @@ -4,8 +4,8 @@ %p.card-admin-status-accept Activée %div %p.card-admin-title - %span.badge.baseline= @procedure.revisions.size - 1 - = t('.title') + %span.badge.baseline= @procedure.revisions_count + = t('.title', count: @procedure.revisions_count) %p.card-admin-subtitle Historique des modifications du formulaire %p.button Voir diff --git a/app/models/procedure.rb b/app/models/procedure.rb index fb91e0dba..9c0a1aa65 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -660,6 +660,11 @@ class Procedure < ApplicationRecord feature_enabled?(:procedure_revisions) && revisions.size > 2 end + def revisions_count + # We start counting from the first revision after publication and we are not counting the draft (there is always one) + revisions.size - 2 + end + def routee? routing_enabled? || groupe_instructeurs.size > 1 end diff --git a/app/views/administrateurs/procedures/_revision_changes.html.haml b/app/views/administrateurs/procedures/_revision_changes.html.haml index edcd43345..e5854bd2b 100644 --- a/app/views/administrateurs/procedures/_revision_changes.html.haml +++ b/app/views/administrateurs/procedures/_revision_changes.html.haml @@ -1,10 +1,13 @@ %ul.revision-changes - - changes.filter { |change| change[:model] == :attestation_template }.each do |change| - = render partial: 'administrateurs/procedures/revision_change_attestation_template', locals: { change: change } - - changes.filter { |change| change[:model] == :type_de_champ }.each do |change| - = render partial: 'administrateurs/procedures/revision_change_type_de_champ', locals: { change: change } - - move_changes, move_private_changes = changes.filter { |change| change[:op] == :move }.partition { |change| !change[:private] } - - if move_changes.size != 0 - %li.mb-1= t(:move, scope: [:administrateurs, :revision_changes], count: move_changes.size) - - if move_private_changes.size != 0 - %li.mb-1= t(:move_private, scope: [:administrateurs, :revision_changes], count: move_private_changes.size) + - if changes.empty? + %li.mb-1= t(:no_changes, scope: [:administrateurs, :revision_changes]) + - else + - changes.filter { |change| change[:model] == :attestation_template }.each do |change| + = render partial: 'administrateurs/procedures/revision_change_attestation_template', locals: { change: change } + - changes.filter { |change| change[:model] == :type_de_champ }.each do |change| + = render partial: 'administrateurs/procedures/revision_change_type_de_champ', locals: { change: change } + - move_changes, move_private_changes = changes.filter { |change| change[:op] == :move }.partition { |change| !change[:private] } + - if move_changes.present? + %li.mb-1= t(:move, scope: [:administrateurs, :revision_changes], count: move_changes.size) + - if move_private_changes.present? + %li.mb-1= t(:move_private, scope: [:administrateurs, :revision_changes], count: move_private_changes.size) diff --git a/app/views/administrateurs/procedures/modifications.html.haml b/app/views/administrateurs/procedures/modifications.html.haml index 756dbc4af..8c29b0f51 100644 --- a/app/views/administrateurs/procedures/modifications.html.haml +++ b/app/views/administrateurs/procedures/modifications.html.haml @@ -11,8 +11,7 @@ - @procedure.revisions.each do |revision| - if previous_revision.present? && !revision.draft? - changes = previous_revision.compare(revision) - - if changes.present? - .card.mb-4 - %h2.card-title= "Modifications publiées le #{l(revision.published_at, format: '%d %B %Y à %R')}" - = render partial: 'revision_changes', locals: { changes: changes } + .card.mb-4 + %h2.card-title= "Modifications publiées le #{l(revision.published_at, format: '%d %B %Y à %R')}" + = render partial: 'revision_changes', locals: { changes: changes } - previous_revision = revision diff --git a/config/locales/views/administrateurs/revision_changes/fr.yml b/config/locales/views/administrateurs/revision_changes/fr.yml index 595f566fe..4513d4bec 100644 --- a/config/locales/views/administrateurs/revision_changes/fr.yml +++ b/config/locales/views/administrateurs/revision_changes/fr.yml @@ -1,6 +1,7 @@ fr: administrateurs: revision_changes: + no_changes: Aucune modification attestation_template: add: Un model d’attestation à été ajouté update_title: Le titre de l’attestation à été modifié. Le nouveau titre est « %{to} »