app: rename new_administrateur to administrateurs

This commit is contained in:
Pierre de La Morinerie 2021-11-25 15:26:55 +00:00
parent 5736521f52
commit 184a401182
97 changed files with 155 additions and 158 deletions

View file

@ -0,0 +1 @@
%iframe{ src: admin_procedure_attestation_template_preview_path, width: '100%', height: '650px' }

View file

@ -0,0 +1,45 @@
= f.label :title do
Titre de l'attestation
%span.mandatory *
= f.text_field :title, class: 'form-control', placeholder: 'Titre de lattestation'
= f.label :body do
Corps du document
%span.mandatory *
= f.text_area :body, rows: '6', placeholder: 'Description de la démarche, destinataires, etc. ', class: 'form-control'
#tags-table
%h2.add-tag-title
Insérer une balise
%p.notice
Copiez-collez les balises ci-dessous pour afficher automatiquement linformation souhaitée.
.head
.tag Balise
.description Description
.items
- @attestation_template.tags.each do |tag|
.item
%code.tag{ style: "white-space: pre-wrap;" }
= "--#{tag[:libelle]}--"
.description
= tag[:description]
%h3.header-subsection Logo de l'attestation
= image_upload_and_render f, @attestation_template.logo, false
%p.notice
Formats acceptés : JPG / JPEG / PNG.
%br
Dimensions conseillées : au minimum 500 px de largeur ou de hauteur, poids maximum : 0,5 Mo.
%h3.header-subsection Tampon de l'attestation
= image_upload_and_render f, @attestation_template.signature, false
%p.notice
Formats acceptés : JPG / JPEG / PNG.
%br
Dimensions conseillées : au minimum 500 px de largeur ou de hauteur, poids maximum : 0,5 Mo.
= f.label :footer do
Pied de page
= f.text_field :footer, class: 'form-control', maxlength: 190

View file

@ -0,0 +1,56 @@
- content_for(:root_class, 'scroll-margins-for-sticky-footer')
= render partial: 'administrateurs/breadcrumbs',
locals: { steps: [link_to('Démarches', admin_procedures_path),
link_to(@procedure.libelle, admin_procedure_path(@procedure)),
'Attestation'] }
.procedure-form#attestation-template-edit
.procedure-form__columns.container
= form_for @attestation_template,
url: url_for({ controller: 'administrateurs/attestation_templates', action: :update, id: @procedure.id }),
multipart: true,
html: { class: 'form procedure-form__column--form' } do |f|
%h1.page-title
Délivrance dattestation
- if @attestation_template.activated?
%span.text-active activée
- else
%span.text-inactive désactivée
- if @attestation_template.activated && @procedure.locked?
.card.warning
%p Lattestation ne peut plus être désactivée car la démarche est publiée.
%p.notice
Lattestation, si elle est activée, est émise au moment où un dossier est accepté.
%br
Lemail daccusé dacceptation envoyé à lusager comporte alors un lien vers lattestation ;
celle-ci est également disponible au téléchargement depuis lespace personnel de lusager.
= render partial: 'administrateurs/attestation_templates/informations', locals: { f: f }
.procedure-form__actions.sticky--bottom
.actions-left
-# Admins cannot disactivate the Attestation if it is activated and the procedure is published
- if !(@attestation_template.activated && @procedure.locked?)
%label.toggle-switch
= f.check_box :activated, class: 'toggle-switch-checkbox'
%span.toggle-switch-control.round
%span.toggle-switch-label.on Attestation activée
%span.toggle-switch-label.off Attestation désactivée
.actions-right
= link_to 'Annuler', edit_admin_procedure_attestation_template_path(id: @procedure), class: 'button', data: { confirm: 'Êtes-vous sûr de vouloir annuler les modifications effectuées ?'}
= f.button 'Enregistrer', class: 'button primary send'
.procedure-form__column--preview
.procedure-form__preview.sticky--top
%h3
.procedure-form__preview-title
Aperçu
.notice
Cet aperçu est mis à jour après chaque sauvegarde.
.procedure-preview
= render partial: 'administrateurs/attestation_templates/apercu', locals: { procedure: @procedure }

View file

@ -0,0 +1,84 @@
require 'prawn/measurement_extensions'
#----- A4 page size
page_size = 'A4'
page_height = 842
page_width = 595
#----- margins
body_width = 400
top_margin = 50
bottom_margin = 20
footer_height = top_margin - bottom_margin
right_margin = (page_width - body_width)/2
left_margin = right_margin
#----- size of images
max_logo_width = body_width
max_logo_height = 50.mm
max_signature_size = 50.mm
def normalize_pdf_text(text)
text&.tr("\t", ' ')
end
title = normalize_pdf_text(@attestation.fetch(:title))
body = normalize_pdf_text(@attestation.fetch(:body))
footer = normalize_pdf_text(@attestation.fetch(:footer))
created_at = @attestation.fetch(:created_at)
logo = @attestation[:logo]
signature = @attestation[:signature]
prawn_document(margin: [top_margin, right_margin, bottom_margin, left_margin], page_size: page_size) do |pdf|
pdf.font_families.update( 'marianne' => { normal: Rails.root.join('lib/prawn/fonts/marianne/marianne-regular.ttf' )})
pdf.font 'marianne'
grey = '555555'
black = '333333'
body_height = pdf.cursor - footer_height
pdf.bounding_box([0, pdf.cursor], width: body_width, height: body_height) do
if logo.present?
logo_content = if logo.is_a?(ActiveStorage::Attached::One)
logo.download
else
logo.rewind && logo.read
end
pdf.image StringIO.new(logo_content), fit: [max_logo_width , max_logo_height], position: :center
end
pdf.fill_color grey
pdf.pad_top(40) { pdf.text "le #{l(created_at, format: '%e %B %Y')}", size: 9, align: :right, character_spacing: -0.5 }
pdf.fill_color black
pdf.pad_top(40) { pdf.text title, size: 14, character_spacing: -0.2 }
pdf.fill_color grey
pdf.pad_top(30) { pdf.text body, size: 9, character_spacing: -0.2, align: :justify }
if signature.present?
pdf.pad_top(40) do
signature_content = if signature.is_a?(ActiveStorage::Attached::One)
signature.download
else
signature.rewind && signature.read
end
pdf.image StringIO.new(signature_content), fit: [max_signature_size , max_signature_size], position: :right
end
end
end
pdf.repeat(:all) do
pdf.move_cursor_to footer_height - 10
pdf.fill_color grey
if footer.present?
# We reduce the size of large footer so they can be drawn in the corresponding area.
# This is due to a font change, the replacing font is slightly bigger than the previous one
footer_font_size = footer.length > 170 ? 7 : 8
pdf.text footer, align: :center, size: footer_font_size
end
end
end