diff --git a/app/graphql/api/v2/schema.rb b/app/graphql/api/v2/schema.rb index 470be61df..fe527c03c 100644 --- a/app/graphql/api/v2/schema.rb +++ b/app/graphql/api/v2/schema.rb @@ -51,7 +51,6 @@ class Api::V2::Schema < GraphQL::Schema Types::Champs::SiretChampType, Types::Champs::TextChampType, Types::GeoAreas::ParcelleCadastraleType, - Types::GeoAreas::QuartierPrioritaireType, Types::GeoAreas::SelectionUtilisateurType, Types::PersonneMoraleType, Types::PersonnePhysiqueType diff --git a/app/graphql/schema.graphql b/app/graphql/schema.graphql index 698bb9ba7..0fe8b1878 100644 --- a/app/graphql/schema.graphql +++ b/app/graphql/schema.graphql @@ -809,11 +809,6 @@ enum GeoAreaSource { """ cadastre - """ - Quartier prioritaire - """ - quartier_prioritaire - """ Sélection utilisateur """ @@ -1101,15 +1096,6 @@ type Profile { id: ID! } -type QuartierPrioritaire implements GeoArea { - code: String! - commune: String! - geometry: GeoJSON! - id: ID! - nom: String! - source: GeoAreaSource! -} - type Query { """ Informations concernant une démarche. diff --git a/app/graphql/types/geo_area_type.rb b/app/graphql/types/geo_area_type.rb index 090fd5778..9a824b031 100644 --- a/app/graphql/types/geo_area_type.rb +++ b/app/graphql/types/geo_area_type.rb @@ -4,11 +4,9 @@ module Types class GeoAreaSource < Types::BaseEnum GeoArea.sources.each do |symbol_name, string_name| - if string_name != "parcelle_agricole" - value(string_name, - I18n.t(symbol_name, scope: [:activerecord, :attributes, :geo_area, :source]), - value: symbol_name) - end + value(string_name, + I18n.t(symbol_name, scope: [:activerecord, :attributes, :geo_area, :source]), + value: symbol_name) end end @@ -21,8 +19,6 @@ module Types case object.source when GeoArea.sources.fetch(:cadastre) Types::GeoAreas::ParcelleCadastraleType - when GeoArea.sources.fetch(:quartier_prioritaire) - Types::GeoAreas::QuartierPrioritaireType when GeoArea.sources.fetch(:selection_utilisateur) Types::GeoAreas::SelectionUtilisateurType end diff --git a/app/graphql/types/geo_areas/quartier_prioritaire_type.rb b/app/graphql/types/geo_areas/quartier_prioritaire_type.rb deleted file mode 100644 index 682ea7319..000000000 --- a/app/graphql/types/geo_areas/quartier_prioritaire_type.rb +++ /dev/null @@ -1,9 +0,0 @@ -module Types::GeoAreas - class QuartierPrioritaireType < Types::BaseObject - implements Types::GeoAreaType - - field :code, String, null: false - field :nom, String, null: false - field :commune, String, null: false - end -end diff --git a/app/helpers/champ_helper.rb b/app/helpers/champ_helper.rb index 41dcf4162..42b8d9310 100644 --- a/app/helpers/champ_helper.rb +++ b/app/helpers/champ_helper.rb @@ -39,10 +39,6 @@ module ChampHelper concat "Parcelle n° #{geo_area.numero} - Feuille #{geo_area.code_arr} #{geo_area.section} #{geo_area.feuille} - #{geo_area.surface_parcelle.round} m" concat tag.sup("2") end - when GeoArea.sources.fetch(:quartier_prioritaire) - "#{geo_area.commune} : #{geo_area.nom}" - when GeoArea.sources.fetch(:parcelle_agricole) - "Culture : #{geo_area.culture} - Surface : #{geo_area.surface} ha" when GeoArea.sources.fetch(:selection_utilisateur) if geo_area.polygon? if geo_area.area.present? diff --git a/app/models/champs/carte_champ.rb b/app/models/champs/carte_champ.rb index b12c85f3a..d4cccbe48 100644 --- a/app/models/champs/carte_champ.rb +++ b/app/models/champs/carte_champ.rb @@ -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? diff --git a/app/models/geo_area.rb b/app/models/geo_area.rb index b08faae7b..c43bc5b90 100644 --- a/app/models/geo_area.rb +++ b/app/models/geo_area.rb @@ -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 { diff --git a/app/models/type_de_champ.rb b/app/models/type_de_champ.rb index 50f4e576a..3a8e88f14 100644 --- a/app/models/type_de_champ.rb +++ b/app/models/type_de_champ.rb @@ -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 diff --git a/app/serializers/geo_area_serializer.rb b/app/serializers/geo_area_serializer.rb index ae00a8e48..f0ff85ccb 100644 --- a/app/serializers/geo_area_serializer.rb +++ b/app/serializers/geo_area_serializer.rb @@ -11,15 +11,6 @@ class GeoAreaSerializer < ActiveModel::Serializer attribute :code_com, if: :include_cadastre? attribute :code_arr, if: :include_cadastre? - attribute :code, if: :include_quartier_prioritaire? - attribute :nom, if: :include_quartier_prioritaire? - attribute :commune, if: :include_quartier_prioritaire? - - attribute :culture, if: :include_parcelle_agricole? - attribute :code_culture, if: :include_parcelle_agricole? - attribute :surface, if: :include_parcelle_agricole? - attribute :bio, if: :include_parcelle_agricole? - def geometry object.safe_geometry end @@ -27,12 +18,4 @@ class GeoAreaSerializer < ActiveModel::Serializer def include_cadastre? object.source == GeoArea.sources.fetch(:cadastre) end - - def include_quartier_prioritaire? - object.source == GeoArea.sources.fetch(:quartier_prioritaire) - end - - def include_parcelle_agricole? - object.source == GeoArea.sources.fetch(:parcelle_agricole) - end end diff --git a/app/serializers/module_api_carto_serializer.rb b/app/serializers/module_api_carto_serializer.rb index 0c993848d..b79abfba8 100644 --- a/app/serializers/module_api_carto_serializer.rb +++ b/app/serializers/module_api_carto_serializer.rb @@ -1,5 +1,3 @@ class ModuleApiCartoSerializer < ActiveModel::Serializer - attributes :use_api_carto, - :quartiers_prioritaires, - :cadastre + attributes :use_api_carto, :cadastre end