Revert "feat(champ): customizable placeholders for text & textarea champs"
This reverts commit 9e26ee932e
.
Finalement les champs génériques ne doivent pas avoir de placeholder
personnalisable, ce sera uniquement via la description.
This commit is contained in:
parent
08611753d5
commit
8c08d0295b
9 changed files with 3 additions and 80 deletions
|
@ -34,13 +34,6 @@
|
||||||
= form.label :description, "Description du champ (optionnel)", for: dom_id(type_de_champ, :description)
|
= 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)
|
= 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
|
.flex.justify-start.mt-1
|
||||||
- if type_de_champ.drop_down_list?
|
- if type_de_champ.drop_down_list?
|
||||||
.flex.column.justify-start.width-33
|
.flex.column.justify-start.width-33
|
||||||
|
|
|
@ -96,7 +96,6 @@ module Administrateurs
|
||||||
:drop_down_secondary_libelle,
|
:drop_down_secondary_libelle,
|
||||||
:drop_down_secondary_description,
|
:drop_down_secondary_description,
|
||||||
:piece_justificative_template,
|
:piece_justificative_template,
|
||||||
:placeholder,
|
|
||||||
editable_options: [
|
editable_options: [
|
||||||
:cadastres,
|
:cadastres,
|
||||||
:unesco,
|
:unesco,
|
||||||
|
|
|
@ -58,16 +58,7 @@ class TypeDeChamp < ApplicationRecord
|
||||||
mesri: 'mesri'
|
mesri: 'mesri'
|
||||||
}
|
}
|
||||||
|
|
||||||
store_accessor :options, :cadastres,
|
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
|
||||||
: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
|
|
||||||
|
|
||||||
has_many :revision_types_de_champ, -> { revision_ordered }, class_name: 'ProcedureRevisionTypeDeChamp', dependent: :destroy, inverse_of: :type_de_champ
|
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_one :revision_type_de_champ, -> { revision_ordered }, class_name: 'ProcedureRevisionTypeDeChamp', inverse_of: false
|
||||||
has_many :revisions, -> { ordered }, through: :revision_types_de_champ
|
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)
|
type_champ == TypeDeChamp.type_champs.fetch(:linked_drop_down_list)
|
||||||
end
|
end
|
||||||
|
|
||||||
def generic?
|
|
||||||
type_champ == TypeDeChamp.type_champs.fetch(:text) || type_champ == TypeDeChamp.type_champs.fetch(:textarea)
|
|
||||||
end
|
|
||||||
|
|
||||||
def exclude_from_view?
|
def exclude_from_view?
|
||||||
type_champ == TypeDeChamp.type_champs.fetch(:explication)
|
type_champ == TypeDeChamp.type_champs.fetch(:explication)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
= form.text_field :value,
|
= form.text_field :value,
|
||||||
id: champ.input_id,
|
id: champ.input_id,
|
||||||
placeholder: champ.type_de_champ.placeholder.presence || t(".placeholder"),
|
placeholder: t(".placeholder"),
|
||||||
required: champ.mandatory?,
|
required: champ.mandatory?,
|
||||||
aria: { describedby: champ.describedby_id }
|
aria: { describedby: champ.describedby_id }
|
||||||
|
|
|
@ -4,4 +4,4 @@
|
||||||
rows: 6,
|
rows: 6,
|
||||||
required: champ.mandatory?,
|
required: champ.mandatory?,
|
||||||
value: html_to_string(champ.value),
|
value: html_to_string(champ.value),
|
||||||
placeholder: champ.type_de_champ.placeholder.presence || t(".placeholder")
|
placeholder: t(".placeholder")
|
||||||
|
|
|
@ -575,9 +575,3 @@ fr:
|
||||||
weekly_distribution_details: "au cours des 6 derniers mois"
|
weekly_distribution_details: "au cours des 6 derniers mois"
|
||||||
procedure_description:
|
procedure_description:
|
||||||
estimated_fill_duration: "Temps de remplissage estimé : %{estimated_minutes} mn"
|
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
|
|
||||||
|
|
|
@ -30,7 +30,6 @@ describe Administrateurs::TypesDeChampController, type: :controller do
|
||||||
type_de_champ: {
|
type_de_champ: {
|
||||||
type_champ: type_champ,
|
type_champ: type_champ,
|
||||||
libelle: 'l1.5',
|
libelle: 'l1.5',
|
||||||
placeholder: "custom placeholder",
|
|
||||||
after_stable_id: first_coordinate.stable_id
|
after_stable_id: first_coordinate.stable_id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,35 +165,4 @@ describe 'As an administrateur I can edit types de champ', js: true do
|
||||||
end
|
end
|
||||||
expect(page).not_to have_content('Durée de remplissage estimée')
|
expect(page).not_to have_content('Durée de remplissage estimée')
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -34,24 +34,6 @@ describe 'shared/dossiers/edit.html.haml', type: :view do
|
||||||
expect(subject).to have_css('input[type="tel"][placeholder^="0612"]')
|
expect(subject).to have_css('input[type="tel"][placeholder^="0612"]')
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
context 'with a single-value list' do
|
context 'with a single-value list' do
|
||||||
|
|
Loading…
Reference in a new issue