refactor(type de champ): rename routable_types in simple_routable_types
This commit is contained in:
parent
52d8f8ed00
commit
60ff785009
6 changed files with 10 additions and 10 deletions
|
@ -41,7 +41,7 @@ module Administrateurs
|
||||||
@procedure = procedure
|
@procedure = procedure
|
||||||
stable_id = params[:create_simple_routing][:stable_id].to_i
|
stable_id = params[:create_simple_routing][:stable_id].to_i
|
||||||
|
|
||||||
tdc = @procedure.active_revision.routable_types_de_champ.find { |tdc| tdc.stable_id == stable_id }
|
tdc = @procedure.active_revision.simple_routable_types_de_champ.find { |tdc| tdc.stable_id == stable_id }
|
||||||
|
|
||||||
case tdc.type_champ
|
case tdc.type_champ
|
||||||
when TypeDeChamp.type_champs.fetch(:departements)
|
when TypeDeChamp.type_champs.fetch(:departements)
|
||||||
|
|
|
@ -265,8 +265,8 @@ class ProcedureRevision < ApplicationRecord
|
||||||
[coordinate, coordinate&.type_de_champ]
|
[coordinate, coordinate&.type_de_champ]
|
||||||
end
|
end
|
||||||
|
|
||||||
def routable_types_de_champ
|
def simple_routable_types_de_champ
|
||||||
types_de_champ_public.filter(&:routable?)
|
types_de_champ_public.filter(&:simple_routable?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def conditionable_types_de_champ
|
def conditionable_types_de_champ
|
||||||
|
|
|
@ -110,7 +110,7 @@ class TypeDeChamp < ApplicationRecord
|
||||||
expression_reguliere: 'expression_reguliere'
|
expression_reguliere: 'expression_reguliere'
|
||||||
}
|
}
|
||||||
|
|
||||||
ROUTABLE_TYPES = [
|
SIMPLE_ROUTABLE_TYPES = [
|
||||||
type_champs.fetch(:drop_down_list),
|
type_champs.fetch(:drop_down_list),
|
||||||
type_champs.fetch(:communes),
|
type_champs.fetch(:communes),
|
||||||
type_champs.fetch(:departements),
|
type_champs.fetch(:departements),
|
||||||
|
@ -652,8 +652,8 @@ class TypeDeChamp < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def routable?
|
def simple_routable?
|
||||||
type_champ.in?(ROUTABLE_TYPES)
|
type_champ.in?(SIMPLE_ROUTABLE_TYPES)
|
||||||
end
|
end
|
||||||
|
|
||||||
def conditionable?
|
def conditionable?
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
%div{ data: { 'action': "click->enable-submit-if-checked#click" } }
|
%div{ data: { 'action': "click->enable-submit-if-checked#click" } }
|
||||||
.notice
|
.notice
|
||||||
Sélectionner le champ à partir duquel créer des groupes d’instructeurs
|
Sélectionner le champ à partir duquel créer des groupes d’instructeurs
|
||||||
- buttons_content = @procedure.active_revision.routable_types_de_champ.map { |tdc| { label: tdc.libelle, value: tdc.stable_id } }
|
- buttons_content = @procedure.active_revision.simple_routable_types_de_champ.map { |tdc| { label: tdc.libelle, value: tdc.stable_id } }
|
||||||
= render Dsfr::RadioButtonListComponent.new(form: f,
|
= render Dsfr::RadioButtonListComponent.new(form: f,
|
||||||
target: :stable_id,
|
target: :stable_id,
|
||||||
buttons: buttons_content)
|
buttons: buttons_content)
|
||||||
|
|
|
@ -12,7 +12,7 @@ describe 're_routing_dossiers' do
|
||||||
|
|
||||||
dossier2.champs.last.update(value: 'Allier')
|
dossier2.champs.last.update(value: 'Allier')
|
||||||
|
|
||||||
tdc = procedure.active_revision.routable_types_de_champ.first
|
tdc = procedure.active_revision.simple_routable_types_de_champ.first
|
||||||
|
|
||||||
tdc_options = APIGeoService.departements.map { ["#{_1[:code]} – #{_1[:name]}", _1[:code]] }
|
tdc_options = APIGeoService.departements.map { ["#{_1[:code]} – #{_1[:name]}", _1[:code]] }
|
||||||
|
|
||||||
|
|
|
@ -1144,7 +1144,7 @@ describe ProcedureRevision do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#routable_types_de_champ' do
|
describe '#simple_routable_types_de_champ' do
|
||||||
let(:procedure) do
|
let(:procedure) do
|
||||||
create(:procedure, types_de_champ_public: [
|
create(:procedure, types_de_champ_public: [
|
||||||
{ type: :text, libelle: 'l1' },
|
{ type: :text, libelle: 'l1' },
|
||||||
|
@ -1156,6 +1156,6 @@ describe ProcedureRevision do
|
||||||
])
|
])
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(draft.routable_types_de_champ.pluck(:libelle)).to eq(['l2', 'l3', 'l4', 'l5', 'l6']) }
|
it { expect(draft.simple_routable_types_de_champ.pluck(:libelle)).to eq(['l2', 'l3', 'l4', 'l5', 'l6']) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue