rollback - add just one new field and use actual description field

This commit is contained in:
Lisa Durand 2023-05-24 11:18:54 +02:00
parent 8291d58dbb
commit 7340206f81
11 changed files with 36 additions and 75 deletions

View file

@ -457,8 +457,7 @@ module Administrateurs
editable_params = [
:libelle,
:description,
:description_for_who,
:description_what,
:description_target_audience,
:organisation,
:direction,
:lien_site_web,

View file

@ -10,23 +10,21 @@ function syncInputToElement(fromSelector, toSelector) {
function syncFormToPreview() {
syncInputToElement('#procedure_libelle', '.procedure-title');
syncInputToElement('#procedure_description', '.procedure-description-body');
syncInputToElement('#procedure_description_what', '.js_description_what p');
syncInputToElement('#procedure_description', '.js_description p');
syncInputToElement(
'#procedure_description_for_who',
'.js_description_for_who p'
'#procedure_description_target_audience',
'.js_description_target_audience p'
);
}
delegate('input', '.procedure-form #procedure_libelle', syncFormToPreview);
delegate('input', '.procedure-form #procedure_description', syncFormToPreview);
delegate(
'input',
'.procedure-form #procedure_description_what',
'.procedure-form #procedure_description',
syncFormToPreview
);
delegate(
'input',
'.procedure-form #procedure_description_for_who',
'.procedure-form #procedure_description_target_audience',
syncFormToPreview
);

View file

@ -16,8 +16,7 @@
# closed_at :datetime
# declarative_with_state :string
# description :string
# description_for_who :string
# description_what :string
# description_target_audience :string
# dossiers_count_computed_at :datetime
# duree_conservation_dossiers_dans_ds :integer
# duree_conservation_etendue_par_ds :boolean default(FALSE), not null
@ -282,8 +281,7 @@ class Procedure < ApplicationRecord
}
validates :libelle, presence: true, allow_blank: false, allow_nil: false
validates :description, presence: true, allow_blank: false, allow_nil: false, if: -> { description_what.nil? && description_for_who.nil? }
validates :description_what, :description_for_who, presence: true, allow_blank: false, allow_nil: false, if: -> { description.nil? }
validates :description, presence: true, allow_blank: false, allow_nil: false
validates :administrateurs, presence: true
validates :lien_site_web, presence: true, if: :publiee?
validates :draft_types_de_champ_public,

View file

@ -8,26 +8,18 @@
%span.mandatory *
= f.text_field :libelle, class: 'fr-input', required: true
- if @procedure.description.present?
.fr-input-group
= f.label :description, class: 'fr-label' do
Description
%span.fr-hint-text Ce champ est déprécié, il n'est plus possible de le modifier. Pour plus de clarté pour les usagers, la description a été scindée en deux nouveaux champs : "objet de la démarche" et "à qui s'adresse la démarche". Vous pouvez remplir ces nouveaux champs en remplacement.
= f.text_field :description, class: 'fr-input', disabled: true
.fr-input-group
= f.label :description_what, class: 'fr-label' do
= f.label :description, class: 'fr-label' do
Quel est lobjet de la démarche ?
%span.mandatory *
%span.fr-hint-text Décrivez en quelques lignes le contexte, la finalité etc.
= f.text_area :description_what, rows: '6', class: 'fr-input'
= f.text_area :description, rows: '6', class: 'fr-input', required: true
.fr-input-group
= f.label :description_for_who, class: 'fr-label' do
= f.label :description_target_audience, class: 'fr-label' do
À qui sadresse la démarche ?
%span.mandatory *
%span.fr-hint-text Décrivez en quelques lignes les destinataires finaux de la démarche, les critères déligibilité sil y en a, les pré-requis, etc.
= f.text_area :description_for_who, rows: '6', class: 'fr-input'
= f.text_area :description_target_audience, rows: '6', class: 'fr-input'
%h3.header-subsection Logo de la démarche
= render Attachment::EditComponent.new(attached_file: @procedure.logo, view_as: :link)

View file

@ -26,22 +26,16 @@
%p Vous pouvez déposer vos dossiers jusquau #{procedure_auto_archive_datetime(procedure)}.
- if procedure.description_what.present? && procedure.description_for_who.present?
.fr-accordions-group
%section.fr-accordion
%h3.fr-accordion__title
%button.fr-accordion__btn{ "aria-controls" => "accordion-114", "aria-expanded" => "true" } Quel est lobjet de cette démarche ?
#accordion-114.fr-collapse.js_description_what
= h render SimpleFormatComponent.new(procedure.description_what, allow_a: true)
%section.fr-accordion
%h3.fr-accordion__title
%button.fr-accordion__btn{ "aria-controls" => "accordion-115", "aria-expanded" => "false" } À qui sadresse la démarche ?
#accordion-115.fr-collapse.js_description_for_who
= h render SimpleFormatComponent.new(procedure.description_for_who, allow_a: true)
- else
.procedure-description
.procedure-description-body.read-more-enabled.read-more-collapsed{ tabindex: "0", role: "region", "aria-label": t('views.users.dossiers.identite.description') }
.fr-accordions-group
%section.fr-accordion
%h2.fr-accordion__title
%button.fr-accordion__btn{ "aria-controls" => "accordion-114", "aria-expanded" => "true" } Quel est lobjet de cette démarche ?
#accordion-114.fr-collapse.js_description
= h render SimpleFormatComponent.new(procedure.description, allow_a: true)
= button_tag "Afficher la description complète", class: 'button read-more-button'
- if procedure.description_target_audience.present?
%section.fr-accordion
%h2.fr-accordion__title
%button.fr-accordion__btn{ "aria-controls" => "accordion-115", "aria-expanded" => "false" } À qui sadresse la démarche ?
#accordion-115.fr-collapse.js_description_target_audience
= h render SimpleFormatComponent.new(procedure.description_target_audience, allow_a: true)

View file

@ -8,8 +8,7 @@ en:
procedure:
path: Public link
organisation: Service
description_for_who: For who
description_what: Procedure subject
description_target_audience: For who
duree_conservation_dossiers_dans_ds: Duration files will be kept
max_duree_conservation_dossiers_dans_ds: Max duration allowed to keep files
aasm_state:

View file

@ -8,8 +8,7 @@ fr:
procedure:
path: Lien public
organisation: Organisme
description_for_who: À qui sadresse la démarche
description_what: Objet de la démarche
description_target_audience: À qui sadresse la démarche
duree_conservation_dossiers_dans_ds: Durée de conservation des dossiers sur demarches-simplifiees.fr (choisi par un usager)
max_duree_conservation_dossiers_dans_ds: Durée de conservation des dossiers maximum (autorisé par un super admin de DS)
id: Id

View file

@ -0,0 +1,5 @@
class AddDescriptionTargetAudienceToProcedure < ActiveRecord::Migration[7.0]
def change
add_column :procedures, :description_target_audience, :string
end
end

View file

@ -1,6 +0,0 @@
class AddTwoFieldsForDescriptionToProcedure < ActiveRecord::Migration[7.0]
def change
add_column :procedures, :description_what, :string
add_column :procedures, :description_for_who, :string
end
end

View file

@ -178,26 +178,9 @@ describe Procedure do
end
context 'description' do
context 'description can not be nil if description_what and description_for_who are nil too' do
let(:procedure) { build(:procedure, description: nil) }
it { is_expected.to allow_value('Description Demande de subvention').for(:description) }
it { expect(procedure.valid?).to eq(false) }
end
context 'description can be nil if description_what and description_for_who are filled' do
let(:procedure) { build(:procedure, description: nil, description_for_who: 'for who', description_what: 'what') }
it { expect(procedure.valid?).to eq(true) }
end
context 'description_what and description_for_who can not be nil if description is nil too' do
let(:procedure) { build(:procedure, description: nil) }
it { expect(procedure.valid?).to eq(false) }
end
context 'description_what and description_for_who can be nil if description is filled' do
let(:procedure) { build(:procedure, description: 'description') }
it { expect(procedure.valid?).to eq(true) }
end
it { is_expected.not_to allow_value(nil).for(:description) }
it { is_expected.not_to allow_value('').for(:description) }
it { is_expected.to allow_value('Description Demande de subvention').for(:description) }
end
context 'organisation' do

View file

@ -1,8 +1,8 @@
module ProcedureSpecHelper
def fill_in_dummy_procedure_details(fill_path: true)
fill_in 'procedure_libelle', with: 'libelle de la procedure'
fill_in 'procedure_description_what', with: "description de l'objet de la procedure"
fill_in 'procedure_description_for_who', with: "description d'à qui s'adresse la procedure"
fill_in 'procedure_description', with: "description de l'objet de la procedure"
fill_in 'procedure_description_target_audience', with: "description d'à qui s'adresse la procedure"
fill_in 'procedure_cadre_juridique', with: 'cadre juridique'
fill_in 'procedure_duree_conservation_dossiers_dans_ds', with: '3'
end