feat(TypeDeChampEditor): prevent to destroy a type de champ used by inligibilite rules
This commit is contained in:
parent
be5f580237
commit
178685b34b
3 changed files with 20 additions and 1 deletions
|
@ -10,7 +10,7 @@
|
|||
.flex.justify-start.width-33
|
||||
.cell.flex.justify-start.column.flex-grow
|
||||
= form.label :type_champ, "Type de champ", for: dom_id(type_de_champ, :type_champ)
|
||||
= form.select :type_champ, grouped_options_for_select(types_of_type_de_champ, type_de_champ.type_champ), {}, class: 'fr-select small-margin small inline width-100', id: dom_id(type_de_champ, :type_champ), disabled: coordinate.used_by_routing_rules?
|
||||
= form.select :type_champ, grouped_options_for_select(types_of_type_de_champ, type_de_champ.type_champ), {}, class: 'fr-select small-margin small inline width-100', id: dom_id(type_de_champ, :type_champ), disabled: coordinate.used_by_routing_rules? || coordinate.used_by_ineligibilite_rules?
|
||||
|
||||
.flex.column.justify-start.flex-grow
|
||||
.cell
|
||||
|
@ -136,6 +136,10 @@
|
|||
%span
|
||||
utilisé pour
|
||||
= link_to('le routage', admin_procedure_groupe_instructeurs_path(revision.procedure_id, anchor: 'routing-rules'))
|
||||
- elsif coordinate.used_by_ineligibilite_rules?
|
||||
%span
|
||||
utilisé pour
|
||||
= link_to('l’eligibilité des dossiers', edit_admin_procedure_ineligibilite_rules_path(revision.procedure_id))
|
||||
- else
|
||||
= button_to type_de_champ_path, class: 'fr-btn fr-btn--tertiary-no-outline fr-icon-delete-line', title: "Supprimer le champ", method: :delete, form: { data: { turbo_confirm: 'Êtes vous sûr de vouloir supprimer ce champ ?' } } do
|
||||
%span.sr-only Supprimer
|
||||
|
|
|
@ -75,4 +75,8 @@ class ProcedureRevisionTypeDeChamp < ApplicationRecord
|
|||
def used_by_routing_rules?
|
||||
stable_id.in?(procedure.stable_ids_used_by_routing_rules)
|
||||
end
|
||||
|
||||
def used_by_ineligibilite_rules?
|
||||
revision.ineligibilite_enabled? && stable_id.in?(revision.ineligibilite_rules&.sources || [])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,10 +2,12 @@ describe TypesDeChampEditor::ChampComponent, type: :component do
|
|||
describe 'render' do
|
||||
let(:component) { described_class.new(coordinate:, upper_coordinates: []) }
|
||||
let(:routing_rules_stable_ids) { [] }
|
||||
let(:ineligibilite_rules_used?) { false }
|
||||
|
||||
before do
|
||||
Flipper.enable_actor(:engagement_juridique_type_de_champ, procedure)
|
||||
allow_any_instance_of(Procedure).to receive(:stable_ids_used_by_routing_rules).and_return(routing_rules_stable_ids)
|
||||
allow_any_instance_of(ProcedureRevisionTypeDeChamp).to receive(:used_by_ineligibilite_rules?).and_return(ineligibilite_rules_used?)
|
||||
render_inline(component)
|
||||
end
|
||||
|
||||
|
@ -29,6 +31,15 @@ describe TypesDeChampEditor::ChampComponent, type: :component do
|
|||
expect(page).to have_text(/utilisé pour\nle routage/)
|
||||
end
|
||||
end
|
||||
|
||||
context 'drop down tdc used for ineligibilite_rules' do
|
||||
let(:ineligibilite_rules_used?) { true }
|
||||
|
||||
it do
|
||||
expect(page).to have_css("select[disabled=\"disabled\"]")
|
||||
expect(page).to have_text(/l’eligibilité des dossiers/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'tdc ej' do
|
||||
|
|
Loading…
Reference in a new issue