diff --git a/.byebug_history b/.byebug_history new file mode 100644 index 000000000..f22879884 --- /dev/null +++ b/.byebug_history @@ -0,0 +1,4 @@ +exit +xit +xtei +cniuecniu diff --git a/app/assets/stylesheets/left_pannel.scss b/app/assets/stylesheets/left_panel.scss similarity index 99% rename from app/assets/stylesheets/left_pannel.scss rename to app/assets/stylesheets/left_panel.scss index 7c8925c3f..0b250ab77 100644 --- a/app/assets/stylesheets/left_pannel.scss +++ b/app/assets/stylesheets/left_panel.scss @@ -1,4 +1,4 @@ -#left-pannel { +#left-panel { margin-top: 60px; padding: 0; background-color: #003189; diff --git a/app/assets/stylesheets/navbar.scss b/app/assets/stylesheets/navbar.scss index 3d8fd8ea5..dd22714b9 100644 --- a/app/assets/stylesheets/navbar.scss +++ b/app/assets/stylesheets/navbar.scss @@ -158,7 +158,6 @@ position: fixed; bottom: 26px; right: -35px; - -webkit-transform: rotate(-45deg); transform: rotate(-45deg); width: 150px; background-color: #008cba; @@ -207,4 +206,3 @@ font-size: 20px; } } - diff --git a/app/assets/stylesheets/print.scss b/app/assets/stylesheets/print.scss index 9b9dc1fec..bdbc39347 100644 --- a/app/assets/stylesheets/print.scss +++ b/app/assets/stylesheets/print.scss @@ -1,6 +1,5 @@ @media print { html, body { - width: 900px; margin: 0; } @@ -28,4 +27,39 @@ #backoffice_dossier_show .nav-tabs { display: none; } + + #left-panel { + margin-top: 0; + height: auto; + position: relative; + width: 100%; + } + + #wrap { + overflow: visible; + } + + #main-container { + width: 100%; + } + + #beta { + top: 26px; + bottom: initial; + position: absolute; + transform: rotate(45deg); + } + + .copyright { + width: 100%; + left: 0; + } + + .no-page-break-inside { + page-break-inside: avoid; + } + + .display-block-on-print { + display: block !important; + } } diff --git a/app/controllers/admin/pieces_justificatives_controller.rb b/app/controllers/admin/pieces_justificatives_controller.rb index 7ed5c7ef5..c899e3486 100644 --- a/app/controllers/admin/pieces_justificatives_controller.rb +++ b/app/controllers/admin/pieces_justificatives_controller.rb @@ -6,8 +6,11 @@ class Admin::PiecesJustificativesController < AdminController end def update - @procedure.update_attributes(update_params) - flash.now.notice = 'Modifications sauvegardées' + if @procedure.update_attributes(update_params) + flash.now.notice = 'Modifications sauvegardées' + else + flash.now.notice = 'Une erreur est survenue' + end render 'show', format: :js end @@ -22,7 +25,7 @@ class Admin::PiecesJustificativesController < AdminController def update_params params .require(:procedure) - .permit(types_de_piece_justificative_attributes: [:libelle, :description, :id, :order_place]) + .permit(types_de_piece_justificative_attributes: [:libelle, :description, :id, :order_place, :lien_demarche]) end def move_up @@ -41,4 +44,4 @@ class Admin::PiecesJustificativesController < AdminController render json: {}, status: 400 end end -end \ No newline at end of file +end diff --git a/app/controllers/root_controller.rb b/app/controllers/root_controller.rb index 0bf6de2b4..679911acb 100644 --- a/app/controllers/root_controller.rb +++ b/app/controllers/root_controller.rb @@ -43,6 +43,8 @@ class RootController < ApplicationController return redirect_to administrations_path end + @demo_environment_host = "https://tps-dev.apientreprise.fr" unless Rails.env.development? + render 'landing' end end diff --git a/app/models/dossier.rb b/app/models/dossier.rb index ee3288d98..90eed3839 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -309,6 +309,10 @@ class Dossier < ActiveRecord::Base end end + def followers_gestionnaires_emails + follows.includes(:gestionnaire).map { |f| f.gestionnaire }.pluck(:email).join(' ') + end + def reset! etablissement.destroy entreprise.destroy diff --git a/app/models/type_de_piece_justificative.rb b/app/models/type_de_piece_justificative.rb index 6ab69f5a6..7bdb8ac42 100644 --- a/app/models/type_de_piece_justificative.rb +++ b/app/models/type_de_piece_justificative.rb @@ -4,4 +4,6 @@ class TypeDePieceJustificative < ActiveRecord::Base belongs_to :procedure validates :libelle, presence: true, allow_blank: false, allow_nil: false + + validates :lien_demarche, format: { with: URI::regexp }, allow_blank: true, allow_nil: true end diff --git a/app/serializers/dossier_procedure_serializer.rb b/app/serializers/dossier_procedure_serializer.rb index 278c6d4ce..c0d694d59 100644 --- a/app/serializers/dossier_procedure_serializer.rb +++ b/app/serializers/dossier_procedure_serializer.rb @@ -5,4 +5,6 @@ class DossierProcedureSerializer < ActiveModel::Serializer :archived, :mandataire_social, :state + + attribute :followers_gestionnaires_emails, key: :emails_accompagnateurs end diff --git a/app/serializers/type_de_piece_justificative_serializer.rb b/app/serializers/type_de_piece_justificative_serializer.rb index 9dc1743b0..cff798508 100644 --- a/app/serializers/type_de_piece_justificative_serializer.rb +++ b/app/serializers/type_de_piece_justificative_serializer.rb @@ -2,5 +2,6 @@ class TypeDePieceJustificativeSerializer < ActiveModel::Serializer attributes :id, :libelle, :description, - :order_place -end \ No newline at end of file + :order_place, + :lien_demarche +end diff --git a/app/views/admin/pieces_justificatives/_fields.html.haml b/app/views/admin/pieces_justificatives/_fields.html.haml index f44cf396a..7c7871a32 100644 --- a/app/views/admin/pieces_justificatives/_fields.html.haml +++ b/app/views/admin/pieces_justificatives/_fields.html.haml @@ -6,6 +6,12 @@ .form-group %h4 Description =ff.text_area :description, class: 'form-control description', placeholder: 'Description' + .form-group + %h4 + Lien du formulaire vierge + %small + (optionel) + =ff.url_field :lien_demarche, class: 'form-control', placeholder: 'Lien du document vierge' .form-group = ff.hidden_field :order_place, value: ff.index @@ -23,4 +29,3 @@ = f.submit('Ajouter la pièce', class: 'btn btn-success', id: 'add_piece_justificative') - else = link_to("", admin_procedure_piece_justificative_path(@procedure, ff.object.id), method: :delete, remote: true, id: "delete_type_de_piece_justificative_#{ff.object.id}", class: %w(form-control btn btn-danger fa fa-trash-o) ) - diff --git a/app/views/dossiers/_dossier_show.html.haml b/app/views/dossiers/_dossier_show.html.haml index a89154ab0..842c9740c 100644 --- a/app/views/dossiers/_dossier_show.html.haml +++ b/app/views/dossiers/_dossier_show.html.haml @@ -4,7 +4,7 @@ .default_data_block %div.row.show-block.infos %div.header - %div.col-lg-8.col-md-8.col-sm-8.col-xs-8.title-no-expanse + %div.col-xs-8.title-no-expanse %div.carret-right INFORMATIONS DU DEMANDEUR - if !@current_gestionnaire && ["draft", "updated", "replied", "initiated"].include?(@facade.dossier.state) @@ -16,34 +16,34 @@ .default_data_block %div.row.show-block.infos#infos_entreprise %div.header - %div.col-lg-12.col-md-12.col-sm-12.col-xs-12.title + %div.col-xs-12.title %div.carret-right %div.carret-down INFORMATIONS DU DEMANDEUR - %div.body + %div.body.display-block-on-print = render partial: '/dossiers/infos_entreprise' .default_data_block.default_visible %div.row.show-block.infos#infos_dossier %div.header - %div.col-lg-10.col-md-10.col-sm-10.col-xs-10.title + %div.col-xs-10.title %div.carret-right %div.carret-down CONSTRUCTION DU DOSSIER = render partial: '/dossiers/edit_dossier' - %div.body + %div.body.display-block-on-print = render partial: '/dossiers/infos_dossier' - if @facade.dossier.procedure.module_api_carto.use_api_carto - .default_data_block.default_visible + .default_data_block.default_visible.no-page-break-inside %div.row.show-block#carto %div.header - %div.col-lg-10.col-md-10.col-sm-10.col-xs-10.title + %div.col-xs-10.title %div.carret-right %div.carret-down CARTOGRAPHIE = render partial: '/dossiers/edit_carto' - %div.body + %div.body.display-block-on-print %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}"} @@ -56,11 +56,11 @@ .default_data_block.default_visible %div.row.show-block#private-fields %div.header - %div.col-lg-10.col-md-10.col-sm-10.col-xs-10.title + %div.col-xs-10.title %div.carret-right %div.carret-down = "formulaire privé".upcase - %div.col-lg-2.col-md-2.col-sm-2.col-xs-2.count + %div.col-xs-2.count - private_fields_count = @champs_private.count = (private_fields_count == 1) ? "1 champ" : "#{private_fields_count} champs" %div.body diff --git a/app/views/dossiers/_messagerie.html.haml b/app/views/dossiers/_messagerie.html.haml index c38063552..47d389e77 100644 --- a/app/views/dossiers/_messagerie.html.haml +++ b/app/views/dossiers/_messagerie.html.haml @@ -11,17 +11,20 @@ .alert.alert-info Cette messagerie permet d'échanger entre le demandeur et le service instructeur. - .body + .body.display-block-on-print - if dossier_facade.commentaires.any? .commentaires = render partial: 'dossiers/commentaires/commentaire', collection: dossier_facade.commentaires.object.sort .split-hr - #new-commentaire + #new-commentaire.hidden-print = render partial: 'dossiers/commentaires/form', locals: { dossier_facade: @facade } - - .last-commentaire.clearfix + .col-md-6 + %input#save-message.form-control.btn.btn-send{ type: 'submit', value: 'ENVOYER' } + + + .last-commentaire.clearfix.hidden-print - if last_comment = dossier_facade.commentaires.first %div DERNIER MESSAGE diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 7b4214397..c4e7e86ce 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -6,6 +6,7 @@ %meta{'http-equiv' => "X-UA-Compatible", :content => "IE=edge"} = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true + = stylesheet_link_tag 'print', media: 'print', 'data-turbolinks-track' => true = javascript_include_tag 'application', 'data-turbolinks-track' => true = csrf_meta_tags @@ -32,7 +33,7 @@ = render partial: "layouts/navbar" %div.row.no-margin - if RenderPartialService.left_panel_exist? @left_pannel_url - %div.col-lg-2.col-md-2.col-sm-2.col-xs-2#left-pannel + %div.col-xs-2#left-panel - if gestionnaire_signed_in? #search-block = render partial: 'layouts/left_panels/search_area' diff --git a/app/views/root/landing.html.haml b/app/views/root/landing.html.haml index 7c8a9ee5a..c4ad61372 100644 --- a/app/views/root/landing.html.haml +++ b/app/views/root/landing.html.haml @@ -44,18 +44,19 @@ .col-md-4.col-lg-4 %h3.text-primary Acteurs publics %h4 Créez des démarches en ligne simplifiées et sécurisées. - =link_to 'Démonstration', 'https://tps-dev.apientreprise.fr/administrateurs/sign_in/demo', {class: 'btn btn-lg btn-primary'} + =link_to 'Démonstration', "#{@demo_environment_host}/administrateurs/sign_in/demo", {class: 'btn btn-lg btn-primary'} .col-md-4.col-lg-4 %h3.text-warning Agents et services %h4 Accompagnez et co-traitez les projets avec les usagers. - =link_to 'Démonstration', 'https://tps-dev.apientreprise.fr/gestionnaires/sign_in/demo', {class: 'btn btn-lg btn-warning'} + =link_to 'Démonstration', "#{@demo_environment_host}/gestionnaires/sign_in/demo", {class: 'btn btn-lg btn-warning'} .col-md-4.col-lg-4 %h3.text-success Usagers %h4 Profitez de démarches simplifiées et d’échanges continus avec les services traitants. - =link_to 'Démonstration', 'https://tps-dev.apientreprise.fr/users/sign_in/demo', {class: 'btn btn-lg btn-success'} - + =link_to 'Démonstration', "#{@demo_environment_host}/users/sign_in/demo", {class: 'btn btn-lg btn-success'} + %h1 + = @demo_environment_host .split-hr-left .center diff --git a/app/views/users/description/_pieces_justificatives.html.haml b/app/views/users/description/_pieces_justificatives.html.haml index e63b2968e..5dce35c68 100644 --- a/app/views/users/description/_pieces_justificatives.html.haml +++ b/app/views/users/description/_pieces_justificatives.html.haml @@ -1,15 +1,17 @@ --unless dossier.procedure.lien_demarche.blank? - %p - Récupérer le formulaire de demande ou CERFA vierge pour mon dossier : - = link_to "Télécharger", dossier.procedure.lien_demarche, target: '_blank', id: 'lien_cerfa' %table.table - if dossier.procedure.cerfa_flag %tr - %th.col-lg-6 + %th Formulaire de demande ou CERFA (complété et numérisé) + %td + -unless dossier.procedure.lien_demarche.blank? + %em + Récupérer le formulaire de demande ou CERFA vierge pour mon dossier : + = link_to "Télécharger", "#{dossier.procedure.lien_demarche}", target: :blank, id: :lien_cerfa + -# %a{ id: 'lien_cerfa', href: "#{dossier.procedure.lien_demarche}", target: '_blank'} Télécharger - %td.col-lg-5 + %td -if dossier.cerfa_available? %span.btn.btn-sm.btn-file.btn-success Modifier @@ -19,9 +21,16 @@ - dossier.types_de_piece_justificative.order('order_place ASC').each do |type_de_piece_justificative| %tr - %th.col-lg-6.piece-libelle + %th.piece-libelle = type_de_piece_justificative.libelle - %td.col-lg-5 + + %td + - unless type_de_piece_justificative.lien_demarche.blank? + %em + Récupérer le formulaire vierge pour mon dossier : + = link_to "Télécharger", type_de_piece_justificative.lien_demarche, target: :blank + + %td -if type_de_piece_justificative.api_entreprise %span.text-success{ id: "piece_justificative_#{type_de_piece_justificative.id}" } Nous l'avons récupéré pour vous. -else diff --git a/app/views/users/description/_show.html.haml b/app/views/users/description/_show.html.haml index 7e130baaa..a1ec74144 100644 --- a/app/views/users/description/_show.html.haml +++ b/app/views/users/description/_show.html.haml @@ -24,6 +24,7 @@ %br %h3 Documents administratifs + //TODO a refactorer .row .col-lg-8 diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 01ef3e663..76333b2be 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -8,4 +8,4 @@ Rails.application.config.assets.version = '1.0' # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. -# Rails.application.config.assets.precompile += %w( search.js ) +Rails.application.config.assets.precompile += %w(print.css) diff --git a/db/migrate/20170118144306_add_lien_to_type_de_piece_justificative.rb b/db/migrate/20170118144306_add_lien_to_type_de_piece_justificative.rb new file mode 100644 index 000000000..93d970638 --- /dev/null +++ b/db/migrate/20170118144306_add_lien_to_type_de_piece_justificative.rb @@ -0,0 +1,5 @@ +class AddLienToTypeDePieceJustificative < ActiveRecord::Migration[5.0] + def change + add_column :types_de_piece_justificative, :lien_demarche, :string, default: nil + end +end diff --git a/db/schema.rb b/db/schema.rb index e9491dca0..f6a873372 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20161227103823) do +ActiveRecord::Schema.define(version: 20170125152856) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -361,6 +361,7 @@ ActiveRecord::Schema.define(version: 20161227103823) do t.datetime "updated_at", null: false t.integer "procedure_id" t.integer "order_place" + t.string "lien_demarche" end create_table "users", force: :cascade do |t| diff --git a/spec/controllers/root_controller_spec.rb b/spec/controllers/root_controller_spec.rb index 60ad3e58d..4f5b387a2 100644 --- a/spec/controllers/root_controller_spec.rb +++ b/spec/controllers/root_controller_spec.rb @@ -56,6 +56,31 @@ describe RootController, type: :controller do end it { expect(response.body).to have_css('#landing') } + + end + + context 'environment is not development' do + render_views + + before do + Rails.env.stub(:development? => false) + subject + end + + it { expect(response.body).to have_link('Démonstration', href: "https://tps-dev.apientreprise.fr#{ users_sign_in_demo_path }") } + + end + + context 'environment is development' do + render_views + + before do + Rails.env.stub(:development? => true) + subject + end + + it { expect(response.body).to have_link('Démonstration', href: users_sign_in_demo_path) } + end context 'when opensimplif features is true' do @@ -81,4 +106,5 @@ describe RootController, type: :controller do expect(response.body).to have_css("a[href='#{new_user_session_path}']") end end + end diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index ddbf350ce..c37efc03f 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -681,27 +681,32 @@ describe Dossier do end end - describe '#export_headers' do + context 'when dossier is followed' do let(:procedure) { create(:procedure, :with_type_de_champ) } - let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) } - subject { dossier.export_headers } + let(:gestionnaire) { create(:gestionnaire) } + let(:follow) { create(:follow, gestionnaire: gestionnaire) } + let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure, follows: [follow]) } - it { expect(subject).to include(:description) } - it { expect(subject.count).to eq(DossierProcedureSerializer.new(dossier).attributes.count + dossier.procedure.types_de_champ.count + dossier.export_entreprise_data.count) } - end + describe '#export_headers' do - describe '#data_with_champs' do - let(:procedure) { create(:procedure, :with_type_de_champ) } - let(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) } - subject { dossier.data_with_champs } + subject { dossier.export_headers } - it { expect(subject[0]).to be_a_kind_of(Integer) } - it { expect(subject[1]).to be_a_kind_of(Time) } - it { expect(subject[2]).to be_a_kind_of(Time) } - it { expect(subject[3]).to be_in([true, false]) } - it { expect(subject[4]).to be_in([true, false]) } - it { expect(subject[5]).to eq("draft") } - it { expect(subject.count).to eq(DossierProcedureSerializer.new(dossier).attributes.count + dossier.procedure.types_de_champ.count + dossier.export_entreprise_data.count) } + it { expect(subject).to include(:description) } + it { expect(subject.count).to eq(DossierProcedureSerializer.new(dossier).attributes.count + dossier.procedure.types_de_champ.count + dossier.export_entreprise_data.count) } + end + + describe '#data_with_champs' do + subject { dossier.data_with_champs } + + it { expect(subject[0]).to be_a_kind_of(Integer) } + it { expect(subject[1]).to be_a_kind_of(Time) } + it { expect(subject[2]).to be_a_kind_of(Time) } + it { expect(subject[3]).to be_in([true, false]) } + it { expect(subject[4]).to be_in([true, false]) } + it { expect(subject[5]).to eq("draft") } + it { expect(subject[6]).to eq(dossier.followers_gestionnaires_emails) } + it { expect(subject.count).to eq(DossierProcedureSerializer.new(dossier).attributes.count + dossier.procedure.types_de_champ.count + dossier.export_entreprise_data.count) } + end end describe '#Dossier.to_csv' do @@ -746,6 +751,7 @@ describe Dossier do it { expect(subject[:entreprise_prenom]).to be_nil } end + describe '#Dossier.to_xlsx' do let!(:procedure) { create(:procedure) } let!(:dossier) { create(:dossier, :with_entreprise, user: user, procedure: procedure) } @@ -930,4 +936,39 @@ describe Dossier do it { is_expected.to be_falsey } end end + + describe '#followers_gestionnaires_emails' do + + context 'when there is no follower' do + let(:dossier) { create(:dossier, follows: []) } + + subject { dossier.followers_gestionnaires_emails } + + it { is_expected.to eq "" } + end + + let(:gestionnaire) { create(:gestionnaire) } + let(:follow) { create(:follow, gestionnaire: gestionnaire) } + + context 'when there is 1 follower' do + let(:dossier) { create(:dossier, follows: [follow]) } + + subject { dossier.followers_gestionnaires_emails } + + it { is_expected.to eq gestionnaire.email } + end + + let(:gestionnaire2) { create :gestionnaire} + let(:follow2) { create(:follow, gestionnaire: gestionnaire2) } + + context 'when there is 2 followers' do + let(:dossier) { create(:dossier, follows: [follow, follow2]) } + + subject { dossier.followers_gestionnaires_emails } + + it { is_expected.to eq "#{gestionnaire.email} #{gestionnaire2.email}" } + end + + + end end diff --git a/spec/models/type_de_piece_justificative_spec.rb b/spec/models/type_de_piece_justificative_spec.rb index a2b47c14e..2983e6857 100644 --- a/spec/models/type_de_piece_justificative_spec.rb +++ b/spec/models/type_de_piece_justificative_spec.rb @@ -10,6 +10,7 @@ describe TypeDePieceJustificative do it { is_expected.to have_db_column(:created_at) } it { is_expected.to have_db_column(:updated_at) } it { is_expected.to have_db_column(:order_place) } + it { is_expected.to have_db_column(:lien_demarche) } end describe 'associations' do @@ -29,5 +30,12 @@ describe TypeDePieceJustificative do # it { is_expected.not_to allow_value('').for(:order_place) } it { is_expected.to allow_value(1).for(:order_place) } end + + context 'lien_demarche' do + it { is_expected.not_to allow_value(nil).for(:lien_demarche) } + it { is_expected.not_to allow_value('').for(:lien_demarche) } + it { is_expected.not_to allow_value('not-a-link').for(:lien_demarche) } + it { is_expected.to allow_value('http://link').for(:lien_demarche) } + end end end