diff --git a/app/assets/stylesheets/dossier_edit.scss b/app/assets/stylesheets/dossier_edit.scss index ca32e9e2b..0d15e692a 100644 --- a/app/assets/stylesheets/dossier_edit.scss +++ b/app/assets/stylesheets/dossier_edit.scss @@ -42,11 +42,6 @@ $dossier-actions-bar-border-width: 1px; } } - .characters-count { - position: relative; - top: -1rem; - } - .warning { margin-bottom: 20px; background-color: #f9b91666; diff --git a/app/components/editable_champ/textarea_component/textarea_component.en.yml b/app/components/editable_champ/textarea_component/textarea_component.en.yml deleted file mode 100644 index 8e9b49901..000000000 --- a/app/components/editable_champ/textarea_component/textarea_component.en.yml +++ /dev/null @@ -1,3 +0,0 @@ -en: - remaining_characters: You have %{remaining_words} characters remaining. - excess_characters: You have %{excess_words} characters too many. diff --git a/app/components/editable_champ/textarea_component/textarea_component.fr.yml b/app/components/editable_champ/textarea_component/textarea_component.fr.yml deleted file mode 100644 index ca85e677e..000000000 --- a/app/components/editable_champ/textarea_component/textarea_component.fr.yml +++ /dev/null @@ -1,3 +0,0 @@ -fr: - remaining_characters: Il vous reste %{remaining_words} caractères. - excess_characters: Vous avez dépassé la taille conseillée de %{excess_words} caractères. diff --git a/app/components/editable_champ/textarea_component/textarea_component.html.haml b/app/components/editable_champ/textarea_component/textarea_component.html.haml index a19653e0d..4eeb28a1c 100644 --- a/app/components/editable_champ/textarea_component/textarea_component.html.haml +++ b/app/components/editable_champ/textarea_component/textarea_component.html.haml @@ -1,20 +1,6 @@ -- character_limit = @champ.textarea_character_limit.to_i if !@champ.textarea_character_limit&.empty? -- character_count = @champ.character_count(@champ.value) -- analyze_character_count = @champ.analyze_character_count(character_count, character_limit) - ~ @form.text_area :value, id: @champ.input_id, aria: { describedby: @champ.describedby_id }, rows: 6, required: @champ.required?, value: html_to_string(@champ.value) - -- if @champ.textarea_character_limit? - - - if analyze_character_count == :info - %span.fr-icon-information-fill.fr-text-default--info.characters-count - = t('.remaining_characters', remaining_words: @champ.remaining_characters(character_count, character_limit)) - - - if analyze_character_count == :warning - %span.fr-icon-close-circle-fill.fr-text-default--error.characters-count - = t('.excess_characters', excess_words: @champ.excess_characters(character_count, character_limit)) diff --git a/app/components/procedure/revision_changes_component/revision_changes_component.fr.yml b/app/components/procedure/revision_changes_component/revision_changes_component.fr.yml index cb04139a3..eac9a5bc8 100644 --- a/app/components/procedure/revision_changes_component/revision_changes_component.fr.yml +++ b/app/components/procedure/revision_changes_component/revision_changes_component.fr.yml @@ -36,8 +36,6 @@ fr: add_condition: Une condition a été ajoutée sur le champ « %{label} ». La nouvelle condition est « %{to} ». remove_condition: La condition du champ « %{label} » a été supprimée. update_condition: La condition du champ « %{label} » a été modifiée. La nouvelle condition est « %{to} ». - update_textarea_character_limit: La limite de caractères du champ texte « %{label} » a été modifiée. La nouvelle limite est « %{to} ». - remove_textarea_character_limit: La limite de caractères du champ texte « %{label} » a été supprimée. private: add: L’annotation privée « %{label} » a été ajoutée. remove: L’annotation privée « %{label} » a été supprimée. diff --git a/app/components/procedure/revision_changes_component/revision_changes_component.html.haml b/app/components/procedure/revision_changes_component/revision_changes_component.html.haml index bc4b24c82..76e42c741 100644 --- a/app/components/procedure/revision_changes_component/revision_changes_component.html.haml +++ b/app/components/procedure/revision_changes_component/revision_changes_component.html.haml @@ -130,14 +130,7 @@ = t(".#{prefix}.update_condition", label: change.label, to: change.to) - if !total_dossiers.zero? && !change.can_rebase? .fr-alert.fr-alert--warning.fr-mt-1v - %p= t('.breakigng_change', count: total_dossiers) - - when :textarea_character_limit - - if change.to.nil? - - list.with_item do - = t(".#{prefix}.remove_textarea_character_limit", label: change.label, to: change.to) - - else - - list.with_item do - = t(".#{prefix}.update_textarea_character_limit", label: change.label, to: change.to) + %p= t('.breaking_change', count: total_dossiers) - if @public_move_changes.present? - list.with_item do diff --git a/app/components/types_de_champ_editor/champ_component/champ_component.html.haml b/app/components/types_de_champ_editor/champ_component/champ_component.html.haml index 6de2696fb..682cbd322 100644 --- a/app/components/types_de_champ_editor/champ_component/champ_component.html.haml +++ b/app/components/types_de_champ_editor/champ_component/champ_component.html.haml @@ -101,11 +101,8 @@ = form.label :collapsible_explanation_text, for: dom_id(type_de_champ, :collapsible_explanation_text) do = "Texte à afficher quand l'utiliser a choisi de l'afficher" = form.text_area :collapsible_explanation_text, class: "small-margin small", id: dom_id(type_de_champ, :collapsible_explanation_text) - - if type_de_champ.textarea? - .cell - = form.label :textarea_character_limit, for: dom_id(type_de_champ, :textarea_character_limit) do - Spécifier un nombre maximal de caractères (non restrictif) : - = form.number_field :textarea_character_limit, min: 400, value: form.object.textarea_character_limit, id: dom_id(type_de_champ, :textarea_character_limit) + + - if type_de_champ.block? .flex.justify-start.section.ml-1 diff --git a/app/controllers/administrateurs/types_de_champ_controller.rb b/app/controllers/administrateurs/types_de_champ_controller.rb index 2b87a60ba..c77310dbd 100644 --- a/app/controllers/administrateurs/types_de_champ_controller.rb +++ b/app/controllers/administrateurs/types_de_champ_controller.rb @@ -119,29 +119,28 @@ module Administrateurs def type_de_champ_update_params params.required(:type_de_champ).permit(:type_champ, - :libelle, - :description, - :mandatory, - :drop_down_list_value, - :drop_down_other, - :drop_down_secondary_libelle, - :drop_down_secondary_description, - :collapsible_explanation_enabled, - :collapsible_explanation_text, - :header_section_level, - :textarea_character_limit, - editable_options: [ - :cadastres, - :unesco, - :arretes_protection, - :conservatoire_littoral, - :reserves_chasse_faune_sauvage, - :reserves_biologiques, - :reserves_naturelles, - :natura_2000, - :zones_humides, - :znieff - ]) + :libelle, + :description, + :mandatory, + :drop_down_list_value, + :drop_down_other, + :drop_down_secondary_libelle, + :drop_down_secondary_description, + :collapsible_explanation_enabled, + :collapsible_explanation_text, + :header_section_level, + editable_options: [ + :cadastres, + :unesco, + :arretes_protection, + :conservatoire_littoral, + :reserves_chasse_faune_sauvage, + :reserves_biologiques, + :reserves_naturelles, + :natura_2000, + :zones_humides, + :znieff + ]) end def draft diff --git a/app/models/champ.rb b/app/models/champ.rb index 7ff1074d3..5060baae8 100644 --- a/app/models/champ.rb +++ b/app/models/champ.rb @@ -75,8 +75,6 @@ class Champ < ApplicationRecord :mandatory?, :prefillable?, :refresh_after_update?, - :textarea_character_limit?, - :textarea_character_limit, to: :type_de_champ delegate :to_typed_id, :to_typed_id_for_query, to: :type_de_champ, prefix: true diff --git a/app/models/champs/email_champ.rb b/app/models/champs/email_champ.rb index 666fb9fc6..0c17ea122 100644 --- a/app/models/champs/email_champ.rb +++ b/app/models/champs/email_champ.rb @@ -21,11 +21,4 @@ # type_de_champ_id :integer # class Champs::EmailChamp < Champs::TextChamp - validates :value, - format: { - with: Devise.email_regexp, - message: I18n.t('invalid', scope: 'activerecord.errors.models.email_champ.attributes.value') - }, - allow_nil: true, - if: -> { validation_context != :brouillon } end diff --git a/app/models/champs/textarea_champ.rb b/app/models/champs/textarea_champ.rb index e729bc1ad..9ce4954f8 100644 --- a/app/models/champs/textarea_champ.rb +++ b/app/models/champs/textarea_champ.rb @@ -24,29 +24,4 @@ class Champs::TextareaChamp < Champs::TextChamp def for_export value.present? ? ActionView::Base.full_sanitizer.sanitize(value) : nil end - - def character_count(text) - return text&.bytesize - end - - def analyze_character_count(characters, limit) - if characters - threshold_75 = limit * 0.75 - - if characters >= limit - return :warning - elsif characters >= threshold_75 - return :info - end - end - end - - def remaining_characters(characters, limit) - threshold_75 = limit * 0.75 - limit - characters if characters >= threshold_75 - end - - def excess_characters(characters, limit) - characters - limit if characters > limit - end end diff --git a/app/models/procedure_revision.rb b/app/models/procedure_revision.rb index 8a6a2168e..e10fbe28f 100644 --- a/app/models/procedure_revision.rb +++ b/app/models/procedure_revision.rb @@ -377,13 +377,6 @@ class ProcedureRevision < ApplicationRecord from_type_de_champ.piece_justificative_template_filename, to_type_de_champ.piece_justificative_template_filename) end - elsif to_type_de_champ.textarea? - if from_type_de_champ.textarea_character_limit != to_type_de_champ.textarea_character_limit - changes << ProcedureRevisionChange::UpdateChamp.new(from_type_de_champ, - :textarea_character_limit, - from_type_de_champ.textarea_character_limit, - to_type_de_champ.textarea_character_limit) - end end changes end diff --git a/app/models/type_de_champ.rb b/app/models/type_de_champ.rb index 4c738da20..a64e8bdd6 100644 --- a/app/models/type_de_champ.rb +++ b/app/models/type_de_champ.rb @@ -19,7 +19,6 @@ class TypeDeChamp < ApplicationRecord FILE_MAX_SIZE = 200.megabytes FEATURE_FLAGS = {} - MINIMUM_TEXTAREA_CHARACTER_LIMIT_LENGTH = 400 STRUCTURE = :structure ETAT_CIVIL = :etat_civil @@ -119,7 +118,6 @@ class TypeDeChamp < ApplicationRecord :drop_down_secondary_libelle, :drop_down_secondary_description, :drop_down_other, - :textarea_character_limit, :collapsible_explanation_enabled, :collapsible_explanation_text, :header_section_level @@ -179,11 +177,6 @@ class TypeDeChamp < ApplicationRecord validates :libelle, presence: true, allow_blank: false, allow_nil: false validates :type_champ, presence: true, allow_blank: false, allow_nil: false - validates :textarea_character_limit, numericality: { - greater_than_or_equal_to: MINIMUM_TEXTAREA_CHARACTER_LIMIT_LENGTH, - only_integer: true, - allow_nil: true - } before_validation :check_mandatory before_validation :normalize_libelle @@ -242,10 +235,6 @@ class TypeDeChamp < ApplicationRecord drop_down_other == "1" || drop_down_other == true end - def textarea_character_limit? - textarea_character_limit.present? - end - def collapsible_explanation_enabled? collapsible_explanation_enabled == "1" end @@ -351,10 +340,6 @@ class TypeDeChamp < ApplicationRecord type_champ == TypeDeChamp.type_champs.fetch(:number) end - def textarea? - type_champ == TypeDeChamp.type_champs.fetch(:textarea) - end - def titre_identite? type_champ == TypeDeChamp.type_champs.fetch(:titre_identite) end @@ -554,8 +539,7 @@ class TypeDeChamp < ApplicationRecord type_champs.fetch(:multiple_drop_down_list), type_champs.fetch(:dossier_link), type_champs.fetch(:linked_drop_down_list), - type_champs.fetch(:drop_down_list), - type_champs.fetch(:textarea) + type_champs.fetch(:drop_down_list) true else false diff --git a/config/locales/en.yml b/config/locales/en.yml index fd0cc1698..ccc09d6c1 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -565,10 +565,6 @@ en: attributes: email: taken: ': Invitation already sent' - email_champ: - attributes: - value: - invalid: "is invalid. Fill in a valid email address, example: john.doe@example.fr" user: attributes: &error_attributes diff --git a/config/locales/fr.yml b/config/locales/fr.yml index b120f4021..8fcd3b281 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -566,10 +566,6 @@ fr: attributes: email: taken: ': Invitation déjà envoyée' - email_champ: - attributes: - value: - invalid: "est invalide. Saisir une adresse éléctronique valide, exemple : john.doe@exemple.fr" user: attributes: &error_attributes reset_password_token: diff --git a/spec/models/champs/email_champ_spec.rb b/spec/models/champs/email_champ_spec.rb deleted file mode 100644 index 7addc1e55..000000000 --- a/spec/models/champs/email_champ_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -describe Champs::EmailChamp do - subject { build(:champ_email, value: value).tap(&:valid?) } - - describe '#valid?' do - context 'when the value is an email' do - let(:value) { 'jean@dupont.fr' } - - it { is_expected.to be_valid } - end - - context 'when the value is not an email' do - let(:value) { 'jean@' } - - it { is_expected.to_not be_valid } - end - - context 'when the value is blank' do - let(:value) { '' } - - it { is_expected.to_not be_valid } - end - - context 'when the value is nil' do - let(:value) { nil } - - it { is_expected.to be_valid } - end - end -end