Remove legacy geo sources
This commit is contained in:
parent
5abb07420b
commit
cad8ee31d8
10 changed files with 10 additions and 81 deletions
|
@ -27,34 +27,18 @@ class Champs::CarteChamp < Champ
|
|||
end
|
||||
end
|
||||
|
||||
def quartiers_prioritaires
|
||||
geo_areas.filter do |area|
|
||||
area.source == GeoArea.sources.fetch(:quartier_prioritaire)
|
||||
end
|
||||
end
|
||||
|
||||
def parcelles_agricoles
|
||||
geo_areas.filter do |area|
|
||||
area.source == GeoArea.sources.fetch(:parcelle_agricole)
|
||||
end
|
||||
end
|
||||
|
||||
def selections_utilisateur
|
||||
geo_areas.filter do |area|
|
||||
area.source == GeoArea.sources.fetch(:selection_utilisateur)
|
||||
end
|
||||
end
|
||||
|
||||
def layer_enabled?(layer)
|
||||
type_de_champ.options[layer] && type_de_champ.options[layer] != '0'
|
||||
end
|
||||
|
||||
def cadastres?
|
||||
type_de_champ&.cadastres && type_de_champ.cadastres != '0'
|
||||
end
|
||||
|
||||
def quartiers_prioritaires?
|
||||
type_de_champ&.quartiers_prioritaires && type_de_champ.quartiers_prioritaires != '0'
|
||||
end
|
||||
|
||||
def parcelles_agricoles?
|
||||
type_de_champ&.parcelles_agricoles && type_de_champ.parcelles_agricoles != '0'
|
||||
layer_enabled?(:cadastres)
|
||||
end
|
||||
|
||||
def mnhn?
|
||||
|
|
|
@ -35,16 +35,12 @@ class GeoArea < ApplicationRecord
|
|||
]
|
||||
|
||||
enum source: {
|
||||
quartier_prioritaire: 'quartier_prioritaire',
|
||||
cadastre: 'cadastre',
|
||||
parcelle_agricole: 'parcelle_agricole',
|
||||
selection_utilisateur: 'selection_utilisateur'
|
||||
}
|
||||
|
||||
scope :selections_utilisateur, -> { where(source: sources.fetch(:selection_utilisateur)) }
|
||||
scope :quartiers_prioritaires, -> { where(source: sources.fetch(:quartier_prioritaire)) }
|
||||
scope :cadastres, -> { where(source: sources.fetch(:cadastre)) }
|
||||
scope :parcelles_agricoles, -> { where(source: sources.fetch(:parcelle_agricole)) }
|
||||
|
||||
def to_feature
|
||||
{
|
||||
|
|
|
@ -56,7 +56,7 @@ class TypeDeChamp < ApplicationRecord
|
|||
belongs_to :parent, class_name: 'TypeDeChamp', optional: true
|
||||
has_many :types_de_champ, -> { ordered }, foreign_key: :parent_id, class_name: 'TypeDeChamp', inverse_of: :parent, dependent: :destroy
|
||||
|
||||
store_accessor :options, :cadastres, :quartiers_prioritaires, :parcelles_agricoles, :mnhn, :old_pj, :drop_down_options, :skip_pj_validation
|
||||
store_accessor :options, :cadastres, :mnhn, :old_pj, :drop_down_options, :skip_pj_validation
|
||||
has_many :revision_types_de_champ, class_name: 'ProcedureRevisionTypeDeChamp', dependent: :destroy, inverse_of: :type_de_champ
|
||||
has_many :revisions, through: :revision_types_de_champ
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue