Merge pull request #11163 from colinux/sva-without-declarative
ETQ admin je suis informé que je ne peux pas activer le SVA/SVR si la démarche est déclarative et vice-versa
This commit is contained in:
commit
520cef7022
7 changed files with 79 additions and 10 deletions
|
@ -8,9 +8,12 @@ class Procedure::SVASVRFormComponent < ApplicationComponent
|
||||||
@configuration = configuration
|
@configuration = configuration
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
def form_disabled?
|
def form_disabled?
|
||||||
return false if procedure.brouillon?
|
|
||||||
return true if !procedure.feature_enabled?(:sva)
|
return true if !procedure.feature_enabled?(:sva)
|
||||||
|
return true if procedure.declarative?
|
||||||
|
return false if procedure.brouillon?
|
||||||
|
|
||||||
procedure.sva_svr_enabled?
|
procedure.sva_svr_enabled?
|
||||||
end
|
end
|
||||||
|
@ -20,8 +23,8 @@ class Procedure::SVASVRFormComponent < ApplicationComponent
|
||||||
|
|
||||||
[
|
[
|
||||||
{ label: t("disabled", scope:), value: "disabled", disabled: form_disabled? },
|
{ label: t("disabled", scope:), value: "disabled", disabled: form_disabled? },
|
||||||
{ label: t("sva", scope:), value: "sva", hint: t("sva_hint", scope:) },
|
{ label: t("sva", scope:), value: "sva", hint: t("sva_hint", scope:), disabled: form_disabled? },
|
||||||
{ label: t("svr", scope:), value: "svr", hint: t("svr_hint", scope:) }
|
{ label: t("svr", scope:), value: "svr", hint: t("svr_hint", scope:), disabled: form_disabled? }
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,12 +35,14 @@ class Procedure::SVASVRFormComponent < ApplicationComponent
|
||||||
{
|
{
|
||||||
value: "continue",
|
value: "continue",
|
||||||
label: t("continue_label", scope: scope),
|
label: t("continue_label", scope: scope),
|
||||||
hint: t("continue_hint", scope: scope)
|
hint: t("continue_hint", scope: scope),
|
||||||
|
disabled: form_disabled?
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "reset",
|
value: "reset",
|
||||||
label: t("reset_label", scope: scope),
|
label: t("reset_label", scope: scope),
|
||||||
hint: t("reset_hint", scope: scope)
|
hint: t("reset_hint", scope: scope),
|
||||||
|
disabled: form_disabled?
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,3 +26,4 @@ en:
|
||||||
reset_hint: "Example: if the file is resubmitted on April 15 and the delay is 2 months, the decision will be automatically made on June 15, unless the instructor pronounces in the meantime or asks for corrections again."
|
reset_hint: "Example: if the file is resubmitted on April 15 and the delay is 2 months, the decision will be automatically made on June 15, unless the instructor pronounces in the meantime or asks for corrections again."
|
||||||
notice_new_files_only: "Information: if you activate this rule, only the newly submitted files will be subject to it."
|
notice_new_files_only: "Information: if you activate this rule, only the newly submitted files will be subject to it."
|
||||||
notice_edit_denied: "Warning: SVA/SVR cannot be changed or disabled."
|
notice_edit_denied: "Warning: SVA/SVR cannot be changed or disabled."
|
||||||
|
notice_incompatible_with_declarative_html: 'Warning: SVA/SVR is incompatible with declarative procedures. <a href="%{edit_admin_procedure_path}">Disable declarative mode</a> first.'
|
||||||
|
|
|
@ -26,3 +26,4 @@ fr:
|
||||||
reset_hint: "Exemple: si le dossier est re-déposé le 15 avril et que le délai est de 2 mois, la décision sera automatiquement prise le 16 juin, sauf à ce que l’instructeur se prononce d’ici là ou demande à nouveau des corrections."
|
reset_hint: "Exemple: si le dossier est re-déposé le 15 avril et que le délai est de 2 mois, la décision sera automatiquement prise le 16 juin, sauf à ce que l’instructeur se prononce d’ici là ou demande à nouveau des corrections."
|
||||||
notice_new_files_only: "Information : si vous activez cette règle, seuls les nouveaux dossiers déposés y seront soumis."
|
notice_new_files_only: "Information : si vous activez cette règle, seuls les nouveaux dossiers déposés y seront soumis."
|
||||||
notice_edit_denied: "Avertissement : le changement ou la désactivation du SVA/SVR est impossible."
|
notice_edit_denied: "Avertissement : le changement ou la désactivation du SVA/SVR est impossible."
|
||||||
|
notice_incompatible_with_declarative_html: 'Avertissement : le SVA/SVR est incompatible avec les démarches déclaratives. <a href="%{edit_admin_procedure_path}">Désactiver le déclaratif</a> au préalable.'
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
.fr-alert.fr-alert--info.fr-alert--sm.fr-mb-4w
|
.fr-alert.fr-alert--info.fr-alert--sm.fr-mb-4w
|
||||||
%p= t('.notice_new_files_only')
|
%p= t('.notice_new_files_only')
|
||||||
|
|
||||||
|
- if procedure.declarative?
|
||||||
|
.fr-alert.fr-alert--warning.fr-alert--sm.fr-mb-4w
|
||||||
|
%p= t('.notice_incompatible_with_declarative_html', edit_admin_procedure_path: edit_admin_procedure_path(procedure, anchor: ":~:text=Options avancées"))
|
||||||
|
|
||||||
- if procedure.publiee? && procedure.sva_svr_enabled?
|
- if procedure.publiee? && procedure.sva_svr_enabled?
|
||||||
.fr-alert.fr-alert--warning.fr-alert--sm.fr-mb-4w
|
.fr-alert.fr-alert--warning.fr-alert--sm.fr-mb-4w
|
||||||
%p= t('.notice_edit_denied')
|
%p= t('.notice_edit_denied')
|
||||||
|
@ -37,4 +41,4 @@
|
||||||
|
|
||||||
= render Dsfr::RadioButtonListComponent.new(form: f, target: :resume, buttons: resume_buttons)
|
= render Dsfr::RadioButtonListComponent.new(form: f, target: :resume, buttons: resume_buttons)
|
||||||
|
|
||||||
= render Procedure::FixedFooterComponent.new(procedure: @procedure, form: f, is_form_disabled: form_disabled?)
|
= render Procedure::FixedFooterComponent.new(procedure: procedure, form: f, is_form_disabled: form_disabled?)
|
||||||
|
|
|
@ -16,13 +16,19 @@ module Administrateurs
|
||||||
@configuration = @procedure.sva_svr_configuration
|
@configuration = @procedure.sva_svr_configuration
|
||||||
@configuration.assign_attributes(configuration_params)
|
@configuration.assign_attributes(configuration_params)
|
||||||
|
|
||||||
if @configuration.valid?
|
if @configuration.invalid?
|
||||||
@procedure.update!(sva_svr: @configuration.attributes)
|
flash.now.alert = "Des erreurs empêchent la validation du SVA/SVR. Corrigez les erreurs"
|
||||||
|
render :edit and return
|
||||||
|
end
|
||||||
|
|
||||||
|
@procedure.assign_attributes(sva_svr: @configuration.attributes)
|
||||||
|
|
||||||
|
if @procedure.valid?
|
||||||
|
@procedure.save!
|
||||||
flash.notice = "La configuration SVA/SVR a été mise à jour et prend immédiatement effet pour les nouveaux dossiers."
|
flash.notice = "La configuration SVA/SVR a été mise à jour et prend immédiatement effet pour les nouveaux dossiers."
|
||||||
redirect_to admin_procedure_path(@procedure)
|
redirect_to admin_procedure_path(@procedure)
|
||||||
else
|
else
|
||||||
flash.now.alert = "Des erreurs empêchent la validation du SVA/SVR. Corrigez les erreurs"
|
flash.now.alert = @procedure.errors.full_messages
|
||||||
render :edit
|
render :edit
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -167,7 +167,8 @@
|
||||||
Démarche déclarative
|
Démarche déclarative
|
||||||
%span.fr-hint-text.fr-mt-0
|
%span.fr-hint-text.fr-mt-0
|
||||||
Par défaut, un dossier déposé peut être complété ou corrigé par le demandeur jusqu'à sa mise en instruction.<br>
|
Par défaut, un dossier déposé peut être complété ou corrigé par le demandeur jusqu'à sa mise en instruction.<br>
|
||||||
Dans une démarche déclarative, une fois déposé, un dossier ne peut plus être modifié. Soit il passe immédiatement « en instruction » pour être traité, soit il est immédiatement « accepté ».
|
Dans une démarche déclarative, une fois déposé, un dossier ne peut plus être modifié. Soit il passe immédiatement « en instruction » pour être traité, soit il est immédiatement « accepté ».<br>
|
||||||
|
Si vous envisagez activer la règle du ”Silence Vaut Accord” ou “Silence Vaut Rejet“, laissez en démarche non déclarative.
|
||||||
.fr-fieldset__element
|
.fr-fieldset__element
|
||||||
.fr-radio-group
|
.fr-radio-group
|
||||||
= f.radio_button :declarative_with_state, ''
|
= f.radio_button :declarative_with_state, ''
|
||||||
|
|
51
spec/components/procedures/sva_svr_form_component_spec.rb
Normal file
51
spec/components/procedures/sva_svr_form_component_spec.rb
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
RSpec.describe Procedure::SVASVRFormComponent, type: :component do
|
||||||
|
let(:procedure) { create(:procedure, :published) }
|
||||||
|
let(:configuration) { SVASVRConfiguration.new }
|
||||||
|
|
||||||
|
subject(:rendered) { render_inline(described_class.new(procedure: procedure, configuration: configuration)) }
|
||||||
|
|
||||||
|
let(:sva_enabled) { true }
|
||||||
|
before { allow(procedure).to receive(:feature_enabled?).with(:sva).and_return(sva_enabled) }
|
||||||
|
|
||||||
|
context "when sva feature is disabled" do
|
||||||
|
let(:sva_enabled) { false }
|
||||||
|
|
||||||
|
it "shows contact information and disables form" do
|
||||||
|
expect(rendered).to have_text(/Pour activer le paramétrage.*contactez-nous/)
|
||||||
|
expect(rendered).to have_field('Silence Vaut Accord', disabled: true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when procedure is published with config" do
|
||||||
|
let(:procedure) { create(:procedure, :published, :sva) }
|
||||||
|
|
||||||
|
it "shows notice about new files only" do
|
||||||
|
expect(rendered).to have_text(/changement.*impossible/i)
|
||||||
|
expect(rendered).to have_field('Silence Vaut Accord', disabled: true)
|
||||||
|
expect(rendered).to have_button('Enregistrer', disabled: true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when procedure is declarative" do
|
||||||
|
let(:procedure) { create(:procedure, :published, declarative_with_state: :en_instruction) }
|
||||||
|
|
||||||
|
it "shows incompatibility warning" do
|
||||||
|
expect(rendered).to have_text(/incompatible avec les démarches déclaratives/i)
|
||||||
|
expect(rendered).to have_link("Désactiver le déclaratif")
|
||||||
|
expect(rendered).to have_field('Silence Vaut Accord', disabled: true)
|
||||||
|
expect(rendered).to have_button('Enregistrer', disabled: true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when procedure is brouillon with sva enabled" do
|
||||||
|
let(:procedure) { create(:procedure, :draft, :sva) }
|
||||||
|
|
||||||
|
it "shows enabled form with all options" do
|
||||||
|
expect(rendered).to have_field('Silence Vaut Accord', type: 'radio', disabled: false)
|
||||||
|
expect(rendered).to have_field('Silence Vaut Rejet', type: 'radio', disabled: false)
|
||||||
|
expect(rendered).to have_button('Enregistrer', disabled: false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Reference in a new issue