Move geographical zones list to a partial
This commit is contained in:
parent
c63675461a
commit
dff4f2116a
6 changed files with 47 additions and 11 deletions
|
@ -28,6 +28,28 @@ class Users::CarteController < UsersController
|
|||
redirect_to brouillon_dossier_path(dossier)
|
||||
end
|
||||
|
||||
def zones
|
||||
@dossier = current_user_dossier
|
||||
@data = {}
|
||||
|
||||
geo_json = JSON.parse(params.required(:selection))
|
||||
|
||||
if geo_json.first == ["error", "TooManyPolygons"]
|
||||
@error = true
|
||||
else
|
||||
if @dossier.procedure.module_api_carto.quartiers_prioritaires?
|
||||
quartiers_prioritaires = ModuleApiCartoService.generate_qp(geo_json).values
|
||||
@dossier.quartier_prioritaires.build(quartiers_prioritaires)
|
||||
@data[:quartiersPrioritaires] = quartiers_prioritaires
|
||||
end
|
||||
|
||||
if @dossier.procedure.module_api_carto.cadastre?
|
||||
cadastres = ModuleApiCartoService.generate_cadastre(geo_json)
|
||||
@dossier.cadastres.build(cadastres)
|
||||
@data[:cadastres] = cadastres
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.route_authorization
|
||||
{
|
||||
|
|
|
@ -2,13 +2,7 @@
|
|||
.col-md-12.col-lg-12
|
||||
#map{ class: dossier.procedure.module_api_carto.classes }
|
||||
|
||||
- if dossier.procedure.module_api_carto.quartiers_prioritaires
|
||||
.col-md-9.col-lg-9#qp.col-md-3.col-lg-3.list
|
||||
%h3.text-info Quartiers prioritaires
|
||||
%ul
|
||||
%span.zones
|
||||
= render partial: 'zones', locals: { dossier: dossier, error: @error }
|
||||
|
||||
- if dossier.procedure.module_api_carto.cadastre
|
||||
.col-md-9.col-lg-9#cadastre.col-md-3.col-lg-3.list
|
||||
%h3.text-warning Cadastres
|
||||
%ul
|
||||
= render partial: 'shared/champs/carto/init', locals: { dossier: dossier }
|
||||
|
|
19
app/views/users/carte/_zones.html.haml
Normal file
19
app/views/users/carte/_zones.html.haml
Normal file
|
@ -0,0 +1,19 @@
|
|||
- if dossier.procedure.module_api_carto.quartiers_prioritaires?
|
||||
.col-md-9.col-lg-9#qp.col-md-3.col-lg-3.list
|
||||
%h3.text-info Quartiers prioritaires
|
||||
%ul
|
||||
- dossier.quartier_prioritaires.each do |qp|
|
||||
%li #{qp.commune} : #{qp.nom}
|
||||
|
||||
- if error.present?
|
||||
%b Merci de dessiner une surface plus petite afin de récupérer les quartiers prioritaires.
|
||||
|
||||
- if dossier.procedure.module_api_carto.cadastre?
|
||||
.col-md-9.col-lg-9#cadastre.col-md-3.col-lg-3.list
|
||||
%h3.text-warning Parcelles cadastrales
|
||||
%ul
|
||||
- dossier.cadastres.each do |cadastre|
|
||||
%li Parcelle nº #{cadastre.numero} - Feuille #{cadastre.code_arr} #{cadastre.section} #{cadastre.feuille}
|
||||
|
||||
- if error.present?
|
||||
%b Merci de dessiner une surface plus petite afin de récupérer les parcelles cadastrales.
|
|
@ -20,9 +20,7 @@
|
|||
|
||||
= form_tag(url_for({ controller: :carte, action: :save, dossier_id: @dossier.id }), class: 'form-inline', method: 'POST') do
|
||||
%br
|
||||
%input#json_latlngs{ type: 'hidden', value: "#{@dossier.json_latlngs}", name: 'json_latlngs' }
|
||||
%input#quartier_prioritaires{ type: 'hidden', value: "#{@dossier.quartier_prioritaires.to_json}" }
|
||||
%input#cadastres{ type: 'hidden', value: "#{@dossier.cadastres.to_json}" }
|
||||
%input{ type: 'hidden', value: "#{@dossier.json_latlngs}", name: 'selection', data: { remote: true, url: users_dossier_carte_zones_path(@dossier), method: 'POST' } }
|
||||
|
||||
- if @dossier.brouillon?
|
||||
= render partial: '/layouts/etape_suivante'
|
||||
|
|
2
app/views/users/carte/zones.js.erb
Normal file
2
app/views/users/carte/zones.js.erb
Normal file
|
@ -0,0 +1,2 @@
|
|||
DS.cartoDrawZones(<%= raw(@data.to_json) %>);
|
||||
<%= render_to_element('.zones', partial: 'zones', locals: { dossier: @dossier, error: @error }) %>
|
|
@ -152,6 +152,7 @@ Rails.application.routes.draw do
|
|||
resources :dossiers do
|
||||
get '/add_siret' => 'dossiers/add_siret#show'
|
||||
|
||||
post '/carte/zones' => 'carte#zones'
|
||||
get '/carte' => 'carte#show'
|
||||
post '/carte' => 'carte#save'
|
||||
|
||||
|
|
Loading…
Reference in a new issue