Revert "Merge pull request #8844 from demarches-simplifiees/feat/7739"
This reverts commit04fbfa15b7
, reversing changes made toaac1cc7161
.
This commit is contained in:
parent
e744ed99d2
commit
909d726429
12 changed files with 26 additions and 114 deletions
|
@ -42,11 +42,6 @@ $dossier-actions-bar-border-width: 1px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.characters-count {
|
|
||||||
position: relative;
|
|
||||||
top: -1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.warning {
|
.warning {
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
background-color: #f9b91666;
|
background-color: #f9b91666;
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
en:
|
|
||||||
remaining_characters: You have %{remaining_words} characters remaining.
|
|
||||||
excess_characters: You have %{excess_words} characters too many.
|
|
|
@ -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.
|
|
|
@ -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,
|
~ @form.text_area :value,
|
||||||
id: @champ.input_id,
|
id: @champ.input_id,
|
||||||
aria: { describedby: @champ.describedby_id },
|
aria: { describedby: @champ.describedby_id },
|
||||||
rows: 6,
|
rows: 6,
|
||||||
required: @champ.required?,
|
required: @champ.required?,
|
||||||
value: html_to_string(@champ.value)
|
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))
|
|
||||||
|
|
|
@ -36,8 +36,6 @@ fr:
|
||||||
add_condition: Une condition a été ajoutée sur le champ « %{label} ». La nouvelle condition est « %{to} ».
|
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.
|
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_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:
|
private:
|
||||||
add: L’annotation privée « %{label} » a été ajoutée.
|
add: L’annotation privée « %{label} » a été ajoutée.
|
||||||
remove: L’annotation privée « %{label} » a été supprimée.
|
remove: L’annotation privée « %{label} » a été supprimée.
|
||||||
|
|
|
@ -130,14 +130,7 @@
|
||||||
= t(".#{prefix}.update_condition", label: change.label, to: change.to)
|
= t(".#{prefix}.update_condition", label: change.label, to: change.to)
|
||||||
- if !total_dossiers.zero? && !change.can_rebase?
|
- if !total_dossiers.zero? && !change.can_rebase?
|
||||||
.fr-alert.fr-alert--warning.fr-mt-1v
|
.fr-alert.fr-alert--warning.fr-mt-1v
|
||||||
%p= t('.breakigng_change', count: total_dossiers)
|
%p= t('.breaking_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)
|
|
||||||
|
|
||||||
- if @public_move_changes.present?
|
- if @public_move_changes.present?
|
||||||
- list.with_item do
|
- list.with_item do
|
||||||
|
|
|
@ -101,11 +101,8 @@
|
||||||
= form.label :collapsible_explanation_text, for: dom_id(type_de_champ, :collapsible_explanation_text) do
|
= 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"
|
= "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)
|
= 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?
|
- if type_de_champ.block?
|
||||||
.flex.justify-start.section.ml-1
|
.flex.justify-start.section.ml-1
|
||||||
|
|
|
@ -119,29 +119,28 @@ module Administrateurs
|
||||||
|
|
||||||
def type_de_champ_update_params
|
def type_de_champ_update_params
|
||||||
params.required(:type_de_champ).permit(:type_champ,
|
params.required(:type_de_champ).permit(:type_champ,
|
||||||
:libelle,
|
:libelle,
|
||||||
:description,
|
:description,
|
||||||
:mandatory,
|
:mandatory,
|
||||||
:drop_down_list_value,
|
:drop_down_list_value,
|
||||||
:drop_down_other,
|
:drop_down_other,
|
||||||
:drop_down_secondary_libelle,
|
:drop_down_secondary_libelle,
|
||||||
:drop_down_secondary_description,
|
:drop_down_secondary_description,
|
||||||
:collapsible_explanation_enabled,
|
:collapsible_explanation_enabled,
|
||||||
:collapsible_explanation_text,
|
:collapsible_explanation_text,
|
||||||
:header_section_level,
|
:header_section_level,
|
||||||
:textarea_character_limit,
|
editable_options: [
|
||||||
editable_options: [
|
:cadastres,
|
||||||
:cadastres,
|
:unesco,
|
||||||
:unesco,
|
:arretes_protection,
|
||||||
:arretes_protection,
|
:conservatoire_littoral,
|
||||||
:conservatoire_littoral,
|
:reserves_chasse_faune_sauvage,
|
||||||
:reserves_chasse_faune_sauvage,
|
:reserves_biologiques,
|
||||||
:reserves_biologiques,
|
:reserves_naturelles,
|
||||||
:reserves_naturelles,
|
:natura_2000,
|
||||||
:natura_2000,
|
:zones_humides,
|
||||||
:zones_humides,
|
:znieff
|
||||||
:znieff
|
])
|
||||||
])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def draft
|
def draft
|
||||||
|
|
|
@ -75,8 +75,6 @@ class Champ < ApplicationRecord
|
||||||
:mandatory?,
|
:mandatory?,
|
||||||
:prefillable?,
|
:prefillable?,
|
||||||
:refresh_after_update?,
|
:refresh_after_update?,
|
||||||
:textarea_character_limit?,
|
|
||||||
:textarea_character_limit,
|
|
||||||
to: :type_de_champ
|
to: :type_de_champ
|
||||||
|
|
||||||
delegate :to_typed_id, :to_typed_id_for_query, to: :type_de_champ, prefix: true
|
delegate :to_typed_id, :to_typed_id_for_query, to: :type_de_champ, prefix: true
|
||||||
|
|
|
@ -24,29 +24,4 @@ class Champs::TextareaChamp < Champs::TextChamp
|
||||||
def for_export
|
def for_export
|
||||||
value.present? ? ActionView::Base.full_sanitizer.sanitize(value) : nil
|
value.present? ? ActionView::Base.full_sanitizer.sanitize(value) : nil
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -377,13 +377,6 @@ class ProcedureRevision < ApplicationRecord
|
||||||
from_type_de_champ.piece_justificative_template_filename,
|
from_type_de_champ.piece_justificative_template_filename,
|
||||||
to_type_de_champ.piece_justificative_template_filename)
|
to_type_de_champ.piece_justificative_template_filename)
|
||||||
end
|
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
|
end
|
||||||
changes
|
changes
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,7 +19,6 @@ class TypeDeChamp < ApplicationRecord
|
||||||
|
|
||||||
FILE_MAX_SIZE = 200.megabytes
|
FILE_MAX_SIZE = 200.megabytes
|
||||||
FEATURE_FLAGS = {}
|
FEATURE_FLAGS = {}
|
||||||
MINIMUM_TEXTAREA_CHARACTER_LIMIT_LENGTH = 400
|
|
||||||
|
|
||||||
STRUCTURE = :structure
|
STRUCTURE = :structure
|
||||||
ETAT_CIVIL = :etat_civil
|
ETAT_CIVIL = :etat_civil
|
||||||
|
@ -119,7 +118,6 @@ class TypeDeChamp < ApplicationRecord
|
||||||
:drop_down_secondary_libelle,
|
:drop_down_secondary_libelle,
|
||||||
:drop_down_secondary_description,
|
:drop_down_secondary_description,
|
||||||
:drop_down_other,
|
:drop_down_other,
|
||||||
:textarea_character_limit,
|
|
||||||
:collapsible_explanation_enabled,
|
:collapsible_explanation_enabled,
|
||||||
:collapsible_explanation_text,
|
:collapsible_explanation_text,
|
||||||
:header_section_level
|
:header_section_level
|
||||||
|
@ -179,11 +177,6 @@ class TypeDeChamp < ApplicationRecord
|
||||||
|
|
||||||
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
||||||
validates :type_champ, 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 :check_mandatory
|
||||||
before_validation :normalize_libelle
|
before_validation :normalize_libelle
|
||||||
|
@ -242,10 +235,6 @@ class TypeDeChamp < ApplicationRecord
|
||||||
drop_down_other == "1" || drop_down_other == true
|
drop_down_other == "1" || drop_down_other == true
|
||||||
end
|
end
|
||||||
|
|
||||||
def textarea_character_limit?
|
|
||||||
textarea_character_limit.present?
|
|
||||||
end
|
|
||||||
|
|
||||||
def collapsible_explanation_enabled?
|
def collapsible_explanation_enabled?
|
||||||
collapsible_explanation_enabled == "1"
|
collapsible_explanation_enabled == "1"
|
||||||
end
|
end
|
||||||
|
@ -351,10 +340,6 @@ class TypeDeChamp < ApplicationRecord
|
||||||
type_champ == TypeDeChamp.type_champs.fetch(:number)
|
type_champ == TypeDeChamp.type_champs.fetch(:number)
|
||||||
end
|
end
|
||||||
|
|
||||||
def textarea?
|
|
||||||
type_champ == TypeDeChamp.type_champs.fetch(:textarea)
|
|
||||||
end
|
|
||||||
|
|
||||||
def titre_identite?
|
def titre_identite?
|
||||||
type_champ == TypeDeChamp.type_champs.fetch(:titre_identite)
|
type_champ == TypeDeChamp.type_champs.fetch(:titre_identite)
|
||||||
end
|
end
|
||||||
|
@ -554,8 +539,7 @@ class TypeDeChamp < ApplicationRecord
|
||||||
type_champs.fetch(:multiple_drop_down_list),
|
type_champs.fetch(:multiple_drop_down_list),
|
||||||
type_champs.fetch(:dossier_link),
|
type_champs.fetch(:dossier_link),
|
||||||
type_champs.fetch(:linked_drop_down_list),
|
type_champs.fetch(:linked_drop_down_list),
|
||||||
type_champs.fetch(:drop_down_list),
|
type_champs.fetch(:drop_down_list)
|
||||||
type_champs.fetch(:textarea)
|
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
|
|
Loading…
Reference in a new issue