- add bower for rails

- add "wildhoney_leaflet_freedraw" bower vendor
- remove api_carto
This commit is contained in:
Xavier J 2015-11-10 18:08:47 +01:00
parent fd9061abdf
commit eadb42af93
16 changed files with 106 additions and 56 deletions

5
.gitignore vendored
View file

@ -16,8 +16,6 @@
!/log/.keep
/tmp
# Ignore Intellij files
.idea/
*.iml
@ -28,4 +26,5 @@ bin/*
config/initializers/token.rb
doc/*.svg
rubocop.html
config/france_connect.yml
config/france_connect.yml
vendor/**/*

View file

@ -49,6 +49,8 @@ gem 'carrierwave'
gem 'pg'
gem "bower-rails", "~> 0.10.0"
gem 'rgeo-geojson'
gem 'leaflet-rails'
gem 'leaflet-markercluster-rails', '~> 0.7.0'

View file

@ -62,6 +62,7 @@ GEM
bootstrap-sass (3.3.5)
autoprefixer-rails (>= 5.0.0.1)
sass (>= 3.2.19)
bower-rails (0.10.0)
builder (3.2.2)
byebug (5.0.0)
columnize (= 0.9.0)
@ -377,6 +378,7 @@ PLATFORMS
DEPENDENCIES
bootstrap-datepicker-rails
bootstrap-sass (~> 3.3.5)
bower-rails (~> 0.10.0)
byebug
capybara
carrierwave
@ -422,3 +424,6 @@ DEPENDENCIES
unicorn
web-console (~> 2.0)
webmock
BUNDLED WITH
1.10.6

View file

@ -18,4 +18,9 @@
//= require bootstrap-sprockets
//= require bootstrap-datepicker/core
//= require bootstrap-datepicker/locales/bootstrap-datepicker.fr.js
//= require leaflet
//= require leaflet
//= require d3
//= require evispa-timo-jsclipper
//= require concavehull
//= require graham_scan
//= require wildhoney_leaflet_freedraw

View file

@ -1,10 +1,30 @@
//récupération de la position de l'entreprise
function get_position(){
function initCarto() {
OSM = L.tileLayer("http://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png", {
attribution: '&copy; Openstreetmap France | &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
});
position = get_position();
var map = L.map("map", {
center: new L.LatLng(position.lat, position.lon),
zoom: 13,
layers: [OSM]
});
freeDraw = new L.FreeDraw({
mode: L.FreeDraw.MODES.CREATE
});
map.addLayer(freeDraw);
}
function get_position() {
var position;
$.ajax({
url: '/users/dossiers/'+dossier_id+'/carte/position',
url: '/users/dossiers/' + dossier_id + '/carte/position',
dataType: 'json',
async: false
}).done(function (data) {
@ -14,7 +34,7 @@ function get_position(){
return position;
}
function get_ref_dossier (){
function get_ref_dossier() {
$.post("http://apicarto.coremaps.com/api/v1/datastore", {
contentType: "application/json",
dataType: 'json',

View file

@ -5,6 +5,19 @@
table {
font-size: 13;
}
#map.mode-create {
cursor: crosshair;
}
svg.tracer {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.info {
padding: 6px 8px;
font: 14px/16px Arial, Helvetica, sans-serif;

View file

@ -1,5 +0,0 @@
%div#sources_CSS_api_carto
%link{:href => "https://leaflet.github.io/Leaflet.draw/leaflet.draw.css", :rel => "stylesheet", :type => "text/css"}
%link{:href => "https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css", :rel => "stylesheet"}
%link{:href => "https://cdn.rawgit.com/CliffCloud/Leaflet.EasyButton/dd04bbf160aa33c44aa63e8a744b3632c162c340/src/easy-button.css", :rel => "stylesheet"}

View file

@ -1,11 +0,0 @@
%script{type: 'text/javascript'}
="var dossier_id =#{@dossier.id}"
%div#sources_JS_api_carto
%script{:src => "https://leaflet.github.io/Leaflet.draw/leaflet.draw.js"}
%script{:src => "https://cdnjs.cloudflare.com/ajax/libs/spin.js/2.0.1/spin.min.js"}
%script{:src => "https://cdn.rawgit.com/CliffCloud/Leaflet.EasyButton/14332b70b18bdec80f4cce86c643372883bf90aa/src/easy-button.bar.js"}
%script{:src => "https://cdn.rawgit.com/CliffCloud/Leaflet.EasyButton/14332b70b18bdec80f4cce86c643372883bf90aa/src/easy-button.button.js"}

View file

@ -1,12 +0,0 @@
%script{type: 'text/javascript'}
="var dossier_id =#{@dossier.id}"
="var ref_dossier=#{@dossier.ref_dossier_carto}"
%div#sources_JS_api_carto_backend
%script{:src => "https://leaflet.github.io/Leaflet.draw/leaflet.draw.js"}
%script{:src => "https://cdnjs.cloudflare.com/ajax/libs/spin.js/2.0.1/spin.min.js"}
%script{:src => "https://cdn.rawgit.com/CliffCloud/Leaflet.EasyButton/14332b70b18bdec80f4cce86c643372883bf90aa/src/easy-button.bar.js"}
%script{:src => "https://cdn.rawgit.com/CliffCloud/Leaflet.EasyButton/14332b70b18bdec80f4cce86c643372883bf90aa/src/easy-button.button.js"}

View file

@ -2,18 +2,26 @@
='Localisation de votre demande'
%br
=render partial: 'carte_sources_CSS'
.content{style:'margin-bottom:60px'}
%button.btn.btn-sm.btn-success{type:'button', disabled: 'disabled'} Nouveau
\-
%button.btn.btn-sm.btn-info{type:'button', disabled: 'disabled'} Editer
\-
%button.btn.btn-sm.btn-danger{type:'button', disabled: 'disabled'} Supprimer
.content
#map_qp{style: 'height:600px; width: 100%;'}
= form_tag(url_for({controller: :carte, action: :save_ref_api_carto, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
%br
%input{type: 'hidden', value: '', name: 'ref_dossier', id: 'ref_dossier'}
%br
#map{style: 'height:600px; width: 100%;'}
-if @dossier.draft?
=render partial: '/layouts/etape_suivante'
-else
=render partial: '/layouts/modifications_terminees'
= form_tag(url_for({controller: :carte, action: :save_ref_api_carto, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do
%br
%input{type: 'hidden', value: '', name: 'ref_dossier', id: 'ref_dossier'}
=render partial: 'carte_sources_JS'
-if @dossier.draft?
=render partial: '/layouts/etape_suivante'
-else
=render partial: '/layouts/modifications_terminees'
%script{type: 'text/javascript'}
="var dossier_id =#{@dossier.id}"
initCarto();

15
bower.json Normal file
View file

@ -0,0 +1,15 @@
{
"lib": {
"name": "bower-rails generated lib assets",
"dependencies": {
// "threex" : "git@github.com:rharriso/threex.git",
// "gsvpano.js" : "https://github.com/rharriso/GSVPano.js/blob/master/src/GSVPano.js"
}
},
"vendor": {
"name": "bower-rails generated vendor assets",
"dependencies": {
"wildhoney_leaflet_freedraw": "https://github.com/Wildhoney/Leaflet.FreeDraw.git"
}
}
}

View file

@ -0,0 +1,19 @@
BowerRails.configure do |bower_rails|
# Tell bower-rails what path should be considered as root. Defaults to Dir.pwd
bower_rails.root_path = '/app/'
# Invokes rake bower:install before precompilation. Defaults to false
bower_rails.install_before_precompile = true
# Invokes rake bower:resolve before precompilation. Defaults to false
bower_rails.resolve_before_precompile = true
# Invokes rake bower:clean before precompilation. Defaults to false
bower_rails.clean_before_precompile = true
# Invokes rake bower:install:deployment instead rake bower:install. Defaults to false
bower_rails.use_bower_install_deployment = true
#
# Invokes rake bower:install and rake bower:install:deployment with -F (force) flag. Defaults to false
bower_rails.force_install = true
end

View file

View file

@ -16,17 +16,9 @@ describe 'users/carte/show.html.haml', type: :view do
it 'le formulaire envoie vers /users/dossiers/:dossier_id/carte en #POST' do
expect(rendered).to have_selector("form[action='/users/dossiers/#{dossier_id}/carte'][method=post]")
end
it 'la page des sources CSS de l\'API carto est chargée' do
expect(rendered).to have_selector('#sources_CSS_api_carto')
end
it 'la page des sources JS de l\'API carto est chargée' do
expect(rendered).to have_selector('#sources_JS_api_carto')
end
it 'la carte est bien présente' do
expect(rendered).to have_selector('#map_qp')
expect(rendered).to have_selector('#map')
end
context 'présence des inputs hidden' do

View file

View file