From 316d8e09b5c3cc499a01ba815030733d87b64903 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Thu, 5 Oct 2017 23:27:02 +0200 Subject: [PATCH] Allow accompagnateurs to print a Dossier --- app/assets/images/icons/printer.svg | 1 + .../stylesheets/new_design/buttons.scss | 4 + app/assets/stylesheets/new_design/icons.scss | 4 + .../new_design/new_application.scss | 1 + app/assets/stylesheets/new_design/print.scss | 25 +++++ .../new_gestionnaire/dossiers_controller.rb | 5 + app/views/layouts/print.html.haml | 18 +++ .../dossiers/_header.html.haml | 2 + .../new_gestionnaire/dossiers/print.html.haml | 106 ++++++++++++++++++ app/views/root/patron.html.haml | 1 + config/initializers/assets.rb | 2 +- config/routes.rb | 1 + 12 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 app/assets/images/icons/printer.svg create mode 100644 app/assets/stylesheets/new_design/print.scss create mode 100644 app/views/layouts/print.html.haml create mode 100644 app/views/new_gestionnaire/dossiers/print.html.haml diff --git a/app/assets/images/icons/printer.svg b/app/assets/images/icons/printer.svg new file mode 100644 index 000000000..960a5561d --- /dev/null +++ b/app/assets/images/icons/printer.svg @@ -0,0 +1 @@ +ic_form \ No newline at end of file diff --git a/app/assets/stylesheets/new_design/buttons.scss b/app/assets/stylesheets/new_design/buttons.scss index 98c159788..40b4a6dfc 100644 --- a/app/assets/stylesheets/new_design/buttons.scss +++ b/app/assets/stylesheets/new_design/buttons.scss @@ -92,6 +92,10 @@ } } } + + &.icon-only i { + margin-right: 0; + } } .dropdown-content { diff --git a/app/assets/stylesheets/new_design/icons.scss b/app/assets/stylesheets/new_design/icons.scss index 2e09bac25..88de2c881 100644 --- a/app/assets/stylesheets/new_design/icons.scss +++ b/app/assets/stylesheets/new_design/icons.scss @@ -56,4 +56,8 @@ i { &.lock { background-image: image-url("icons/lock.svg"); } + + &.printer { + background-image: image-url("icons/printer.svg"); + } } diff --git a/app/assets/stylesheets/new_design/new_application.scss b/app/assets/stylesheets/new_design/new_application.scss index e575f56c5..2069bcfbe 100644 --- a/app/assets/stylesheets/new_design/new_application.scss +++ b/app/assets/stylesheets/new_design/new_application.scss @@ -7,3 +7,4 @@ // = require select2 // = require typeahead // = require_tree . +// = stub "print" diff --git a/app/assets/stylesheets/new_design/print.scss b/app/assets/stylesheets/new_design/print.scss new file mode 100644 index 000000000..e7617dd75 --- /dev/null +++ b/app/assets/stylesheets/new_design/print.scss @@ -0,0 +1,25 @@ +@import "colors"; +@import "fonts"; + +body { + font-family: "Muli"; +} + +.subtitle { + margin-top: -20px; + color: $grey; +} + +th, +td { + vertical-align: top; +} + +th { + text-align: left; + + &.header-section { + padding-top: 1.2em; + font-size: 1.2em; + } +} diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index 7c98e4af2..9fe474620 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -83,6 +83,11 @@ module NewGestionnaire redirect_to annotations_privees_dossier_path(dossier.procedure, dossier) end + def print + @dossier = dossier + render layout: "print" + end + private def dossier diff --git a/app/views/layouts/print.html.haml b/app/views/layouts/print.html.haml new file mode 100644 index 000000000..332c6430a --- /dev/null +++ b/app/views/layouts/print.html.haml @@ -0,0 +1,18 @@ +%html + %head + %meta{ "http-equiv": "Content-Type", content: "text/html; charset=UTF-8" } + %meta{ "http-equiv": "X-UA-Compatible", content: "IE=edge" } + %meta{ name: "viewport", content: "width=device-width, initial-scale=1" } + = csrf_meta_tags + + %title + = t("dynamics.page_title") + + = favicon_link_tag(image_url("favicons/16x16.png"), type: "image/png", sizes: "16x16") + = favicon_link_tag(image_url("favicons/32x32.png"), type: "image/png", sizes: "32x32") + = favicon_link_tag(image_url("favicons/96x96.png"), type: "image/png", sizes: "96x96") + + = stylesheet_link_tag "new_design/print", media: "all" + + %body + = yield diff --git a/app/views/new_gestionnaire/dossiers/_header.html.haml b/app/views/new_gestionnaire/dossiers/_header.html.haml index 949120b76..7104642d0 100644 --- a/app/views/new_gestionnaire/dossiers/_header.html.haml +++ b/app/views/new_gestionnaire/dossiers/_header.html.haml @@ -7,6 +7,8 @@ %li = "Dossier nº #{dossier.id}" %div + = link_to print_dossier_path(dossier.procedure, dossier), target: "_blank", class: "button icon-only" do + %i.printer> = render partial: "new_gestionnaire/procedures/dossier_actions", locals: { procedure: dossier.procedure, dossier: dossier, dossier_is_followed: current_gestionnaire&.follow?(dossier) } = render partial: "state_button", locals: { dossier: dossier } %ul.tabs diff --git a/app/views/new_gestionnaire/dossiers/print.html.haml b/app/views/new_gestionnaire/dossiers/print.html.haml new file mode 100644 index 000000000..aa52edc1d --- /dev/null +++ b/app/views/new_gestionnaire/dossiers/print.html.haml @@ -0,0 +1,106 @@ +%h1= "Dossier nº #{@dossier.id}" +%h1.subtitle= "Procédure : #{@dossier.procedure.libelle}" + +%h2 Identité du demandeur + +- if @dossier.entreprise.present? + = render partial: "identite_entreprise", locals: { entreprise: @dossier.entreprise } + +- if @dossier.individual.present? + = render partial: "identite_individual", locals: { individual: @dossier.individual } + +%h2 Formulaire + +- champs = @dossier.ordered_champs.decorate +- if champs.any? + = render partial: "champs", locals: { champs: champs } + +- if @dossier.procedure.use_api_carto + %h3 Cartographie + - if @dossier.quartier_prioritaires.any? + %h4 Quartiers prioritaires + %table + - @dossier.quartier_prioritaires.each do |q| + %tr + %td= q.nom + + - if @dossier.cadastres.any? + %h4 Parcelles cadastrales + %table + - @dossier.cadastres.each do |p| + %tr + %td= "Parcelle n° #{p.numero} - Feuille #{p.code_arr} #{p.section} #{p.feuille}" + +- if @dossier.procedure.cerfa_flag? || @dossier.types_de_piece_justificative.any? + %h3 Pièces jointes + + %table + - if @dossier.procedure.cerfa_flag? + %tr + %th Formulaire : + %td + - if @dossier.cerfa_available? + Pièce fournie + - else + Pièce non fournie + + - @dossier.procedure.types_de_piece_justificative.each do |type_de_piece_justificative| + %tr + %th= "#{type_de_piece_justificative.libelle} :" + %td + - pj = @dossier.retrieve_last_piece_justificative_by_type(type_de_piece_justificative.id) + - if pj.present? + Pièce fournie + - else + Pièce non fournie + +%h2 Annotations privées + +- if @dossier.ordered_champs_private.present? + %table + - @dossier.champs_private.each do |champ| + %tr + %th + = champ.libelle + %td + = champ.value +- else + Aucune annotation privée + +%h2 Avis + +- if @dossier.avis.present? + %table + - @dossier.avis.each do |avis| + %tr + %th + = "Avis de #{avis.email_to_display}" + - if avis.confidentiel? + (confidentiel) + %td + - if avis.answer.present? + = avis.answer + - else + En attente de réponse +- else + Aucun avis + +%h2 Messagerie + +%table + - @dossier.commentaires.each do |commentaire| + %tr + %th + = render partial: 'commentaire_issuer', locals: { commentaire: commentaire, current_gestionnaire: current_gestionnaire } + - if ![current_gestionnaire.email, @dossier.user.email, 'contact@tps.apientreprise.fr'].include?(commentaire.email) + (invité) + %br + = I18n.l(commentaire.created_at.localtime, format: 'le %d/%m/%Y à %H:%M') + %td + %p= sanitize(commentaire.body) + - if file = commentaire.piece_justificative + %br + = file.original_filename + +%script{ type: "text/javascript" } + window.print(); diff --git a/app/views/root/patron.html.haml b/app/views/root/patron.html.haml index 38c478083..e98c59d2d 100644 --- a/app/views/root/patron.html.haml +++ b/app/views/root/patron.html.haml @@ -15,6 +15,7 @@ %i.bubble %i.attachment %i.lock + %i.printer %h1 Formulaires diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index f6ab56d75..049f67e64 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(print.css new_design/new_application.css new_design/application.js) +Rails.application.config.assets.precompile += %w(print.css new_design/new_application.css new_design/print.css new_design/application.js) diff --git a/config/routes.rb b/config/routes.rb index 64f7b8417..fcbf4ffa0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -258,6 +258,7 @@ Rails.application.routes.draw do get 'position' end post 'avis' => 'dossiers#create_avis' + get 'print' => 'dossiers#print' end end end