amelioration(Procedure.revision_changes): ajout du support pour les texte complementaire affichable au clique des champs de type explication
Co-authored-by: Paul Chavard <github@paul.chavard.net>
This commit is contained in:
parent
df54dc04a4
commit
b3f80dc5f9
6 changed files with 118 additions and 40 deletions
|
@ -6,6 +6,6 @@
|
|||
- if @champ.collapsible_explanation_enabled? && @champ.collapsible_explanation_text.present?
|
||||
%div
|
||||
%p.fr-my-2w
|
||||
%button{type: "button", "aria-controls" => "champs-text-#{@champ.id}", "aria-expanded" => "false", href: "#champs-text-#{@champ.id}"} Lire plus
|
||||
%p.fr-collapse{ id: "champs-text-#{@champ.id}"}
|
||||
%button{type: "button", "aria-controls": dom_id(@champ, :explanation), "aria-expanded": "false", href: dom_id(@champ, :explanation)} Lire plus
|
||||
%p.fr-collapse{ id: dom_id(@champ, :explanation)}
|
||||
= @champ.collapsible_explanation_text
|
||||
|
|
|
@ -42,7 +42,6 @@ class Champ < ApplicationRecord
|
|||
:drop_down_list_enabled_non_empty_options,
|
||||
:drop_down_secondary_libelle,
|
||||
:drop_down_secondary_description,
|
||||
:collapsible_explanation_enabled,
|
||||
:collapsible_explanation_enabled?,
|
||||
:collapsible_explanation_text,
|
||||
:exclude_from_export?,
|
||||
|
|
|
@ -359,6 +359,30 @@ class ProcedureRevision < ApplicationRecord
|
|||
stable_id: from_type_de_champ.stable_id
|
||||
}
|
||||
end
|
||||
if from_type_de_champ.collapsible_explanation_enabled? != to_type_de_champ.collapsible_explanation_enabled?
|
||||
changes << {
|
||||
model: :type_de_champ,
|
||||
op: :update,
|
||||
attribute: :collapsible_explanation_enabled,
|
||||
label: from_type_de_champ.libelle,
|
||||
private: from_type_de_champ.private?,
|
||||
from: from_type_de_champ.collapsible_explanation_enabled?,
|
||||
to: to_type_de_champ.collapsible_explanation_enabled?,
|
||||
stable_id: from_type_de_champ.stable_id
|
||||
}
|
||||
end
|
||||
if from_type_de_champ.collapsible_explanation_text != to_type_de_champ.collapsible_explanation_text
|
||||
changes << {
|
||||
model: :type_de_champ,
|
||||
op: :update,
|
||||
attribute: :collapsible_explanation_text,
|
||||
label: from_type_de_champ.libelle,
|
||||
private: from_type_de_champ.private?,
|
||||
from: from_type_de_champ.collapsible_explanation_text,
|
||||
to: to_type_de_champ.collapsible_explanation_text,
|
||||
stable_id: from_type_de_champ.stable_id
|
||||
}
|
||||
end
|
||||
if from_type_de_champ.description != to_type_de_champ.description
|
||||
changes << {
|
||||
model: :type_de_champ,
|
||||
|
|
|
@ -70,6 +70,17 @@
|
|||
- if removed.present?
|
||||
- list.with_item do
|
||||
= t(:remove_option, scope: [:administrateurs, :revision_changes], items: removed.map{ |term| "« #{t(term, scope: [:administrateurs, :carte_layers])} »" }.join(", "))
|
||||
- when :collapsible_explanation_enabled
|
||||
- if change[:to]
|
||||
- list.with_item do
|
||||
= t("administrateurs.revision_changes.update_collapsible_explanation_enabled#{postfix}.enabled", label: change[:label])
|
||||
- else
|
||||
- list.with_item do
|
||||
= t("administrateurs.revision_changes.update_collapsible_explanation_enabled#{postfix}.disabled", label: change[:label])
|
||||
- when :collapsible_explanation_text
|
||||
- list.with_item do
|
||||
= t("administrateurs.revision_changes.update_collapsible_explanation_text#{postfix}", label: change[:label], text: change[:to])
|
||||
|
||||
- when :condition
|
||||
- if change[:from].nil?
|
||||
- list.with_item do
|
||||
|
|
|
@ -29,6 +29,10 @@ fr:
|
|||
enabled: Le champ « %{label} » comporte maintenant un choix « Autre »
|
||||
disabled: Le champ « %{label} » ne comporte plus de choix « Autre »
|
||||
update_carte_layers: Les référentiels cartographiques du champ « %{label} » ont été modifiés
|
||||
update_collapsible_explanation_enabled:
|
||||
enabled: "Le texte complementaire affichable au clique du champ « %{label} » a été ajouté"
|
||||
disabled: "Le texte complementaire affichable au clique du champ « %{label} » a été supprimée"
|
||||
update_collapsible_explanation_text: "Le texte complementaire affichable au clique du champ « %{label} » a été modifié. Il est maintenant « %{text} »."
|
||||
add_private: L’annotation privée « %{label} » a été ajoutée
|
||||
remove_private: L’annotation privée « %{label} » a été supprimée
|
||||
move_private:
|
||||
|
@ -45,6 +49,10 @@ fr:
|
|||
update_piece_justificative_template_private: Le modèle de pièce justificative de l’annotation privée « %{label} » a été modifié
|
||||
update_drop_down_options_private: Les options de sélection de l’annotation privée « %{label} » ont été modifiées
|
||||
update_carte_layers_private: Les référentiels cartographiques de l’annotation privée « %{label} » ont été modifiés
|
||||
update_collapsible_explanation_enabled_private:
|
||||
enabled: "Le texte complementaire affichable au clique de l’annotation privée « %{label} » a été ajouté"
|
||||
disabled: "Le texte complementaire affichable au clique de l’annotation privée « %{label} » a été supprimée"
|
||||
update_collapsible_explanation_private: "Le texte complementaire affichable au clique de l’annotation privée « %{label} » a été modifié. Il est maintenant « %{text} »."
|
||||
add_option: "ajoutés : %{items}"
|
||||
remove_option: "supprimés : %{items}"
|
||||
add_condition: Une condition a été ajoutée sur le champ « %{label} ». La nouvelle condition est « %{to} »
|
||||
|
|
|
@ -440,47 +440,83 @@ describe ProcedureRevision do
|
|||
end
|
||||
|
||||
context 'when a type de champ is changed' do
|
||||
let(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||
context 'when libelle, description, and mandatory are changed' do
|
||||
let(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||
|
||||
before do
|
||||
updated_tdc = new_draft.find_and_ensure_exclusive_use(first_tdc.stable_id)
|
||||
before do
|
||||
updated_tdc = new_draft.find_and_ensure_exclusive_use(first_tdc.stable_id)
|
||||
|
||||
updated_tdc.update(libelle: 'modifier le libelle', description: 'une description', mandatory: !updated_tdc.mandatory)
|
||||
updated_tdc.update(libelle: 'modifier le libelle', description: 'une description', mandatory: !updated_tdc.mandatory)
|
||||
end
|
||||
|
||||
it do
|
||||
is_expected.to eq([
|
||||
{
|
||||
model: :type_de_champ,
|
||||
op: :update,
|
||||
attribute: :libelle,
|
||||
label: first_tdc.libelle,
|
||||
private: false,
|
||||
from: first_tdc.libelle,
|
||||
to: "modifier le libelle",
|
||||
stable_id: first_tdc.stable_id
|
||||
},
|
||||
{
|
||||
model: :type_de_champ,
|
||||
op: :update,
|
||||
attribute: :description,
|
||||
label: first_tdc.libelle,
|
||||
private: false,
|
||||
from: first_tdc.description,
|
||||
to: "une description",
|
||||
stable_id: first_tdc.stable_id
|
||||
},
|
||||
{
|
||||
model: :type_de_champ,
|
||||
op: :update,
|
||||
attribute: :mandatory,
|
||||
label: first_tdc.libelle,
|
||||
private: false,
|
||||
from: false,
|
||||
to: true,
|
||||
stable_id: first_tdc.stable_id
|
||||
}
|
||||
])
|
||||
end
|
||||
end
|
||||
|
||||
it do
|
||||
is_expected.to eq([
|
||||
{
|
||||
model: :type_de_champ,
|
||||
op: :update,
|
||||
attribute: :libelle,
|
||||
label: first_tdc.libelle,
|
||||
private: false,
|
||||
from: first_tdc.libelle,
|
||||
to: "modifier le libelle",
|
||||
stable_id: first_tdc.stable_id
|
||||
},
|
||||
{
|
||||
model: :type_de_champ,
|
||||
op: :update,
|
||||
attribute: :description,
|
||||
label: first_tdc.libelle,
|
||||
private: false,
|
||||
from: first_tdc.description,
|
||||
to: "une description",
|
||||
stable_id: first_tdc.stable_id
|
||||
},
|
||||
{
|
||||
model: :type_de_champ,
|
||||
op: :update,
|
||||
attribute: :mandatory,
|
||||
label: first_tdc.libelle,
|
||||
private: false,
|
||||
from: false,
|
||||
to: true,
|
||||
stable_id: first_tdc.stable_id
|
||||
}
|
||||
])
|
||||
context 'when collapsible_explanation_enabled and collapsible_explanation_text are changed' do
|
||||
let(:procedure) { create(:procedure, :with_explication) }
|
||||
|
||||
before do
|
||||
updated_tdc = new_draft.find_and_ensure_exclusive_use(first_tdc.stable_id)
|
||||
|
||||
updated_tdc.update(collapsible_explanation_enabled: "1", collapsible_explanation_text: 'afficher au clique')
|
||||
end
|
||||
it do
|
||||
is_expected.to eq([
|
||||
{
|
||||
model: :type_de_champ,
|
||||
op: :update,
|
||||
attribute: :collapsible_explanation_enabled,
|
||||
label: first_tdc.libelle,
|
||||
private: first_tdc.private?,
|
||||
from: false,
|
||||
to: true,
|
||||
stable_id: first_tdc.stable_id
|
||||
},
|
||||
{
|
||||
model: :type_de_champ,
|
||||
op: :update,
|
||||
attribute: :collapsible_explanation_text,
|
||||
label: first_tdc.libelle,
|
||||
private: first_tdc.private?,
|
||||
from: nil,
|
||||
to: 'afficher au clique',
|
||||
stable_id: first_tdc.stable_id
|
||||
}
|
||||
])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue