🐛 make possible_values_list method public
This commit is contained in:
parent
a77a0e2c7f
commit
0159a10969
5 changed files with 18 additions and 18 deletions
|
@ -1,10 +1,4 @@
|
||||||
class TypesDeChamp::PrefillDropDownListTypeDeChamp < TypesDeChamp::PrefillTypeDeChamp
|
class TypesDeChamp::PrefillDropDownListTypeDeChamp < TypesDeChamp::PrefillTypeDeChamp
|
||||||
def example_value
|
|
||||||
possible_values_list.first
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def possible_values_list
|
def possible_values_list
|
||||||
if drop_down_other?
|
if drop_down_other?
|
||||||
drop_down_list_enabled_non_empty_options.insert(
|
drop_down_list_enabled_non_empty_options.insert(
|
||||||
|
@ -15,4 +9,8 @@ class TypesDeChamp::PrefillDropDownListTypeDeChamp < TypesDeChamp::PrefillTypeDe
|
||||||
drop_down_list_enabled_non_empty_options
|
drop_down_list_enabled_non_empty_options
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def example_value
|
||||||
|
possible_values_list.first
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
class TypesDeChamp::PrefillPaysTypeDeChamp < TypesDeChamp::PrefillTypeDeChamp
|
class TypesDeChamp::PrefillPaysTypeDeChamp < TypesDeChamp::PrefillTypeDeChamp
|
||||||
|
def possible_values_list
|
||||||
|
countries.map { |country| "#{country[:code]} (#{country[:name]})" }
|
||||||
|
end
|
||||||
|
|
||||||
def example_value
|
def example_value
|
||||||
countries.pick(:code)
|
countries.pick(:code)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def possible_values_list
|
|
||||||
countries.map { |country| "#{country[:code]} (#{country[:name]})" }
|
|
||||||
end
|
|
||||||
|
|
||||||
def countries
|
def countries
|
||||||
@countries ||= APIGeoService.countries.sort_by { |country| country[:code] }
|
@countries ||= APIGeoService.countries.sort_by { |country| country[:code] }
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
class TypesDeChamp::PrefillRegionTypeDeChamp < TypesDeChamp::PrefillTypeDeChamp
|
class TypesDeChamp::PrefillRegionTypeDeChamp < TypesDeChamp::PrefillTypeDeChamp
|
||||||
private
|
|
||||||
|
|
||||||
def possible_values_list
|
def possible_values_list
|
||||||
regions.map { |region| "#{region[:code]} (#{region[:name]})" }
|
regions.map { |region| "#{region[:code]} (#{region[:name]})" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
def regions
|
def regions
|
||||||
@regions ||= APIGeoService.regions.sort_by { |region| region[:code] }
|
@regions ||= APIGeoService.regions.sort_by { |region| region[:code] }
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,6 +27,12 @@ class TypesDeChamp::PrefillTypeDeChamp < SimpleDelegator
|
||||||
[possible_values_list_display, link_to_all_possible_values].compact.join('<br>').html_safe # rubocop:disable Rails/OutputSafety
|
[possible_values_list_display, link_to_all_possible_values].compact.join('<br>').html_safe # rubocop:disable Rails/OutputSafety
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def possible_values_list
|
||||||
|
return [] unless prefillable?
|
||||||
|
|
||||||
|
[I18n.t("views.prefill_descriptions.edit.possible_values.#{type_champ}_html")]
|
||||||
|
end
|
||||||
|
|
||||||
def example_value
|
def example_value
|
||||||
return nil unless prefillable?
|
return nil unless prefillable?
|
||||||
|
|
||||||
|
@ -43,12 +49,6 @@ class TypesDeChamp::PrefillTypeDeChamp < SimpleDelegator
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def possible_values_list
|
|
||||||
return [] unless prefillable?
|
|
||||||
|
|
||||||
[I18n.t("views.prefill_descriptions.edit.possible_values.#{type_champ}_html")]
|
|
||||||
end
|
|
||||||
|
|
||||||
def link_to_all_possible_values
|
def link_to_all_possible_values
|
||||||
return unless too_many_possible_values? && prefillable?
|
return unless too_many_possible_values? && prefillable?
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@ RSpec.describe PrefillTypeDeChampsController, type: :controller do
|
||||||
context 'when the procedure is found' do
|
context 'when the procedure is found' do
|
||||||
context 'when the procedure is publiee' do
|
context 'when the procedure is publiee' do
|
||||||
context 'when the procedure is opendata' do
|
context 'when the procedure is opendata' do
|
||||||
|
render_views
|
||||||
|
|
||||||
let(:procedure) { create(:procedure, :published, opendata: true) }
|
let(:procedure) { create(:procedure, :published, opendata: true) }
|
||||||
|
|
||||||
it { expect(show_request).to render_template(:show) }
|
it { expect(show_request).to render_template(:show) }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue