diff --git a/.gitignore b/.gitignore index 303c6304d..25c5ca18f 100644 --- a/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file +config/france_connect.yml +vendor/**/* \ No newline at end of file diff --git a/Gemfile b/Gemfile index 2be2cc7d8..3b1620b29 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index 25e3f8612..78f51424f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 7242859cf..111a9a582 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -18,4 +18,9 @@ //= require bootstrap-sprockets //= require bootstrap-datepicker/core //= require bootstrap-datepicker/locales/bootstrap-datepicker.fr.js -//= require leaflet \ No newline at end of file +//= require leaflet +//= require d3 +//= require evispa-timo-jsclipper +//= require concavehull +//= require graham_scan +//= require wildhoney_leaflet_freedraw diff --git a/app/assets/javascripts/carte.js b/app/assets/javascripts/carte.js index 0a4c0582c..dca22b3a1 100644 --- a/app/assets/javascripts/carte.js +++ b/app/assets/javascripts/carte.js @@ -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: '© Openstreetmap France | © OpenStreetMap' + }); + + 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', diff --git a/app/assets/stylesheets/carte.scss b/app/assets/stylesheets/carte.scss index 3a40513fa..4e0251c10 100644 --- a/app/assets/stylesheets/carte.scss +++ b/app/assets/stylesheets/carte.scss @@ -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; diff --git a/app/views/users/carte/_carte_sources_CSS.html.haml b/app/views/users/carte/_carte_sources_CSS.html.haml deleted file mode 100644 index 2682e2f1e..000000000 --- a/app/views/users/carte/_carte_sources_CSS.html.haml +++ /dev/null @@ -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"} diff --git a/app/views/users/carte/_carte_sources_JS.html.haml b/app/views/users/carte/_carte_sources_JS.html.haml deleted file mode 100644 index 9c3f3df71..000000000 --- a/app/views/users/carte/_carte_sources_JS.html.haml +++ /dev/null @@ -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"} - - diff --git a/app/views/users/carte/_carte_sources_JS_backend.html.haml b/app/views/users/carte/_carte_sources_JS_backend.html.haml deleted file mode 100644 index cc0f8ce38..000000000 --- a/app/views/users/carte/_carte_sources_JS_backend.html.haml +++ /dev/null @@ -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"} - - diff --git a/app/views/users/carte/show.html.haml b/app/views/users/carte/show.html.haml index d58cb94e5..a77c016ff 100644 --- a/app/views/users/carte/show.html.haml +++ b/app/views/users/carte/show.html.haml @@ -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' \ No newline at end of file + -if @dossier.draft? + =render partial: '/layouts/etape_suivante' + -else + =render partial: '/layouts/modifications_terminees' + +%script{type: 'text/javascript'} + ="var dossier_id =#{@dossier.id}" + initCarto(); \ No newline at end of file diff --git a/bower.json b/bower.json new file mode 100644 index 000000000..d3aa99bde --- /dev/null +++ b/bower.json @@ -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" + } + } +} \ No newline at end of file diff --git a/config/initializers/bower_rails.rb b/config/initializers/bower_rails.rb new file mode 100644 index 000000000..fbc7e532f --- /dev/null +++ b/config/initializers/bower_rails.rb @@ -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 diff --git a/lib/assets/.keep b/lib/assets/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/spec/views/users/carte/show.html.haml_spec.rb b/spec/views/users/carte/show.html.haml_spec.rb index 7d10bc568..d4df8349d 100644 --- a/spec/views/users/carte/show.html.haml_spec.rb +++ b/spec/views/users/carte/show.html.haml_spec.rb @@ -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 diff --git a/vendor/assets/javascripts/.keep b/vendor/assets/javascripts/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/vendor/assets/stylesheets/.keep b/vendor/assets/stylesheets/.keep deleted file mode 100644 index e69de29bb..000000000