help: add a custom help dropdown in dossier context
This commit is contained in:
parent
ce9c5da6e1
commit
549b17f75e
8 changed files with 219 additions and 3 deletions
51
app/assets/stylesheets/new_design/help_dropdown.scss
Normal file
51
app/assets/stylesheets/new_design/help_dropdown.scss
Normal file
|
@ -0,0 +1,51 @@
|
|||
@import "colors";
|
||||
@import "constants";
|
||||
|
||||
.help-dropdown {
|
||||
.dropdown-content {
|
||||
width: 340px;
|
||||
}
|
||||
|
||||
.dropdown-description {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
h4.help-dropdown-title {
|
||||
font-size: 16px;
|
||||
color: $blue;
|
||||
}
|
||||
|
||||
.dropdown-items li.help-dropdown-service {
|
||||
cursor: default;
|
||||
|
||||
&:hover {
|
||||
background: inherit;
|
||||
}
|
||||
|
||||
a {
|
||||
display: inline;
|
||||
color: $blue;
|
||||
}
|
||||
}
|
||||
|
||||
.help-dropdown-service-action {
|
||||
margin-top: $default-padding;
|
||||
margin-bottom: $default-spacer;
|
||||
}
|
||||
|
||||
.help-dropdown-service-item {
|
||||
margin-top: $default-spacer;
|
||||
line-height: 18px;
|
||||
|
||||
.icon {
|
||||
vertical-align: middle;
|
||||
margin-right: 5px;
|
||||
|
||||
&.clock {
|
||||
filter: contrast(0) brightness(120%);
|
||||
vertical-align: -4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -240,6 +240,11 @@ module NewUser
|
|||
flash.notice = 'La pièce jointe a bien été supprimée.'
|
||||
end
|
||||
|
||||
def dossier_for_help
|
||||
dossier_id = params[:id] || params[:dossier_id]
|
||||
@dossier || (dossier_id.present? && Dossier.find_by(id: dossier_id.to_i))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def store_user_location!
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/ We can't use &. because the controller may not implement #nav_bar_profile
|
||||
-# We can't use &. because the controller may not implement #nav_bar_profile
|
||||
- nav_bar_profile = controller.try(:nav_bar_profile)
|
||||
- dossier = controller.try(:dossier_for_help)
|
||||
|
||||
.new-header{ class: current_page?(root_path) ? nil : "new-header-with-border" }
|
||||
.header-inner-content
|
||||
|
@ -95,4 +96,7 @@
|
|||
|
||||
%li
|
||||
.header-help
|
||||
= link_to 'Aide', FAQ_URL, class: "button primary", target: "_blank", rel: "noopener"
|
||||
- if nav_bar_profile == :user && dossier.present?
|
||||
= render partial: 'new_user/dossier_help_dropdown', locals: { dossier: dossier }
|
||||
- else
|
||||
= link_to 'Aide', FAQ_URL, class: "button primary"
|
||||
|
|
42
app/views/new_user/_dossier_help_dropdown.html.haml
Normal file
42
app/views/new_user/_dossier_help_dropdown.html.haml
Normal file
|
@ -0,0 +1,42 @@
|
|||
.dropdown.help-dropdown
|
||||
.button.primary.dropdown-button Aide
|
||||
.dropdown-content.fade-in-down
|
||||
%ul.dropdown-items
|
||||
|
||||
- title = dossier.brouillon? ? "Besoin d’aide pour remplir votre dossier ?" : "Une question sur votre dossier ?"
|
||||
|
||||
- if dossier.messagerie_available?
|
||||
-# Contact the administration using the messagerie
|
||||
%li
|
||||
= link_to messagerie_dossier_path(dossier) do
|
||||
%span.icon.mail
|
||||
.dropdown-description
|
||||
%h4.help-dropdown-title= title
|
||||
%p Envoyez directement un message à l’instructeur.
|
||||
|
||||
- elsif dossier.procedure.service.present?
|
||||
- service = dossier.procedure.service
|
||||
-# Contact the administration using email or phone
|
||||
%li.help-dropdown-service
|
||||
%span.icon.person
|
||||
.dropdown-description
|
||||
%h4.help-dropdown-title= title
|
||||
.help-dropdown-service-action
|
||||
%p Contactez directement l’administration :
|
||||
%p.help-dropdown-service-item
|
||||
%span.icon.small.mail
|
||||
= link_to service.email, "mailto:#{service.email}"
|
||||
%p.help-dropdown-service-item
|
||||
%span.icon.small.phone
|
||||
= link_to service.telephone, "tel:#{service.telephone}"
|
||||
%p.help-dropdown-service-item
|
||||
%span.icon.small.clock
|
||||
= service.horaires
|
||||
|
||||
-# Use the help website
|
||||
%li
|
||||
= link_to FAQ_URL, target: "_blank", rel: "noopener" do
|
||||
%span.icon.help
|
||||
.dropdown-description
|
||||
%h4.help-dropdown-title Un problème avec le site ?
|
||||
%p Trouvez votre réponse dans l’aide en ligne.
|
|
@ -952,4 +952,30 @@ describe NewUser::DossiersController, type: :controller do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#dossier_for_help" do
|
||||
before do
|
||||
sign_in(user)
|
||||
controller.params[:dossier_id] = dossier_id.to_s
|
||||
end
|
||||
|
||||
subject { controller.dossier_for_help }
|
||||
|
||||
context 'when the id matches an existing dossier' do
|
||||
let(:dossier) { create(:dossier) }
|
||||
let(:dossier_id) { dossier.id }
|
||||
|
||||
it { is_expected.to eq dossier }
|
||||
end
|
||||
|
||||
context 'when the id doesn’t match an existing dossier' do
|
||||
let(:dossier_id) { 9999999 }
|
||||
it { is_expected.to be nil }
|
||||
end
|
||||
|
||||
context 'when the id is empty' do
|
||||
let(:dossier_id) { nil }
|
||||
it { is_expected.to be_falsy }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
84
spec/features/help_spec.rb
Normal file
84
spec/features/help_spec.rb
Normal file
|
@ -0,0 +1,84 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'Getting help:' do
|
||||
scenario 'a Help button is visible on public pages' do
|
||||
visit '/'
|
||||
within('.new-header') do
|
||||
expect(page).to have_help_button
|
||||
end
|
||||
end
|
||||
|
||||
context 'as a signed-in user' do
|
||||
let(:user) { create(:user) }
|
||||
let(:procedure) { create(:procedure, :with_service) }
|
||||
|
||||
before do
|
||||
login_as user, scope: :user
|
||||
end
|
||||
|
||||
scenario 'a Help button is visible on signed-in pages' do
|
||||
visit dossiers_path
|
||||
within('.new-header') do
|
||||
expect(page).to have_help_button
|
||||
end
|
||||
end
|
||||
|
||||
context 'on a page related to a draft dossier' do
|
||||
let(:dossier) { create(:dossier, user: user, procedure: procedure) }
|
||||
|
||||
scenario 'a Help menu provides administration contacts and a link to the FAQ' do
|
||||
visit dossier_path(dossier)
|
||||
|
||||
within('.new-header') do
|
||||
expect(page).to have_help_menu
|
||||
end
|
||||
|
||||
within('.help-dropdown') do
|
||||
expect(page).to have_content(dossier.procedure.service.email)
|
||||
expect(page).to have_content(dossier.procedure.service.telephone)
|
||||
expect(page).to have_link(nil, href: FAQ_URL)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'on a page related to a submitted dossier' do
|
||||
let(:dossier) { create(:dossier, :en_construction, user: user, procedure: procedure) }
|
||||
|
||||
scenario 'a Help menu provides links to the Messagerie and to the FAQ' do
|
||||
visit dossier_path(dossier)
|
||||
|
||||
within('.new-header') do
|
||||
expect(page).to have_help_menu
|
||||
end
|
||||
|
||||
within('.help-dropdown') do
|
||||
expect(page).to have_link(nil, href: messagerie_dossier_path(dossier))
|
||||
expect(page).to have_link(nil, href: FAQ_URL)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'as a gestionnaire' do
|
||||
let(:gestionnaire) { create(:gestionnaire) }
|
||||
|
||||
before do
|
||||
login_as gestionnaire, scope: :gestionnaire
|
||||
end
|
||||
|
||||
scenario 'a Help button is visible on signed-in pages' do
|
||||
visit gestionnaire_procedures_path
|
||||
within('.new-header') do
|
||||
expect(page).to have_help_button
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def have_help_button
|
||||
have_link('Aide', href: FAQ_URL)
|
||||
end
|
||||
|
||||
def have_help_menu
|
||||
have_selector('.help-dropdown')
|
||||
end
|
||||
end
|
|
@ -54,7 +54,7 @@ feature 'The gestionnaire part' do
|
|||
|
||||
click_on 'En instruction'
|
||||
|
||||
within('.dropdown-items') do
|
||||
within('.state-button') do
|
||||
click_on 'Accepter'
|
||||
end
|
||||
|
||||
|
|
|
@ -16,6 +16,10 @@ describe 'layouts/_new_header.html.haml', type: :view do
|
|||
|
||||
it { is_expected.to have_css("a.header-logo[href=\"#{dossiers_path}\"]") }
|
||||
it { is_expected.to have_link("Dossiers", href: dossiers_path) }
|
||||
|
||||
it 'displays the Help button' do
|
||||
expect(subject).to have_link("Aide", href: FAQ_URL)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when rendering for gestionnaire' do
|
||||
|
|
Loading…
Reference in a new issue