diff --git a/app/dashboards/procedure_dashboard.rb b/app/dashboards/procedure_dashboard.rb index b7d889d37..134208df4 100644 --- a/app/dashboards/procedure_dashboard.rb +++ b/app/dashboards/procedure_dashboard.rb @@ -46,6 +46,7 @@ class ProcedureDashboard < Administrate::BaseDashboard max_duree_conservation_dossiers_dans_ds: Field::Number, estimated_duration_visible: Field::Boolean, piece_justificative_multiple: Field::Boolean, + for_tiers_enabled: Field::Boolean, replaced_by_procedure_id: Field::String, tags: Field::Text, template: Field::Boolean @@ -109,6 +110,7 @@ class ProcedureDashboard < Administrate::BaseDashboard :max_duree_conservation_dossiers_dans_ds, :estimated_duration_visible, :piece_justificative_multiple, + :for_tiers_enabled, :replaced_by_procedure_id ].freeze @@ -121,6 +123,7 @@ class ProcedureDashboard < Administrate::BaseDashboard :max_duree_conservation_dossiers_dans_ds, :estimated_duration_visible, :piece_justificative_multiple, + :for_tiers_enabled, :replaced_by_procedure_id ].freeze diff --git a/app/views/users/dossiers/identite.html.haml b/app/views/users/dossiers/identite.html.haml index afb250715..8f79877b4 100644 --- a/app/views/users/dossiers/identite.html.haml +++ b/app/views/users/dossiers/identite.html.haml @@ -3,27 +3,28 @@ = render partial: "shared/dossiers/submit_is_over", locals: { dossier: @dossier } - if !dossier_submission_is_closed?(@dossier) - = form_for @dossier, url: identite_dossier_path(@dossier), method: :patch, html: { class: "form" }, data: {turbo: true, controller: :autosubmit} do |f| + - if @dossier.procedure.for_tiers_enabled? + = form_for @dossier, url: identite_dossier_path(@dossier), method: :patch, html: { class: "form" }, data: {turbo: true, controller: :autosubmit} do |f| - %fieldset#radio-rich-hint.fr-fieldset{ "aria-labelledby" => "radio-rich-hint-legend radio-rich-hint-messages" } - %legend#radio-rich-hint-legend.fr-fieldset__legend--regular.fr-fieldset__legend - = t('views.users.dossiers.identite.legend') + %fieldset#radio-rich-hint.fr-fieldset{ "aria-labelledby" => "radio-rich-hint-legend radio-rich-hint-messages" } + %legend#radio-rich-hint-legend.fr-fieldset__legend--regular.fr-fieldset__legend + = t('views.users.dossiers.identite.legend') - .fr-fieldset__element - .fr-radio-group.fr-radio-rich - = f.radio_button :for_tiers, false, required: true, id: "radio-self-manage" - %label.fr-label{ for: "radio-self-manage" } - = t('activerecord.attributes.dossier.for_tiers.false') - .fr-radio-rich__img - %span.fr-icon-user-fill - .fr-fieldset__element - .fr-radio-group.fr-radio-rich - = f.radio_button :for_tiers, true, required: true, id: "radio-tiers-manage" - %label.fr-label{ for: "radio-tiers-manage" } - = t('activerecord.attributes.dossier.for_tiers.true') - .fr-radio-rich__img - %span.fr-icon-parent-fill + .fr-fieldset__element + .fr-radio-group.fr-radio-rich + = f.radio_button :for_tiers, false, required: true, id: "radio-self-manage" + %label.fr-label{ for: "radio-self-manage" } + = t('activerecord.attributes.dossier.for_tiers.false') + .fr-radio-rich__img + %span.fr-icon-user-fill + .fr-fieldset__element + .fr-radio-group.fr-radio-rich + = f.radio_button :for_tiers, true, required: true, id: "radio-tiers-manage" + %label.fr-label{ for: "radio-tiers-manage" } + = t('activerecord.attributes.dossier.for_tiers.true') + .fr-radio-rich__img + %span.fr-icon-parent-fill - = f.submit t('views.users.dossiers.identite.continue'), class: 'visually-hidden' + = f.submit t('views.users.dossiers.identite.continue'), class: 'visually-hidden' = render Dossiers::IndividualFormComponent.new(dossier: @dossier) diff --git a/config/locales/models/procedure/en.yml b/config/locales/models/procedure/en.yml index 19aca8bdf..2f1d1c8b8 100644 --- a/config/locales/models/procedure/en.yml +++ b/config/locales/models/procedure/en.yml @@ -37,6 +37,7 @@ en: lien_dpo: Link or email to contact the data protection officer (DPO) duree_conservation_dossiers_dans_ds: Duration files will be kept max_duree_conservation_dossiers_dans_ds: Max duration allowed to keep files + for_tiers_enabled: Enable a third party to submit a file aasm_state: brouillon: Draft publiee: Published diff --git a/config/locales/models/procedure/fr.yml b/config/locales/models/procedure/fr.yml index cdf2309b8..78e2bcf26 100644 --- a/config/locales/models/procedure/fr.yml +++ b/config/locales/models/procedure/fr.yml @@ -20,6 +20,7 @@ fr: organisation: Organisme duree_conservation_dossiers_dans_ds: Durée de conservation des dossiers max_duree_conservation_dossiers_dans_ds: Durée maximale de conservation des dossiers (autorisée par un super admin) + for_tiers_enabled: Activer le dépot par un tiers id: Id libelle: Titre de la démarche description: Quel est l’objet de la démarche ? diff --git a/db/migrate/20240417053843_add_column_for_tiers_enabled_to_procedure.rb b/db/migrate/20240417053843_add_column_for_tiers_enabled_to_procedure.rb new file mode 100644 index 000000000..c2e40a0d4 --- /dev/null +++ b/db/migrate/20240417053843_add_column_for_tiers_enabled_to_procedure.rb @@ -0,0 +1,5 @@ +class AddColumnForTiersEnabledToProcedure < ActiveRecord::Migration[7.0] + def change + add_column :procedures, :for_tiers_enabled, :boolean, default: true, null: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 1caaf322c..b936bf6b3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2024_04_16_062900) do +ActiveRecord::Schema[7.0].define(version: 2024_04_17_053843) do # These are extensions that must be enabled in order to support this database enable_extension "pg_buffercache" enable_extension "pg_stat_statements" @@ -894,6 +894,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_04_16_062900) do t.boolean "euro_flag", default: false t.boolean "experts_require_administrateur_invitation", default: false t.boolean "for_individual", default: false + t.boolean "for_tiers_enabled", default: true, null: false t.datetime "hidden_at", precision: nil t.datetime "hidden_at_as_template", precision: nil t.boolean "instructeurs_self_management_enabled", default: false diff --git a/spec/views/users/dossiers/identite.html.haml_spec.rb b/spec/views/users/dossiers/identite.html.haml_spec.rb index 7c065f980..0ca066eee 100644 --- a/spec/views/users/dossiers/identite.html.haml_spec.rb +++ b/spec/views/users/dossiers/identite.html.haml_spec.rb @@ -1,5 +1,4 @@ describe 'users/dossiers/identite', type: :view do - let(:procedure) { create(:simple_procedure, :for_individual) } let(:dossier) { create(:dossier, :with_service, state: Dossier.states.fetch(:brouillon), procedure: procedure) } before do @@ -9,18 +8,43 @@ describe 'users/dossiers/identite', type: :view do subject! { render } - it 'has identity fields' do - within('.individual-infos') do - expect(rendered).to have_field(id: 'Prenom') - expect(rendered).to have_field(id: 'Nom') + context 'when procedure has for_tiers_enabled' do + let(:procedure) { create(:simple_procedure, :for_individual) } + + it 'has choice for you or a tiers' do + expect(rendered).to have_content "Pour vous" + expect(rendered).to have_content "Pour un bénéficiaire : membre de la famille, proche, mandant, professionnel en charge du suivi du dossier…" + end + + it 'has identity fields' do + within('.individual-infos') do + expect(rendered).to have_field(id: 'Prenom') + expect(rendered).to have_field(id: 'Nom') + end + end + + context 'when the demarche asks for the birthdate' do + let(:procedure) { create(:simple_procedure, for_individual: true, ask_birthday: true) } + + it 'has a birthday field' do + expect(rendered).to have_field('Date de naissance') + end end end - context 'when the demarche asks for the birthdate' do - let(:procedure) { create(:simple_procedure, for_individual: true, ask_birthday: true) } + context 'when procedure has for_tiers_enabled' do + let(:procedure) { create(:simple_procedure, :for_individual, for_tiers_enabled: false) } - it 'has a birthday field' do - expect(rendered).to have_field('Date de naissance') + it 'has choice for you or a tiers' do + expect(rendered).not_to have_content "Pour vous" + expect(rendered).not_to have_content "Pour un bénéficiaire : membre de la famille, proche, mandant, professionnel en charge du suivi du dossier…" + end + + it 'has identity fields' do + within('.individual-infos') do + expect(rendered).to have_field(id: 'Prenom') + expect(rendered).to have_field(id: 'Nom') + end end end end