Merge branch 'dev'

This commit is contained in:
Mathieu Magnin 2017-12-15 11:41:53 +01:00
commit 1330497742
41 changed files with 171 additions and 99 deletions

View file

@ -1,17 +1,28 @@
@import "colors";
@import "constants";
.accompagnateur-title {
.page-title {
font-size: 30px;
font-weight: normal;
margin-top: 3 * $default-spacer;
margin-bottom: 3 * $default-spacer;
}
.tab-title {
font-size: 18px;
font-weight: bold;
margin-bottom: $default-padding;
}
.tab-list,
.tab-paragraph {
margin-bottom: 2 * $default-padding;
}
.accompagnateur-header {
background-color: $light-grey;
padding-top: $default-padding;
margin-bottom: 2 * $default-spacer;
margin-bottom: 3 * $default-spacer;
border-bottom: 1px solid $border-grey;
.container {

View file

@ -3,12 +3,6 @@
@import "constants";
.give-avis {
h1 {
font-size: 18px;
font-weight: bold;
margin-bottom: $default-padding;
}
.lock {
margin-right: $default-spacer;
}
@ -39,12 +33,6 @@
}
.ask-avis {
h1 {
font-size: 18px;
font-weight: bold;
margin-bottom: $default-padding;
}
.avis-notice {
font-size: 14px;
color: $grey;
@ -74,22 +62,16 @@
}
.list-avis {
.title {
font-size: 18px;
font-weight: bold;
margin-bottom: $default-padding;
.count {
display: inline-block;
width: 20px;
height: 20px;
border-radius: 10px;
border: 1px solid $grey;
text-align: center;
font-size: 12px;
font-weight: normal;
margin-left: 8px;
}
.count {
display: inline-block;
width: 20px;
height: 20px;
border-radius: 10px;
border: 1px solid $grey;
text-align: center;
font-size: 12px;
font-weight: normal;
margin-left: 8px;
}
.one-avis {

View file

@ -7,13 +7,23 @@
max-height: 350px;
overflow-y: scroll;
border: 1px solid $border-grey;
background: $light-grey;
padding: 2 * $default-spacer;
margin-bottom: $default-spacer;
border-radius: 4px;
> li {
display: flex;
align-items: flex-start;
margin-bottom: 2 * $default-padding;
margin-bottom: $default-padding;
padding: $default-padding;
background: #FFFFFF;
width: 80%;
border-radius: 3px;
&.from-me {
margin-left: auto;
}
}
}

View file

@ -0,0 +1,5 @@
module ChampHelper
def is_not_header_nor_explication?(champ)
!['header_section', 'explication'].include?(champ.type_champ)
end
end

View file

@ -0,0 +1,7 @@
module CommentaireHelper
def commentaire_is_from_me_class(commentaire, email)
if commentaire.email == email
"from-me"
end
end
end

View file

@ -128,17 +128,27 @@ class AttestationTemplate < ApplicationRecord
.select { |dossier_champ| dossier_champ.libelle == tag[:libelle] }
.first
acc.gsub("--#{tag[:libelle]}--", champ.to_s)
replace_tag(acc, tag, champ)
end
end
def replace_tags_with_values_from_data(text, tags, data)
if data.present?
tags.inject(text) do |acc, tag|
acc.gsub("--#{tag[:libelle]}--", data.send(tag[:target].to_sym).to_s)
replace_tag(acc, tag, data.send(tag[:target].to_sym))
end
else
text
end
end
def replace_tag(text, tag, value)
libelle = Regexp.quote(tag[:libelle])
# allow any kind of space (non-breaking or other) in the tags libellé to match any kind of space in the template
# (the '\\ |' is there because plain ASCII spaces were escaped by preceding Regexp.quote)
libelle.gsub!(/\\ |[[:blank:]]/, "[[:blank:]]")
text.gsub(/--#{libelle}--/, value.to_s)
end
end

View file

@ -1,6 +1,6 @@
- if avis.present?
%section.list-avis
%h1.title
%h1.tab-title
Avis des invités
%span.count= avis.count

View file

@ -9,5 +9,7 @@
= link_to 'Demande', avis_path(avis)
%li{ class: current_page?(instruction_avis_path(avis)) ? 'active' : nil }
= link_to 'Avis', instruction_avis_path(avis)
- if avis.answer == nil
%span.notifications{ 'aria-label': 'notifications' }
%li{ class: current_page?(messagerie_avis_path(avis)) ? 'active' : nil }
= link_to 'Messagerie', messagerie_avis_path(avis)

View file

@ -5,7 +5,7 @@
.accompagnateur-header
.container.flex
.width-100
%h1 Avis
%h1.tab-title Avis
%ul.tabs
%li{ class: (@statut == NewGestionnaire::AvisController::A_DONNER_STATUS) ? 'active' : nil }>
= link_to(avis_index_path(statut: NewGestionnaire::AvisController::A_DONNER_STATUS)) do

View file

@ -5,7 +5,7 @@
.container
%section.give-avis
%h1 Donner votre avis
%h1.tab-title Donner votre avis
%h2.claimant
Demandeur :
%span.email= @avis.claimant.email
@ -22,7 +22,7 @@
= f.submit 'Envoyer votre avis', class: 'button send'
%section.ask-avis
%h1 Inviter une personne à donner son avis
%h1.tab-title Inviter une personne à donner son avis
%p.avis-notice L'invité pourra consulter, donner un avis sur le dossier et contribuer au fil de messagerie, mais il ne pourra le modifier.
= form_for Avis.new, url: avis_avis_path(@avis), html: { class: 'form' } do |f|

View file

@ -5,7 +5,7 @@
.messagerie.container
%ul.messages-list
- @dossier.commentaires.each do |commentaire|
%li
%li{ class: commentaire_is_from_me_class(commentaire, current_gestionnaire.email) }
= render partial: "new_gestionnaire/shared/commentaires/commentaire", locals: { commentaire: commentaire, messagerie_seen_at: nil }
= render partial: "new_gestionnaire/shared/commentaires/form", locals: { commentaire: @commentaire, form_url: commentaire_avis_path(@avis) }

View file

@ -4,7 +4,7 @@
= render partial: 'header', locals: { avis: @avis, dossier: @dossier }
.container
.accompagnateur-title Identité du demandeur
.tab-title Identité du demandeur
.card
- if @dossier.entreprise.present?
= render partial: 'new_gestionnaire/dossiers/identite_entreprise', locals: { entreprise: @dossier.entreprise }
@ -12,18 +12,18 @@
- if @dossier.individual.present?
= render partial: 'new_gestionnaire/dossiers/identite_individual', locals: { individual: @dossier.individual }
.accompagnateur-title Formulaire
.tab-title Formulaire
- champs = @dossier.ordered_champs.decorate
- if champs.any?
.card
= render partial: 'new_gestionnaire/dossiers/champs', locals: { champs: champs, dossier: @dossier, demande_seen_at: nil }
- if @dossier.procedure.use_api_carto
.accompagnateur-title Cartographie
.tab-title Cartographie
.card
= render partial: 'new_gestionnaire/dossiers/map', locals: { dossier: @dossier }
- if @dossier.procedure.cerfa_flag? || @dossier.types_de_piece_justificative.any?
.accompagnateur-title Pièces jointes
.tab-title Pièces jointes
.card
= render partial: "new_gestionnaire/dossiers/pieces_jointes", locals: { dossier: @dossier, demande_seen_at: nil }

View file

@ -1,9 +1,10 @@
.accompagnateur-title= title
.tab-title= title
- if emails_collection.present?
%ul
%ul.tab-list
- emails_collection.each do |email|
%li
= email
- else
= blank
%p.tab-paragraph
= blank

View file

@ -5,16 +5,14 @@
#dossier-annotations-privees.container
- if @dossier.ordered_champs_private.present?
%section
%h1.private-annotations Annotations privées
.card.featured
= form_for @dossier, url: annotations_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' } do |f|
= f.fields_for :champs_private, f.object.ordered_champs_private do |champ_form|
- champ = champ_form.object
= render partial: "new_gestionnaire/dossiers/champs/champ",
locals: { champ: champ, form: champ_form, seen_at: @annotations_privees_seen_at }
= form_for @dossier, url: annotations_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' } do |f|
= f.fields_for :champs_private, f.object.ordered_champs_private do |champ_form|
- champ = champ_form.object
= render partial: "new_gestionnaire/dossiers/champs/champ",
locals: { champ: champ, form: champ_form, seen_at: @annotations_privees_seen_at }
.send-wrapper
= f.submit 'Sauvegarder', class: 'button send', data: { disable_with: "Envoi..." }
.send-wrapper
= f.submit 'Sauvegarder', class: 'button send', data: { disable_with: "Envoi..." }
- else
%h2.empty-text Aucune annotation privée

View file

@ -4,7 +4,7 @@
.container
%section.ask-avis
%h1 Inviter une personne à donner son avis
%h1.tab-title Inviter une personne à donner son avis
%p.avis-notice L'invité pourra consulter, donner un avis sur le dossier et contribuer au fil de messagerie, mais il ne pourra le modifier.
= form_for Avis.new, url: avis_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' } do |f|

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.text_field :value,
'data-address': 'true',
placeholder: champ.libelle,

View file

@ -1,3 +1,6 @@
.champ
- if is_not_header_nor_explication?(champ)
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= render partial: "new_gestionnaire/dossiers/champs/#{champ.type_champ}",
locals: { champ: champ, form: form, seen_at: seen_at }
locals: { champ: champ, form: form }

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.check_box :value,
{ required: champ.mandatory },
'on',

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
.radios
%label
= form.radio_button :value, 'M.'

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.date_field :value,
value: champ.value,
placeholder: 'JJ/MM/AAAA',

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
- parsed_value = champ.value.present? ? DateTime.parse(champ.value) : DateTime.now
.datetime

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.select :value,
Champ.departements,
required: champ.mandatory

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
- dossier = Dossier.find_by(id: champ.value)
- show_text_summary = dossier.present?
- show_warning = !show_text_summary && champ.value.present?

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
- if champ.drop_down_list && champ.drop_down_list.options.any?
= form.select :value,
champ.drop_down_list.options,

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.email_field :value,
placeholder: champ.libelle,
required: champ.mandatory

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.check_box :value,
{ required: champ.mandatory },
'on',

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
- if champ.drop_down_list && champ.drop_down_list.options.any?
= form.select :value,
champ.drop_down_list.options,

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.number_field :value,
placeholder: champ.libelle,
required: champ.mandatory

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.select :value,
Champ.pays,
required: champ.mandatory

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.phone_field :value,
placeholder: champ.libelle,
required: champ.mandatory

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.select :value,
Champ.regions,
required: champ.mandatory

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.text_field :value,
placeholder: champ.libelle,
required: champ.mandatory

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
~ form.text_area :value,
row: 6,
placeholder: champ.description,

View file

@ -1,5 +1,3 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
.radios
%label
= form.radio_button :value, true

View file

@ -5,7 +5,7 @@
.messagerie.container
%ul.messages-list
- @dossier.commentaires.each do |commentaire|
%li
%li{ class: commentaire_is_from_me_class(commentaire, current_gestionnaire.email) }
= render partial: "new_gestionnaire/shared/commentaires/commentaire", locals: { commentaire: commentaire, messagerie_seen_at: @messagerie_seen_at }
= render partial: "new_gestionnaire/shared/commentaires/form", locals: { commentaire: @commentaire, form_url: commentaire_dossier_path(@dossier.procedure, @dossier) }

View file

@ -3,7 +3,7 @@
= render partial: "header", locals: { dossier: @dossier }
.container
.accompagnateur-title Identité du demandeur
.tab-title Identité du demandeur
.card
- if @dossier.entreprise.present?
= render partial: "identite_entreprise", locals: { entreprise: @dossier.entreprise }
@ -11,18 +11,18 @@
- if @dossier.individual.present?
= render partial: "identite_individual", locals: { individual: @dossier.individual }
.accompagnateur-title Formulaire
.tab-title Formulaire
- champs = @dossier.ordered_champs.includes(:type_de_champ).decorate
- if champs.any?
.card
= render partial: "champs", locals: { champs: champs, dossier: @dossier, demande_seen_at: @demande_seen_at }
- if @dossier.procedure.use_api_carto
.accompagnateur-title Cartographie
.tab-title Cartographie
.card
= render partial: "map", locals: { dossier: @dossier }
- if @dossier.procedure.cerfa_flag? || @dossier.types_de_piece_justificative.any?
.accompagnateur-title Pièces jointes
.tab-title Pièces jointes
.card
= render partial: "pieces_jointes", locals: { dossier: @dossier, demande_seen_at: @demande_seen_at }

View file

@ -1,7 +1,7 @@
- content_for(:title, "Procédures")
.container
%h1.accompagnateur-title Procédures
%h1.page-title Procédures
%ul.procedure-list
- @procedures.each do |p|

View file

@ -1,7 +1,7 @@
- content_for(:title, "Recherche : #{@search_terms}")
.container
.accompagnateur-title
.page-title
Résultat de la recherche :
= pluralize(@dossiers.count, "dossier trouvé", "dossiers trouvés")

View file

@ -0,0 +1,21 @@
require 'rails_helper'
RSpec.describe CommentaireHelper, type: :helper do
describe ".commentaire_is_from_me_class" do
let(:commentaire) { create(:commentaire, email: "michel@pref.fr") }
subject { commentaire_is_from_me_class(commentaire, me) }
context "when commentaire is from me" do
let(:me) { "michel@pref.fr" }
it { is_expected.to eq("from-me") }
end
context "when commentaire is not from me" do
let(:me) { "roger@usager.fr" }
it { is_expected.to eq nil }
end
end
end

View file

@ -283,5 +283,45 @@ describe AttestationTemplate, type: :model do
end
end
end
context "match breaking and non breaking spaces" do
before do
c = dossier.champs.first
c.value = 'valeur'
c.save
end
context "when the tag contains a non breaking space" do
let(:template_body) { 'body --mon tag--' }
context 'and the champ contains the non breaking space' do
let(:types_de_champ) { [create(:type_de_champ_public, libelle: 'mon tag')] }
it { expect(view_args[:body]).to eq('body valeur') }
end
context 'and the champ has an ordinary space' do
let(:types_de_champ) { [create(:type_de_champ_public, libelle: 'mon tag')] }
it { expect(view_args[:body]).to eq('body valeur') }
end
end
context "when the tag contains an ordinay space" do
let(:template_body) { 'body --mon tag--' }
context 'and the champ contains a non breaking space' do
let(:types_de_champ) { [create(:type_de_champ_public, libelle: 'mon tag')] }
it { expect(view_args[:body]).to eq('body valeur') }
end
context 'and the champ has an ordinary space' do
let(:types_de_champ) { [create(:type_de_champ_public, libelle: 'mon tag')] }
it { expect(view_args[:body]).to eq('body valeur') }
end
end
end
end
end

View file

@ -0,0 +1,18 @@
describe 'new_gestionnaire/dossiers/print.html.haml', type: :view do
before { view.extend DossierHelper }
context "with a dossier" do
let(:current_gestionnaire) { create(:gestionnaire) }
let(:dossier) { create(:dossier, :received) }
before do
assign(:dossier, dossier)
view.stub(:current_gestionnaire).and_return(current_gestionnaire)
render
end
it { expect(rendered).to include("Dossier nº #{dossier.id}") }
it { expect(rendered).to include(dossier.procedure.libelle) }
end
end