add api_carto on back office and recapitulative page
This commit is contained in:
parent
ce6af625d2
commit
61b126b0f9
8 changed files with 74 additions and 27 deletions
|
@ -3,41 +3,52 @@ function initCarto() {
|
||||||
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
||||||
});
|
});
|
||||||
|
|
||||||
position = get_position();
|
var LON = '2.428462';
|
||||||
|
var LAT = '46.538192';
|
||||||
|
|
||||||
|
position = get_position() || {lon: LON, lat: LAT, zoom: 13};
|
||||||
|
|
||||||
|
if (typeof position.zoom == 'undefined')
|
||||||
|
position.zoom = 13;
|
||||||
|
|
||||||
var map = L.map("map", {
|
var map = L.map("map", {
|
||||||
center: new L.LatLng(position.lat, position.lon),
|
center: new L.LatLng(position.lat, position.lon),
|
||||||
zoom: 13,
|
zoom: position.zoom,
|
||||||
layers: [OSM]
|
layers: [OSM]
|
||||||
});
|
});
|
||||||
|
|
||||||
var freeDraw = new L.FreeDraw({
|
var freeDraw = new L.FreeDraw({
|
||||||
mode: L.FreeDraw.MODES.CREATE
|
//mode: L.FreeDraw.MODES.CREATE
|
||||||
});
|
});
|
||||||
|
|
||||||
map.addLayer(freeDraw);
|
map.addLayer(freeDraw);
|
||||||
|
|
||||||
$.each($.parseJSON($("#json_latlngs").val()), function(i, val){
|
if ($("#json_latlngs").val() != '' && $("#json_latlngs").val() != '[]') {
|
||||||
freeDraw.createPolygon(val);
|
$.each($.parseJSON($("#json_latlngs").val()), function (i, val) {
|
||||||
});
|
freeDraw.createPolygon(val);
|
||||||
|
});
|
||||||
|
map.setView(freeDraw.polygons[0].getBounds().getCenter(), position.zoom);
|
||||||
|
}
|
||||||
|
else if (position.lat == LAT && position.lon == LON)
|
||||||
|
map.setView(new L.LatLng(position.lat, position.lon), 5);
|
||||||
|
|
||||||
add_event_freeDraw(freeDraw);
|
add_event_freeDraw(freeDraw);
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_event_freeDraw(freeDraw){
|
function add_event_freeDraw(freeDraw) {
|
||||||
freeDraw.on('markers', function (e){
|
freeDraw.on('markers', function (e) {
|
||||||
$("#json_latlngs").val(JSON.stringify(e.latLngs));
|
$("#json_latlngs").val(JSON.stringify(e.latLngs));
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#new").on('click', function (e){
|
$("#new").on('click', function (e) {
|
||||||
freeDraw.setMode(L.FreeDraw.MODES.CREATE);
|
freeDraw.setMode(L.FreeDraw.MODES.CREATE);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#edit").on('click', function (e){
|
$("#edit").on('click', function (e) {
|
||||||
freeDraw.setMode(L.FreeDraw.MODES.EDIT);
|
freeDraw.setMode(L.FreeDraw.MODES.EDIT);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#delete").on('click', function (e){
|
$("#delete").on('click', function (e) {
|
||||||
freeDraw.setMode(L.FreeDraw.MODES.DELETE);
|
freeDraw.setMode(L.FreeDraw.MODES.DELETE);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,14 @@ table {
|
||||||
font-size: 13;
|
font-size: 13;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#map{
|
||||||
|
height:600px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#map.mini{
|
||||||
|
height:300px;
|
||||||
|
}
|
||||||
|
|
||||||
#map section.overlay {
|
#map section.overlay {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
|
@ -8,6 +8,7 @@ class Users::CarteController < UsersController
|
||||||
redirect_to url_for(root_path)
|
redirect_to url_for(root_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#TODO change name funtion
|
||||||
def save_ref_api_carto
|
def save_ref_api_carto
|
||||||
dossier = current_user_dossier
|
dossier = current_user_dossier
|
||||||
dossier.update_attributes(json_latlngs: params[:json_latlngs])
|
dossier.update_attributes(json_latlngs: params[:json_latlngs])
|
||||||
|
|
|
@ -13,23 +13,36 @@
|
||||||
%br
|
%br
|
||||||
- rescue
|
- rescue
|
||||||
=''
|
=''
|
||||||
.col-lg-6.col-md-6
|
- if @dossier.procedure.use_api_carto
|
||||||
=render partial: '/dossiers/pieces_justificatives'
|
.col-lg-6.col-md-6
|
||||||
|
#map.mini
|
||||||
|
%input{id: 'json_latlngs', type:'hidden', value: "#{@dossier.json_latlngs}"}
|
||||||
|
%script{type: 'text/javascript'}
|
||||||
|
= "var dossier_id =#{@dossier.id}"
|
||||||
|
initCarto();
|
||||||
|
|
||||||
%br
|
%br
|
||||||
-unless @champs.nil?
|
-unless @champs.nil?
|
||||||
%table.table#liste_champs
|
.row
|
||||||
-@champs.each do |champ|
|
.col-lg-6.col-md-6
|
||||||
%tr
|
%table.table#liste_champs
|
||||||
%th{ style: 'width:25%' }
|
-@champs.each do |champ|
|
||||||
=champ.libelle
|
%tr
|
||||||
%td
|
%th{ style: 'width:25%' }
|
||||||
=champ.value
|
=champ.libelle
|
||||||
|
%td
|
||||||
|
=champ.value
|
||||||
|
.col-lg-6.col-md-6
|
||||||
|
=render partial: '/dossiers/pieces_justificatives'
|
||||||
|
%br
|
||||||
|
|
||||||
%div.row{style: 'text-align:right'}
|
%div.row{style: 'text-align:right'}
|
||||||
-unless gestionnaire_signed_in?
|
-unless gestionnaire_signed_in?
|
||||||
-if !@dossier.validated? && !@dossier.submitted? && !@dossier.closed?
|
-if !@dossier.validated? && !@dossier.submitted? && !@dossier.closed?
|
||||||
%a#maj_infos.btn.btn-info{href: "/users/dossiers/#{@dossier.id}/description?back_url=recapitulatif"}
|
-if @dossier.procedure.use_api_carto
|
||||||
|
%a#maj_carte.btn.btn-primary{href: "/users/dossiers/#{@dossier.id}/carte"}
|
||||||
|
= 'Editer ma carte'
|
||||||
|
%a#maj_infos.btn.btn-info{href: "/users/dossiers/#{@dossier.id}/description"}
|
||||||
= 'Editer mon dossier'
|
= 'Editer mon dossier'
|
||||||
|
|
||||||
-unless user_signed_in?
|
-unless user_signed_in?
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pieces_justificatives
|
#pieces_justificatives
|
||||||
%h3.text-info Liste des pièces justificatives
|
-#%h3.text-info Liste des pièces justificatives
|
||||||
%br
|
-#%br
|
||||||
%table.table
|
%table.table
|
||||||
-if @procedure.lien_demarche != nil
|
-if @procedure.lien_demarche != nil
|
||||||
%tr{id: "piece_justificative_0"}
|
%tr{id: "piece_justificative_0"}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
%div#commentaire_new{style: 'width:80%; margin-left:auto; margin-right:auto'}
|
%div#commentaire_new{style: 'width:80%; margin-left:auto; margin-right:auto'}
|
||||||
= form_tag(url_for({ controller: :commentaires, action: :create, dossier_id: @dossier.id }), class: 'form-inline', method: 'POST') do
|
= form_tag(url_for({ controller: :commentaires, action: :create, dossier_id: @dossier.id }), class: 'form-inline', method: 'POST') do
|
||||||
%textarea.form-control{id: 'texte_commentaire', name: 'texte_commentaire', style: 'width: 100%; margin-bottom:2%', rows: '5', maxlength: '255', placeholder:"Dialoguer avec votre interlocuteur privilégié en charge de votre dossier."}
|
%textarea.form-control{id: 'texte_commentaire', name: 'texte_commentaire', style: 'width: 100%; margin-bottom:2%', rows: '5', maxlength: '255', placeholder:"Dialoguer avec votre interlocuteur privilégié en charge de votre dossier."}
|
||||||
%input.form-control.btn.btn-primary{:type => 'submit', :value => 'Poster', style: 'float:right'}
|
%input.form-control.btn.btn-success{:type => 'submit', :value => 'Poster', style: 'float:right'}
|
||||||
%br
|
%br
|
||||||
%br
|
%br
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,10 @@ FactoryGirl.define do
|
||||||
libelle 'Demande de subvention'
|
libelle 'Demande de subvention'
|
||||||
description "Demande de subvention à l'intention des associations"
|
description "Demande de subvention à l'intention des associations"
|
||||||
|
|
||||||
|
trait :with_api_carto do
|
||||||
|
use_api_carto true
|
||||||
|
end
|
||||||
|
|
||||||
trait :with_type_de_champ do
|
trait :with_type_de_champ do
|
||||||
after(:build) do |procedure, _evaluator|
|
after(:build) do |procedure, _evaluator|
|
||||||
type_de_champ = create(:type_de_champ)
|
type_de_champ = create(:type_de_champ)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'users/recapitulatif/show.html.haml', type: :view do
|
describe 'users/recapitulatif/show.html.haml', type: :view do
|
||||||
let(:dossier) { create(:dossier, :with_user, :with_entreprise, :with_procedure) }
|
let(:dossier) { create(:dossier, :with_user, :with_entreprise, procedure: create(:procedure, :with_api_carto)) }
|
||||||
let(:dossier_id) { dossier.id }
|
let(:dossier_id) { dossier.id }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -36,7 +36,17 @@ describe 'users/recapitulatif/show.html.haml', type: :view do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'le lien vers description est correct' do
|
it 'le lien vers description est correct' do
|
||||||
expect(rendered).to have_selector("a[id=maj_infos][href='/users/dossiers/#{dossier_id}/description?back_url=recapitulatif']")
|
expect(rendered).to have_selector("a[id=maj_infos][href='/users/dossiers/#{dossier_id}/description']")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'lien carte' do
|
||||||
|
it 'le lien vers carte est présent' do
|
||||||
|
expect(rendered).to have_css('#maj_carte')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'le lien vers description est correct' do
|
||||||
|
expect(rendered).to have_selector("a[id=maj_carte][href='/users/dossiers/#{dossier_id}/carte']")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue