Merge pull request #3109 from tchak/selection-utilisateur-size
Expose selection utilisateur size on champ carte
This commit is contained in:
commit
826448d7cc
3 changed files with 45 additions and 3 deletions
|
@ -62,6 +62,14 @@ class Champs::CarteChamp < Champ
|
|||
end
|
||||
end
|
||||
|
||||
def selection_utilisateur_size
|
||||
if geo_json.present?
|
||||
geo_json['coordinates'].size
|
||||
else
|
||||
0
|
||||
end
|
||||
end
|
||||
|
||||
def to_render_data
|
||||
{
|
||||
position: position,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
- elsif champ.value.blank?
|
||||
Aucune zone tracée
|
||||
- elsif champ.quartiers_prioritaires.blank?
|
||||
= t('errors.messages.quartiers_prioritaires_empty', count: champ.geo_json.size)
|
||||
= t('errors.messages.quartiers_prioritaires_empty', count: champ.selection_utilisateur_size)
|
||||
- else
|
||||
%ul
|
||||
- champ.quartiers_prioritaires.each do |qp|
|
||||
|
@ -20,7 +20,7 @@
|
|||
- elsif champ.value.blank?
|
||||
Aucune zone tracée
|
||||
- elsif champ.cadastres.blank?
|
||||
= t('errors.messages.cadastres_empty', count: champ.geo_json.size)
|
||||
= t('errors.messages.cadastres_empty', count: champ.selection_utilisateur_size)
|
||||
- else
|
||||
%ul
|
||||
- champ.cadastres.each do |pc|
|
||||
|
@ -34,7 +34,7 @@
|
|||
- elsif champ.value.blank?
|
||||
Aucune zone tracée
|
||||
- elsif champ.parcelles_agricoles.blank?
|
||||
= t('errors.messages.parcelles_agricoles_empty', count: champ.geo_json.size)
|
||||
= t('errors.messages.parcelles_agricoles_empty', count: champ.selection_utilisateur_size)
|
||||
- else
|
||||
%ul
|
||||
- champ.parcelles_agricoles.each do |pa|
|
||||
|
|
|
@ -60,4 +60,38 @@ describe Champs::CarteChamp do
|
|||
it { is_expected.to eq(render_data) }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#selection_utilisateur_size' do
|
||||
subject { champ.selection_utilisateur_size }
|
||||
|
||||
context 'when the value is nil' do
|
||||
let(:value) { nil }
|
||||
|
||||
it { is_expected.to eq(0) }
|
||||
end
|
||||
|
||||
context 'when the value is blank' do
|
||||
let(:value) { '' }
|
||||
|
||||
it { is_expected.to eq(0) }
|
||||
end
|
||||
|
||||
context 'when the value is empty array' do
|
||||
let(:value) { '[]' }
|
||||
|
||||
it { is_expected.to eq(0) }
|
||||
end
|
||||
|
||||
context 'when the value is coordinates' do
|
||||
let(:value) { coordinates.to_json }
|
||||
|
||||
it { is_expected.to eq(1) }
|
||||
end
|
||||
|
||||
context 'when the value is geojson' do
|
||||
let(:value) { geo_json }
|
||||
|
||||
it { is_expected.to eq(1) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue