Merge pull request #7558 from betagouv/rollback-customized-generic-placeholder

Rollback customized generic placeholder
This commit is contained in:
Paul Chavard 2022-07-12 11:44:14 +02:00 committed by GitHub
commit b30aa72eb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 4 additions and 106 deletions

View file

@ -34,13 +34,6 @@
= form.label :description, "Description du champ (optionnel)", for: dom_id(type_de_champ, :description)
= form.text_area :description, class: 'small-margin small width-100', rows: 3, id: dom_id(type_de_champ, :description)
- if type_de_champ.generic?
.cell.mt-1
= form.label :placeholder, t(".generic.custom_placeholder_title"), class: 'flex-grow', for: dom_id(type_de_champ, :placeholder)
= form.text_field :placeholder, class: 'small-margin small width-100', placeholder: t("#{type_de_champ.type_champ}.placeholder", scope: "shared.dossiers.editable_champs"), id: dom_id(type_de_champ, :placeholder)
%p
= t(".generic.custom_placeholder_hint")
.flex.justify-start.mt-1
- if type_de_champ.drop_down_list?
.flex.column.justify-start.width-33

View file

@ -96,7 +96,6 @@ module Administrateurs
:drop_down_secondary_libelle,
:drop_down_secondary_description,
:piece_justificative_template,
:placeholder,
editable_options: [
:cadastres,
:unesco,

View file

@ -385,18 +385,6 @@ class ProcedureRevision < ApplicationRecord
stable_id: from_type_de_champ.stable_id
}
end
if from_type_de_champ.placeholder != to_type_de_champ.placeholder
changes << {
model: :type_de_champ,
op: :update,
attribute: :placeholder,
label: from_type_de_champ.libelle,
private: from_type_de_champ.private?,
from: from_type_de_champ.placeholder,
to: to_type_de_champ.placeholder,
stable_id: from_type_de_champ.stable_id
}
end
if to_type_de_champ.drop_down_list?
if from_type_de_champ.drop_down_list_options != to_type_de_champ.drop_down_list_options
changes << {

View file

@ -58,16 +58,7 @@ class TypeDeChamp < ApplicationRecord
mesri: 'mesri'
}
store_accessor :options, :cadastres,
:drop_down_options,
:drop_down_other,
:drop_down_secondary_description,
:drop_down_secondary_libelle,
:old_pj,
:placeholder,
:skip_content_type_pj_validation,
:skip_pj_validation
store_accessor :options, :cadastres, :old_pj, :drop_down_options, :skip_pj_validation, :skip_content_type_pj_validation, :drop_down_secondary_libelle, :drop_down_secondary_description, :drop_down_other
has_many :revision_types_de_champ, -> { revision_ordered }, class_name: 'ProcedureRevisionTypeDeChamp', dependent: :destroy, inverse_of: :type_de_champ
has_one :revision_type_de_champ, -> { revision_ordered }, class_name: 'ProcedureRevisionTypeDeChamp', inverse_of: false
has_many :revisions, -> { ordered }, through: :revision_types_de_champ
@ -226,10 +217,6 @@ class TypeDeChamp < ApplicationRecord
type_champ == TypeDeChamp.type_champs.fetch(:linked_drop_down_list)
end
def generic?
type_champ == TypeDeChamp.type_champs.fetch(:text) || type_champ == TypeDeChamp.type_champs.fetch(:textarea)
end
def exclude_from_view?
type_champ == TypeDeChamp.type_champs.fetch(:explication)
end

View file

@ -44,8 +44,6 @@
%li.mb-1= t("administrateurs.revision_changes.update_drop_down_other#{postfix}.enabled", label: change[:label])
- else
%li.mb-1= t("administrateurs.revision_changes.update_drop_down_other#{postfix}.disabled", label: change[:label])
- when :placeholder
%li.mb-1= t("update_placeholder#{postfix}", label: change[:label], to: change[:to], scope: [:administrateurs, :revision_changes])
- when :carte_layers
- added = change[:to].sort - change[:from].sort
- removed = change[:from].sort - change[:to].sort

View file

@ -1,5 +1,5 @@
= form.text_field :value,
id: champ.input_id,
placeholder: champ.type_de_champ.placeholder.presence || t(".placeholder"),
placeholder: t(".placeholder"),
required: champ.mandatory?,
aria: { describedby: champ.describedby_id }

View file

@ -4,4 +4,4 @@
rows: 6,
required: champ.mandatory?,
value: html_to_string(champ.value),
placeholder: champ.type_de_champ.placeholder.presence || t(".placeholder")
placeholder: t(".placeholder")

View file

@ -575,9 +575,3 @@ fr:
weekly_distribution_details: "au cours des 6 derniers mois"
procedure_description:
estimated_fill_duration: "Temps de remplissage estimé : %{estimated_minutes} mn"
types_de_champ_editor:
champ_component:
generic:
custom_placeholder_title: "Spécimen de saisie (optionnel)"
custom_placeholder_hint: Modèle de réponse visible dans le champ avant la saisie par l'usager

View file

@ -28,7 +28,6 @@ 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_placeholder: Le spécimen de saisie du champ « %{label} » a été modifié. Le nouveau spécimen est « %{to} ».
add_private: Lannotation privée « %{label} » a été ajoutée
remove_private: Lannotation privée « %{label} » a été supprimée
move_private:

View file

@ -30,7 +30,6 @@ describe Administrateurs::TypesDeChampController, type: :controller do
type_de_champ: {
type_champ: type_champ,
libelle: 'l1.5',
placeholder: "custom placeholder",
after_stable_id: first_coordinate.stable_id
}
}

View file

@ -357,7 +357,7 @@ describe ProcedureRevision do
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, placeholder: "new placeholder")
updated_tdc.update(libelle: 'modifier le libelle', description: 'une description', mandatory: !updated_tdc.mandatory)
end
it do
@ -391,16 +391,6 @@ describe ProcedureRevision do
from: false,
to: true,
stable_id: first_tdc.stable_id
},
{
model: :type_de_champ,
op: :update,
attribute: :placeholder,
label: first_tdc.libelle,
private: false,
from: first_tdc.placeholder,
to: "new placeholder",
stable_id: first_tdc.stable_id
}
])
end

View file

@ -165,35 +165,4 @@ describe 'As an administrateur I can edit types de champ', js: true do
end
expect(page).not_to have_content('Durée de remplissage estimée')
end
describe "placeholders for generic types" do
let(:placeholder) { "my placeholder" }
before do
add_champ
end
it "text champ" do
select('Texte', from: 'Type de champ')
expect(page).to have_content('Spécimen de saisie')
fill_in 'Spécimen de saisie', with: placeholder
wait_until { procedure.draft_types_de_champ.first.placeholder == placeholder }
page.refresh
expect(page).to have_selector("input[value='#{placeholder}']")
end
it "textarea champ" do
select('Zone de texte', from: 'Type de champ')
expect(page).to have_content('Spécimen de saisie')
fill_in 'Spécimen de saisie', with: placeholder
wait_until { procedure.draft_types_de_champ.first.placeholder == placeholder }
page.refresh
expect(page).to have_selector("input[value='#{placeholder}']")
end
end
end

View file

@ -34,24 +34,6 @@ describe 'shared/dossiers/edit.html.haml', type: :view do
expect(subject).to have_css('input[type="tel"][placeholder^="0612"]')
end
end
context "with generic champs" do
let(:champ_text) { create(:champ_text, dossier: dossier) }
let(:champs) { [champ_text, champ_textarea] }
it "renders default placeholders" do
expect(subject).to have_css('input[placeholder*="réponse"]')
expect(subject).to have_css('textarea[placeholder*="réponse"]')
end
it "renders customized placeholders" do
champ_text.type_de_champ.placeholder = "custom1 placeholder"
champ_textarea.type_de_champ.placeholder = "custom2 placeholder"
expect(subject).to have_css('input[placeholder*="custom1"]')
expect(subject).to have_css('textarea[placeholder*="custom2"]')
end
end
end
context 'with a single-value list' do