commit
c999745a7e
8 changed files with 619 additions and 759 deletions
|
@ -76,7 +76,7 @@ class Champs::CarteChamp < Champ
|
|||
type: 'FeatureCollection',
|
||||
id: stable_id,
|
||||
bbox: bounding_box,
|
||||
features: (legacy_selections_utilisateur + except_selections_utilisateur).map(&:to_feature)
|
||||
features: geo_areas.map(&:to_feature)
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -84,23 +84,6 @@ class Champs::CarteChamp < Champ
|
|||
geo_areas.present?
|
||||
end
|
||||
|
||||
def selection_utilisateur_legacy_geometry
|
||||
if selection_utilisateur_legacy?
|
||||
selections_utilisateur.first.geometry
|
||||
elsif selections_utilisateur.present?
|
||||
{
|
||||
type: 'MultiPolygon',
|
||||
coordinates: selections_utilisateur.filter do |selection_utilisateur|
|
||||
selection_utilisateur.geometry['type'] == 'Polygon'
|
||||
end.map do |selection_utilisateur|
|
||||
selection_utilisateur.geometry['coordinates']
|
||||
end
|
||||
}
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def selection_utilisateur_legacy_geo_area
|
||||
geometry = selection_utilisateur_legacy_geometry
|
||||
if geometry.present?
|
||||
|
@ -131,35 +114,18 @@ class Champs::CarteChamp < Champ
|
|||
|
||||
private
|
||||
|
||||
def selection_utilisateur_legacy?
|
||||
if selections_utilisateur.size == 1
|
||||
geometry = selections_utilisateur.first.geometry
|
||||
return geometry && geometry['type'] == 'MultiPolygon'
|
||||
end
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
def legacy_selections_utilisateur
|
||||
if selection_utilisateur_legacy?
|
||||
selections_utilisateur.first.geometry['coordinates'].map do |coordinates|
|
||||
GeoArea.new(
|
||||
geometry: {
|
||||
type: 'Polygon',
|
||||
coordinates: coordinates
|
||||
},
|
||||
properties: {},
|
||||
source: GeoArea.sources.fetch(:selection_utilisateur)
|
||||
)
|
||||
def selection_utilisateur_legacy_geometry
|
||||
if selections_utilisateur.present?
|
||||
{
|
||||
type: 'MultiPolygon',
|
||||
coordinates: selections_utilisateur.filter do |selection_utilisateur|
|
||||
selection_utilisateur.geometry['type'] == 'Polygon'
|
||||
end.map do |selection_utilisateur|
|
||||
selection_utilisateur.geometry['coordinates']
|
||||
end
|
||||
}
|
||||
else
|
||||
selections_utilisateur
|
||||
end
|
||||
end
|
||||
|
||||
def except_selections_utilisateur
|
||||
geo_areas.filter do |area|
|
||||
area.source != GeoArea.sources.fetch(:selection_utilisateur)
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -62,7 +62,14 @@
|
|||
- if @statut == 'tous'
|
||||
%p.explication-onglet Tous les dossiers qui ont été déposés sur cette démarche, quel que soit le statut.
|
||||
- if @statut == 'archives'
|
||||
%p.explication-onglet Les dossiers de cet onglet sont archivés : vous ne pouvez plus y répondre, et les demandeurs ne peuvent plus les modifier.
|
||||
%p.explication-onglet
|
||||
Les dossiers de cet onglet sont archivés : vous ne pouvez plus y répondre, et les demandeurs ne peuvent plus les modifier.
|
||||
%br
|
||||
Ces dossiers seront supprimés lorsque leur délai de conservation dans Démarches-simplifiées
|
||||
- if @procedure.duree_conservation_dossiers_dans_ds
|
||||
= "(#{@procedure.duree_conservation_dossiers_dans_ds} mois)"
|
||||
sera expiré.
|
||||
= link_to 'En savoir plus', ARCHIVAGE_DOC_URL
|
||||
.afficher-dossiers-supprimes
|
||||
= link_to deleted_dossiers_instructeur_procedure_path(@procedure) do
|
||||
%span.icon.delete
|
||||
|
|
|
@ -21,6 +21,7 @@ CGU_URL = [DOC_URL, "cgu"].join("/")
|
|||
MENTIONS_LEGALES_URL = [DOC_URL, "mentions-legales"].join("/")
|
||||
API_DOC_URL = [DOC_URL, "pour-aller-plus-loin", "api"].join("/")
|
||||
WEBHOOK_DOC_URL = [DOC_URL, "pour-aller-plus-loin", "webhook"].join("/")
|
||||
ARCHIVAGE_DOC_URL = [DOC_URL, "pour-aller-plus-loin", "archivage-longue-duree-des-demarches"].join("/")
|
||||
FAQ_URL = "https://faq.demarches-simplifiees.fr"
|
||||
FAQ_ADMIN_URL = "https://faq.demarches-simplifiees.fr/collection/1-administrateur"
|
||||
COMMENT_TROUVER_MA_DEMARCHE_URL = [FAQ_URL, "article", "59-comment-trouver-ma-demarche"].join("/")
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: split_geo_area_selection_multipolygons'
|
||||
task split_geo_area_selection_multipolygons: :environment do
|
||||
puts "Running deploy task 'split_geo_area_selection_multipolygons'"
|
||||
|
||||
Champs::CarteChamp.where.not(value: ['', '[]']).includes(:geo_areas).find_each do |champ|
|
||||
if champ.send(:selection_utilisateur_legacy?)
|
||||
legacy_selection_utilisateur = champ.selections_utilisateur.first
|
||||
champ.send(:legacy_selections_utilisateur).each do |area|
|
||||
champ.geo_areas << area
|
||||
end
|
||||
legacy_selection_utilisateur.destroy
|
||||
end
|
||||
end
|
||||
|
||||
AfterParty::TaskRecord.create version: '20200414104712'
|
||||
end
|
||||
end
|
50
package.json
50
package.json
|
@ -1,35 +1,35 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"@babel/preset-react": "^7.9.4",
|
||||
"@fortawesome/fontawesome-svg-core": "^1.2.28",
|
||||
"@fortawesome/free-solid-svg-icons": "^5.13.0",
|
||||
"@fortawesome/react-fontawesome": "^0.1.9",
|
||||
"@babel/preset-react": "^7.8.3",
|
||||
"@fortawesome/fontawesome-svg-core": "^1.2.26",
|
||||
"@fortawesome/free-solid-svg-icons": "^5.12.0",
|
||||
"@fortawesome/react-fontawesome": "^0.1.8",
|
||||
"@mapbox/mapbox-gl-draw": "^1.1.2",
|
||||
"@rails/actiontext": "^6.0.2-2",
|
||||
"@rails/activestorage": "^6.0.2-2",
|
||||
"@rails/ujs": "^6.0.2-2",
|
||||
"@rails/webpacker": "5.1.1",
|
||||
"@reach/combobox": "^0.10.1",
|
||||
"@sentry/browser": "^5.15.5",
|
||||
"@rails/actiontext": "^6.0.2-1",
|
||||
"@rails/activestorage": "^6.0.2-1",
|
||||
"@rails/ujs": "^6.0.2-1",
|
||||
"@rails/webpacker": "4.2.2",
|
||||
"@reach/combobox": "^0.10.0",
|
||||
"@sentry/browser": "^5.11.2",
|
||||
"@tmcw/togeojson": "^4.0.0",
|
||||
"@turf/area": "^6.0.1",
|
||||
"babel-plugin-macros": "^2.8.0",
|
||||
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
||||
"chartkick": "^3.2.0",
|
||||
"core-js": "^3.6.5",
|
||||
"core-js": "^3.6.4",
|
||||
"debounce": "^1.2.0",
|
||||
"dom4": "^2.1.5",
|
||||
"email-butler": "^1.0.13",
|
||||
"highcharts": "^8.0.4",
|
||||
"intersection-observer": "^0.10.0",
|
||||
"highcharts": "^8.0.0",
|
||||
"intersection-observer": "^0.7.0",
|
||||
"jquery": "^3.5.0",
|
||||
"leaflet": "^1.6.0",
|
||||
"leaflet-freedraw": "^2.12.0",
|
||||
"mapbox-gl": "^1.10.0",
|
||||
"mapbox-gl": "^1.9.0",
|
||||
"prop-types": "^15.7.2",
|
||||
"react": "^16.13.1",
|
||||
"react-dom": "^16.13.1",
|
||||
"react-intersection-observer": "^8.26.2",
|
||||
"react": "^16.12.0",
|
||||
"react-dom": "^16.12.0",
|
||||
"react-intersection-observer": "^8.25.2",
|
||||
"react-loadable": "^5.5.0",
|
||||
"react-mapbox-gl": "^4.8.3",
|
||||
"react-mapbox-gl-draw": "^2.0.4",
|
||||
|
@ -37,20 +37,20 @@
|
|||
"react-sortable-hoc": "^1.11.0",
|
||||
"react_ujs": "^2.6.1",
|
||||
"select2": "^4.0.13",
|
||||
"trix": "^1.2.3",
|
||||
"trix": "^1.2.2",
|
||||
"whatwg-fetch": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-eslint": "^10.1.0",
|
||||
"babel-eslint": "^10.0.3",
|
||||
"eclint": "^2.8.1",
|
||||
"eslint": "^6.7.2",
|
||||
"eslint-config-prettier": "^6.11.0",
|
||||
"eslint-plugin-prettier": "^3.1.3",
|
||||
"eslint-plugin-react": "^7.19.0",
|
||||
"eslint-plugin-react-hooks": "^3.0.0",
|
||||
"eslint-config-prettier": "^6.10.0",
|
||||
"eslint-plugin-prettier": "^3.1.2",
|
||||
"eslint-plugin-react": "^7.18.0",
|
||||
"eslint-plugin-react-hooks": "^2.3.0",
|
||||
"prettier": "^2.0.5",
|
||||
"webpack-bundle-analyzer": "^3.7.0",
|
||||
"webpack-dev-server": "^3.10.3"
|
||||
"webpack-bundle-analyzer": "^3.6.0",
|
||||
"webpack-dev-server": "^3.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"lint:ec": "eclint check $({ git ls-files | grep -v app/graphql/schema.graphql ; find vendor -type f ; echo 'db/schema.rb' ; } | sort | uniq -u)",
|
||||
|
|
|
@ -58,5 +58,27 @@ FactoryBot.define do
|
|||
}
|
||||
end
|
||||
end
|
||||
|
||||
trait :multi_polygon do
|
||||
geometry do
|
||||
{
|
||||
"type": "MultiPolygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
[2.428439855575562, 46.538476837725796],
|
||||
[2.4284291267395024, 46.53842148758162],
|
||||
[2.4282521009445195, 46.53841410755813],
|
||||
[2.42824137210846, 46.53847314771794],
|
||||
[2.428284287452698, 46.53847314771794],
|
||||
[2.428364753723145, 46.538487907747864],
|
||||
[2.4284291267395024, 46.538491597754714],
|
||||
[2.428439855575562, 46.538476837725796]
|
||||
]
|
||||
]
|
||||
]
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,16 +24,9 @@ describe ChampSerializer do
|
|||
end
|
||||
|
||||
context 'when type champ is carte' do
|
||||
let(:champ) { create(:champ_carte, value: value, geo_areas: [geo_area].compact) }
|
||||
let(:value) { nil }
|
||||
let(:geo_area) { create(:geo_area, :cadastre, geometry: geo_json) }
|
||||
let(:geo_json) do
|
||||
{
|
||||
"type" => 'MultiPolygon',
|
||||
"coordinates" => coordinates
|
||||
}
|
||||
end
|
||||
let(:coordinates) { [[[2.3859214782714844, 48.87442541960633], [2.3850631713867183, 48.87273183590832], [2.3809432983398438, 48.87081237174292], [2.3859214782714844, 48.87442541960633]]] }
|
||||
let(:champ) { create(:champ_carte, geo_areas: [geo_area].compact) }
|
||||
let(:geo_area) { create(:geo_area, :cadastre, :multi_polygon) }
|
||||
let(:geo_json) { attributes_for(:geo_area, :multi_polygon)[:geometry].stringify_keys }
|
||||
|
||||
let(:serialized_champ) {
|
||||
{
|
||||
|
@ -56,29 +49,7 @@ describe ChampSerializer do
|
|||
let(:serialized_value) { geo_json }
|
||||
|
||||
context 'and geo_area is selection_utilisateur' do
|
||||
let(:geo_area) { create(:geo_area, :selection_utilisateur, geometry: geo_json) }
|
||||
|
||||
context 'value is empty' do
|
||||
let(:geo_area) { nil }
|
||||
|
||||
context 'when value is nil' do
|
||||
let(:value) { nil }
|
||||
|
||||
it { expect(champ.selection_utilisateur_legacy_geo_area).to be_nil }
|
||||
end
|
||||
|
||||
context 'when value is empty array' do
|
||||
let(:value) { '[]' }
|
||||
|
||||
it { expect(champ.selection_utilisateur_legacy_geo_area).to be_nil }
|
||||
end
|
||||
|
||||
context 'when value is blank' do
|
||||
let(:value) { '' }
|
||||
|
||||
it { expect(champ.selection_utilisateur_legacy_geo_area).to be_nil }
|
||||
end
|
||||
end
|
||||
let(:geo_area) { create(:geo_area, :selection_utilisateur, :polygon) }
|
||||
|
||||
context 'old_api' do
|
||||
let(:serialized_libelle) { "user geometry" }
|
||||
|
@ -87,14 +58,6 @@ describe ChampSerializer do
|
|||
let(:serializable_object) { champ.selection_utilisateur_legacy_geo_area }
|
||||
|
||||
context 'when value is coordinates' do
|
||||
let(:value) { coordinates.to_json }
|
||||
|
||||
it { expect(subject).to eq(serialized_champ) }
|
||||
end
|
||||
|
||||
context 'when value is geojson' do
|
||||
let(:value) { geo_json.to_json }
|
||||
|
||||
it { expect(subject).to eq(serialized_champ) }
|
||||
end
|
||||
end
|
||||
|
@ -120,33 +83,6 @@ describe ChampSerializer do
|
|||
|
||||
it { expect(subject).to eq(serialized_champ) }
|
||||
end
|
||||
|
||||
context 'when value is geojson' do
|
||||
let(:value) { geo_json.to_json }
|
||||
|
||||
it { expect(subject).to eq(serialized_champ) }
|
||||
end
|
||||
|
||||
context 'when value is nil' do
|
||||
let(:value) { nil }
|
||||
let(:serialized_value) { nil }
|
||||
|
||||
it { expect(subject).to eq(serialized_champ) }
|
||||
end
|
||||
|
||||
context 'when value is empty array' do
|
||||
let(:value) { '[]' }
|
||||
let(:serialized_value) { nil }
|
||||
|
||||
it { expect(subject).to eq(serialized_champ) }
|
||||
end
|
||||
|
||||
context 'when value is blank' do
|
||||
let(:value) { '' }
|
||||
let(:serialized_value) { nil }
|
||||
|
||||
it { expect(subject).to eq(serialized_champ) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue