feat(procedure_revision.compate): track and show diff for TypeDeChamp.explication between draft and published revisions

This commit is contained in:
Martin 2023-12-19 10:44:51 +01:00
parent f7feca5fd1
commit e43c2f1407
6 changed files with 25 additions and 11 deletions

View file

@ -9,4 +9,4 @@
.fr-collapse{ id: dom_id(@champ, :explanation) } .fr-collapse{ id: dom_id(@champ, :explanation) }
= render SimpleFormatComponent.new(@champ.collapsible_explanation_text, allow_a: true) = render SimpleFormatComponent.new(@champ.collapsible_explanation_text, allow_a: true)
- if notice_explicative.attached? - if notice_explicative.attached?
= render Dsfr::DownloadComponent.new(attachment: notice_explicative, virus_not_analyzed: !notice_explicative.virus_scanner.started?, new_tab: true) = render Dsfr::DownloadComponent.new(attachment: notice_explicative, virus_not_analyzed: !notice_explicative.virus_scanner.started?, new_tab: true)

View file

@ -24,6 +24,7 @@ fr:
update_drop_down_secondary_description: La description secondaire du champ « %{label} » a été modifiée. La nouvelle description est « %{to} ». update_drop_down_secondary_description: La description secondaire du champ « %{label} » a été modifiée. La nouvelle description est « %{to} ».
update_type_champ: Le type du champ « %{label} » a été modifié. Il est maintenant de type « %{to} ». update_type_champ: Le type du champ « %{label} » a été modifié. Il est maintenant de type « %{to} ».
update_piece_justificative_template: Le modèle de pièce justificative du champ « %{label} » a été modifié. update_piece_justificative_template: Le modèle de pièce justificative du champ « %{label} » a été modifié.
update_notice_explicative: La notice explicative du champ « %{label} » a été modifiée.
update_drop_down_options: "Les options de sélection du champ « %{label} » ont été modifiées :" update_drop_down_options: "Les options de sélection du champ « %{label} » ont été modifiées :"
update_drop_down_options_alert: "Le champ « %{label} » est utilisé pour le routage des dossiers. Veuillez mettre à jour la configuration des groupes d'instructeurs après avoir publié les modifications." update_drop_down_options_alert: "Le champ « %{label} » est utilisé pour le routage des dossiers. Veuillez mettre à jour la configuration des groupes d'instructeurs après avoir publié les modifications."
enable_mandatory: Le champ « %{label} » est maintenant obligatoire. enable_mandatory: Le champ « %{label} » est maintenant obligatoire.
@ -59,6 +60,7 @@ fr:
update_drop_down_secondary_description: La description secondaire de lannotation « %{label} » a été modifiée. La nouvelle description est « %{to} ». update_drop_down_secondary_description: La description secondaire de lannotation « %{label} » a été modifiée. La nouvelle description est « %{to} ».
update_type_champ: Le type de lannotation privée « %{label} » a été modifié. Elle est maintenant de type « %{to} ». update_type_champ: Le type de lannotation privée « %{label} » a été modifié. Elle est maintenant de type « %{to} ».
update_piece_justificative_template: Le modèle de pièce justificative de lannotation privée « %{label} » a été modifié. update_piece_justificative_template: Le modèle de pièce justificative de lannotation privée « %{label} » a été modifié.
update_notice_explicative: La notice explicative lannotation privée « %{label} » a été modifiée.
update_drop_down_options: "Les options de sélection de lannotation privée « %{label} » ont été modifiées :" update_drop_down_options: "Les options de sélection de lannotation privée « %{label} » ont été modifiées :"
update_carte_layers: "Les référentiels cartographiques de lannotation privée « %{label} » ont été modifiés :" update_carte_layers: "Les référentiels cartographiques de lannotation privée « %{label} » ont été modifiés :"
enable_drop_down_other: Lannotation privée « %{label} » comporte maintenant un choix « Autre ». enable_drop_down_other: Lannotation privée « %{label} » comporte maintenant un choix « Autre ».

View file

@ -59,6 +59,9 @@
- when :piece_justificative_template - when :piece_justificative_template
- list.with_item do - list.with_item do
= t(".#{prefix}.update_piece_justificative_template", label: change.label) = t(".#{prefix}.update_piece_justificative_template", label: change.label)
- when :notice_explicative
- list.with_item do
= t(".#{prefix}.update_notice_explicative", label: change.label)
- when :drop_down_options - when :drop_down_options
- added = change.to.sort - change.from.sort - added = change.to.sort - change.from.sort
- removed = change.from.sort - change.to.sort - removed = change.from.sort - change.to.sort

View file

@ -46,7 +46,7 @@ module Administrateurs
def notice_explicative def notice_explicative
type_de_champ = draft.find_and_ensure_exclusive_use(params[:stable_id]) type_de_champ = draft.find_and_ensure_exclusive_use(params[:stable_id])
byebug
if type_de_champ.notice_explicative.attach(params[:blob_signed_id]) if type_de_champ.notice_explicative.attach(params[:blob_signed_id])
@coordinate = draft.coordinate_for(type_de_champ) @coordinate = draft.coordinate_for(type_de_champ)
@morphed = [champ_component_from(@coordinate)] @morphed = [champ_component_from(@coordinate)]

View file

@ -363,11 +363,18 @@ class ProcedureRevision < ApplicationRecord
to_type_de_champ.carte_optional_layers) to_type_de_champ.carte_optional_layers)
end end
elsif to_type_de_champ.piece_justificative? elsif to_type_de_champ.piece_justificative?
if from_type_de_champ.piece_justificative_template_checksum != to_type_de_champ.piece_justificative_template_checksum if from_type_de_champ.checksum_for_attachment(:piece_justificative_template) != to_type_de_champ.checksum_for_attachment(:piece_justificative_template)
changes << ProcedureRevisionChange::UpdateChamp.new(from_type_de_champ, changes << ProcedureRevisionChange::UpdateChamp.new(from_type_de_champ,
:piece_justificative_template, :piece_justificative_template,
from_type_de_champ.piece_justificative_template_filename, from_type_de_champ.filename_for_attachement(:piece_justificative_template),
to_type_de_champ.piece_justificative_template_filename) to_type_de_champ.filename_for_attachement(:piece_justificative_template))
end
elsif to_type_de_champ.explication?
if from_type_de_champ.checksum_for_attachment(:notice_explicative) != to_type_de_champ.checksum_for_attachment(:notice_explicative)
changes << ProcedureRevisionChange::UpdateChamp.new(from_type_de_champ,
:notice_explicative,
from_type_de_champ.filename_for_attachement(:notice_explicative),
to_type_de_champ.filename_for_attachement(:notice_explicative))
end end
elsif to_type_de_champ.textarea? elsif to_type_de_champ.textarea?
if from_type_de_champ.character_limit != to_type_de_champ.character_limit if from_type_de_champ.character_limit != to_type_de_champ.character_limit

View file

@ -461,15 +461,17 @@ class TypeDeChamp < ApplicationRecord
"TypesDeChamp::#{type_champ.classify}TypeDeChamp" "TypesDeChamp::#{type_champ.classify}TypeDeChamp"
end end
def piece_justificative_template_filename def filename_for_attachement(attachment_sym)
if piece_justificative_template.attached? attachment = send(attachment_sym)
piece_justificative_template.filename if attachment.attached?
attachment.filename
end end
end end
def piece_justificative_template_checksum def checksum_for_attachment(attachment_sym)
if piece_justificative_template.attached? attachment = send(attachment_sym)
piece_justificative_template.checksum if attachment.attached?
attachment.checksum
end end
end end