Improuve champ blank check

This commit is contained in:
Paul Chavard 2021-07-21 10:45:59 +02:00
parent 38b73f0fee
commit ac0f50b488
6 changed files with 39 additions and 18 deletions

View file

@ -95,14 +95,7 @@ class Champ < ApplicationRecord
end
def blank?
case type_de_champ.type_champ
when TypeDeChamp.type_champs.fetch(:carte)
geo_areas.blank? || value == '[]'
when TypeDeChamp.type_champs.fetch(:multiple_drop_down_list)
value.blank? || value == '[]'
else
value.blank?
end
value.blank?
end
def search_terms

View file

@ -109,6 +109,10 @@ class Champs::CarteChamp < Champ
nil
end
def blank?
geo_areas.blank?
end
private
def selection_utilisateur_legacy_geometry

View file

@ -62,6 +62,10 @@ class Champs::MultipleDropDownListChamp < Champ
enabled_non_empty_options.size <= THRESHOLD_NB_OPTIONS_AS_CHECKBOX
end
def blank?
selected_options.blank?
end
private
def format_before_save

View file

@ -30,8 +30,8 @@ class Champs::RepetitionChamp < Champ
end
end
def mandatory_and_blank?
mandatory? && champs.empty?
def blank?
champs.empty?
end
def search_terms