From e258118825aa9e7e104f3efc85295a3fdf7b9b1d Mon Sep 17 00:00:00 2001 From: Xavier J Date: Tue, 20 Dec 2016 14:48:09 +0100 Subject: [PATCH] Reactive cartographie --- app/assets/stylesheets/dossier_show.scss | 8 +++ app/views/dossiers/_dossier_show.html.haml | 27 +++++---- app/views/dossiers/_edit_carto.html.haml | 4 +- app/views/users/carte/_init_carto.html.haml | 4 ++ app/views/users/carte/_map.html.haml | 13 +++++ app/views/users/carte/show.html.haml | 20 +------ .../_commentaires_flux.html.haml | 19 ------- spec/features/admin/procedure_locked_spec.rb | 41 -------------- .../recapitulatif/_commentaires_flux_spec.rb | 56 ------------------- .../recapitulatif/show.html.haml_spec.rb | 3 - 10 files changed, 45 insertions(+), 150 deletions(-) create mode 100644 app/views/users/carte/_init_carto.html.haml create mode 100644 app/views/users/carte/_map.html.haml delete mode 100644 app/views/users/recapitulatif/_commentaires_flux.html.haml delete mode 100644 spec/views/users/recapitulatif/_commentaires_flux_spec.rb diff --git a/app/assets/stylesheets/dossier_show.scss b/app/assets/stylesheets/dossier_show.scss index 01fc543be..54d6e14b4 100644 --- a/app/assets/stylesheets/dossier_show.scss +++ b/app/assets/stylesheets/dossier_show.scss @@ -106,6 +106,14 @@ color: #000000; } } + + #carto { + #map { + margin-bottom: 20px; + height: 350px; + } + } + #dossier, #pieces-jointes, .infos, #carto, #private-fields { .body { padding: 20px 20px 0 20px; diff --git a/app/views/dossiers/_dossier_show.html.haml b/app/views/dossiers/_dossier_show.html.haml index 33849b60a..2a0abded1 100644 --- a/app/views/dossiers/_dossier_show.html.haml +++ b/app/views/dossiers/_dossier_show.html.haml @@ -83,17 +83,22 @@ = render partial: '/dossiers/infos_dossier' - if @facade.dossier.procedure.module_api_carto.use_api_carto - - if false - .default_data_block - %div.row.show-block#carto - %div.header - %div.col-lg-10.col-md-10.title - %div.carret-right - %div.carret-down - CARTOGRAPHIE - = render partial: '/dossiers/edit_carto' - %div.body - = render partial: '/dossiers/infos_carto' + .default_data_block.default_visible + %div.row.show-block#carto + %div.header + %div.col-lg-10.col-md-10.title + %div.carret-right + %div.carret-down + CARTOGRAPHIE + = render partial: '/dossiers/edit_carto' + %div.body + %input{id: 'json_latlngs', type: 'hidden', value: "#{@facade.dossier.json_latlngs}", name: 'json_latlngs'} + %input{id: 'quartier_prioritaires', type: 'hidden', value: "#{@facade.dossier.quartier_prioritaires.to_json}"} + %input{id: 'cadastres', type: 'hidden', value: "#{@facade.dossier.cadastres.to_json}"} + + = render partial: '/users/carte/map', locals: {dossier: @facade.dossier} + = render partial: 'users/carte/init_carto', locals: {dossier: @facade.dossier} + - if @current_gestionnaire && gestionnaire_signed_in? && @champs.count > 0 .default_data_block diff --git a/app/views/dossiers/_edit_carto.html.haml b/app/views/dossiers/_edit_carto.html.haml index 64156728b..c038b143b 100644 --- a/app/views/dossiers/_edit_carto.html.haml +++ b/app/views/dossiers/_edit_carto.html.haml @@ -1,5 +1,5 @@ - unless @facade.dossier.read_only? - if user_signed_in? && (@facade.dossier.owner?(current_user.email) || @facade.dossier.invite_by_user?(current_user.email)) - %div.col-lg-2.col-md-2.action - %a#maj_carte.action{href: "/users/dossiers/#{@facade.dossier.id}/carte"} + %a#maj_carte.action{href: "/users/dossiers/#{@facade.dossier.id}/carte"} + %div.col-lg-2.col-md-2.action = 'éditer'.upcase diff --git a/app/views/users/carte/_init_carto.html.haml b/app/views/users/carte/_init_carto.html.haml new file mode 100644 index 000000000..fdb2f12cc --- /dev/null +++ b/app/views/users/carte/_init_carto.html.haml @@ -0,0 +1,4 @@ +%script{type: 'text/javascript'} + ="var dossier_id =#{dossier.id}" + $(document).on('page:load', initCarto); + $(document).ready(initCarto); \ No newline at end of file diff --git a/app/views/users/carte/_map.html.haml b/app/views/users/carte/_map.html.haml new file mode 100644 index 000000000..1f165dccf --- /dev/null +++ b/app/views/users/carte/_map.html.haml @@ -0,0 +1,13 @@ +#carte_page.row + #map{class: dossier.procedure.module_api_carto.classes } + + - if dossier.procedure.module_api_carto.quartiers_prioritaires + #qp.list + %h3.text-info Quartiers prioritaites + %ul + + - if dossier.procedure.module_api_carto.cadastre + #cadastre.list + %h3.text-warning Cadastres + %ul + diff --git a/app/views/users/carte/show.html.haml b/app/views/users/carte/show.html.haml index 0e75ebe20..7c7e7cc2a 100644 --- a/app/views/users/carte/show.html.haml +++ b/app/views/users/carte/show.html.haml @@ -10,27 +10,13 @@ %button#new.btn.btn-md.btn-success{type:'button'} %i.fa.fa-pencil Ajouter une zone - -#\- - -#%button#edit.btn.btn-sm.btn-info{type:'button'} Editer - -#\- - -#%button#delete.btn.btn-sm.btn-danger{type:'button'} Supprimer %span#search_by_address{style: 'margin-left: 20px'} %input.form-control{type: :address, placeholder: 'Rechercher une adresse'} %br %br - #carte_page.row - #map{class: @dossier.procedure.module_api_carto.classes } - - if @dossier.procedure.module_api_carto.quartiers_prioritaires - #qp.list - %h3.text-info Quartiers prioritaites - %ul - - - if @dossier.procedure.module_api_carto.cadastre - #cadastre.list - %h3.text-warning Cadastres - %ul + =render partial: 'users/carte/map', locals: {dossier: @dossier} = form_tag(url_for({controller: :carte, action: :save, dossier_id: @dossier.id}), class: 'form-inline', method: 'POST') do %br @@ -43,6 +29,4 @@ -else =render partial: '/layouts/modifications_terminees' - %script{type: 'text/javascript'} - ="var dossier_id =#{@dossier.id}" - initCarto(); + = render partial: 'users/carte/init_carto', locals: {dossier: @dossier} diff --git a/app/views/users/recapitulatif/_commentaires_flux.html.haml b/app/views/users/recapitulatif/_commentaires_flux.html.haml deleted file mode 100644 index 843940b25..000000000 --- a/app/views/users/recapitulatif/_commentaires_flux.html.haml +++ /dev/null @@ -1,19 +0,0 @@ -.content{id: ('commentaires_flux' + (@facade.champ_id.nil? ? '' : "_#{@facade.champ_id}")),style:'width:100%;'} - -@facade.commentaires.each do |com| - %span.text-info#email_contact{style: 'font-weight:bold'} - =com.email - %span#created_at - \- - =com.created_at_fr - - unless com.piece_justificative.nil? - \- - %span#piece_justificative - %b - = link_to com.piece_justificative.original_filename, com.piece_justificative.content_url, style:'color: green', target: '_blank' - - %br - .description#body - =com.body.html_safe - - - %br diff --git a/spec/features/admin/procedure_locked_spec.rb b/spec/features/admin/procedure_locked_spec.rb index 0f0139a42..bfd9fc2d6 100644 --- a/spec/features/admin/procedure_locked_spec.rb +++ b/spec/features/admin/procedure_locked_spec.rb @@ -16,45 +16,4 @@ feature 'procedure locked' do expect(page).not_to have_content('La procédure ne peut plus être modifiée car elle a été publiée') end end - context 'when procedure is published' do - pending 'à voir si on enlève complètement les référence dans le left panel ou pas' - # let(:published) { true } - # before do - # visit admin_procedure_path(procedure) - # end - # - # scenario 'info label is present' do - # expect(page).to have_content('La procédure ne peut plus être modifiée car elle a été publiée') - # end - # - # context 'when user click on Description tab' do - # before do - # page.click_on 'Description' - # end - # - # scenario 'page doest not change' do - # expect(page).to have_css('#procedure_show') - # end - # end - # - # context 'when user click on Champs tab' do - # before do - # page.click_on 'Champs' - # end - # - # scenario 'page doest not change' do - # expect(page).to have_css('#procedure_show') - # end - # end - # - # context 'when user click on Pieces Justificatives tab' do - # before do - # page.click_on 'Pièces justificatives' - # end - # - # scenario 'page doest not change' do - # expect(page).to have_css('#procedure_show') - # end - # end - end end diff --git a/spec/views/users/recapitulatif/_commentaires_flux_spec.rb b/spec/views/users/recapitulatif/_commentaires_flux_spec.rb deleted file mode 100644 index 0770f40b2..000000000 --- a/spec/views/users/recapitulatif/_commentaires_flux_spec.rb +++ /dev/null @@ -1,56 +0,0 @@ -require 'spec_helper' - -describe 'users/recapitulatif/_commentaires_flux.html.haml', type: :view, vcr: { cassette_name: 'views_users_recapitulatif_commentaires_flux' } do - let(:dossier) { create(:dossier) } - let(:dossier_id) { dossier.id } - let(:email_commentaire) { 'mon_mail_de_commentaire@test.com' } - - let(:document_upload) { Rack::Test::UploadedFile.new("./spec/support/files/piece_justificative_0.pdf", 'application/pdf') } - let(:pj) { create :piece_justificative, content: document_upload } - - let!(:commentaire) { create(:commentaire, dossier: dossier, email: email_commentaire, body: 'ma super description', piece_justificative: pj) } - let(:body) { 'Commentaire de test' } - - before do - assign(:facade, DossierFacades.new(dossier.id, dossier.user.email)) - render - end - - pending 'à supprimer quand les tests seront vert' - - # context 'Affichage du flux de commentaire' do - # it 'l\'email du contact est présent' do - # expect(rendered).to have_selector('span[id=email_contact]') - # end - # - # it 'la date du commentaire est présent' do - # expect(rendered).to have_selector('span[id=created_at]') - # end - # - # it 'le corps du commentaire est présent' do - # expect(rendered).to have_selector('div[class=description][id=body]') - # end - # - # context 'when commentaire as PJ' do - # it 'commentaire present the link' do - # expect(rendered).to have_css('#piece_justificative') - # end - # end - # end - # - # context 'Affichage du formulaire de commentaire' do - # it 'Le formulaire envoie vers /dossiers/:dossier_id/commentaire en #POST' do - # expect(rendered).to have_selector("form[action='/users/dossiers/#{dossier_id}/commentaire'][method=post]") - # end - # - # it 'Champs de texte' do - # expect(rendered).to have_selector('textarea[id=texte_commentaire][name=texte_commentaire]') - # end - # - # describe 'File input' do - # it 'have file_input tag' do - # expect(rendered).to have_css('#piece_justificative_content') - # end - # end - # end -end diff --git a/spec/views/users/recapitulatif/show.html.haml_spec.rb b/spec/views/users/recapitulatif/show.html.haml_spec.rb index 143f626c2..63ba3bee8 100644 --- a/spec/views/users/recapitulatif/show.html.haml_spec.rb +++ b/spec/views/users/recapitulatif/show.html.haml_spec.rb @@ -55,12 +55,10 @@ describe 'users/recapitulatif/show.html.haml', type: :view do context 'lien carte' do it 'le lien vers carte est présent' do - pending 'map: later' expect(rendered).to have_css('#maj_carte') end it 'le lien vers description est correct' do - pending 'map: later' expect(rendered).to have_selector("a[id=maj_carte][href='/users/dossiers/#{dossier_id}/carte']") end end @@ -139,7 +137,6 @@ describe 'users/recapitulatif/show.html.haml', type: :view do end it 'map link is present' do - pending 'map: later' expect(rendered).to have_css('#maj_carte') end