Merge branch 'dev'

This commit is contained in:
gregoirenovel 2017-12-14 13:42:12 +01:00
commit 98a3b9daea
18 changed files with 136 additions and 65 deletions

View file

@ -1,7 +1,5 @@
module NewGestionnaire
class AvisController < ApplicationController
layout 'new_application'
class AvisController < GestionnaireController
before_action :set_avis_and_dossier, only: [:show, :instruction, :messagerie, :create_commentaire]
A_DONNER_STATUS = 'a-donner'

View file

@ -10,8 +10,10 @@ class ProcedureDecorator < Draper::Decorator
end
def published_at_fr
if published_at.present?
published_at.localtime.strftime('%d/%m/%Y %H:%M')
end
end
def logo_img
if logo.blank?

View file

@ -0,0 +1,12 @@
module DossierLinkHelper
def dossier_linked_path(gestionnaire, dossier)
if dossier.procedure.gestionnaires.include?(gestionnaire)
dossier_path(dossier.procedure, dossier)
else
avis = dossier.avis.find_by(gestionnaire: gestionnaire)
if avis.present?
avis_path(avis)
end
end
end
end

View file

@ -14,12 +14,12 @@
- if avis.confidentiel?
%span.confidentiel
confidentiel
.icon.lock{ title: "Cet avis n'est pas affiché avec les autres experts consultés" }
%span.icon.lock{ title: "Cet avis n'est pas affiché avec les autres experts consultés" }
%span.date Demande d'avis envoyée le #{I18n.l(avis.created_at.localtime, format: '%d/%m/%y')}
%p= avis.introduction
.answer.flex.align-start
.icon.bubble.avis-icon
%span.icon.bubble.avis-icon
.width-100
%h2.gestionnaire
= (avis.email_to_display == current_gestionnaire.email) ? 'Vous' : avis.email_to_display

View file

@ -32,7 +32,7 @@
%tr
%td.number-col
= link_to(avis_path(avis), class: 'cell-link') do
.icon.folder
%span.icon.folder
#{avis.dossier.id}
%td= link_to(avis.dossier.user.email, avis_path(avis), class: 'cell-link')
%td= link_to(avis.dossier.procedure.libelle, avis_path(avis), class: 'cell-link')

View file

@ -16,7 +16,7 @@
= f.text_area :answer, rows: 3, placeholder: 'Votre avis', required: true
.flex.justify-between.align-baseline
%p.confidentiel
.icon.lock
%span.icon.lock
Cet avis est confidentiel et n'est pas affiché aux autres experts consultés
.send-wrapper
= f.submit 'Envoyer votre avis', class: 'button send'
@ -31,7 +31,7 @@
.flex.justify-between.align-baseline
- if @avis.confidentiel?
%p.confidentiel
.icon.lock
%span.icon.lock
Cet avis est confidentiel et n'est pas affiché aux autres experts consultés
.send-wrapper
= f.submit 'Demander un avis', class: 'button send'

View file

@ -21,7 +21,11 @@
%td.rich-text
- dossier = Dossier.includes(:procedure).find_by(id: c.value)
- if dossier
= link_to("Dossier nº #{dossier.id}", dossier_path(dossier.procedure, dossier), target: '_blank')
- path = dossier_linked_path(current_gestionnaire, dossier)
- if path.present?
= link_to("Dossier nº #{dossier.id}", path, target: '_blank')
- else
Dossier nº #{dossier.id}
%br
= dossier.text_summary
- else

View file

@ -8,7 +8,7 @@
= "Dossier nº #{dossier.id}"
.mixed-buttons-bar
.button.dropdown.icon-only.print-menu-opener{ onclick: "javascript:TPS.togglePrintMenu(event);" }
.icon.printer
%span.icon.printer
%ul.print-menu
%li
= link_to "Tout le dossier", print_dossier_path(dossier.procedure, dossier), target: "_blank", class: "menu-item menu-link"

View file

@ -5,13 +5,13 @@
%ul.dropdown-items
- if dossier.en_construction?
%li.selected
.icon.edit
%span.icon.edit
.description
%h4 En construction
Vous permettez à l'usager de modifier ses réponses au formulaire
%li
= link_to passer_en_instruction_dossier_path(dossier.procedure, dossier), method: :post, data: { confirm: "Confirmer vous le passage en instruction de ce dossier ?" } do
.icon.in-progress
%span.icon.in-progress
.description
%h4 Passer en instruction
L'usager ne pourra plus modifier le formulaire
@ -19,27 +19,27 @@
- if dossier.en_instruction?
%li
= link_to repasser_en_construction_dossier_path(dossier.procedure, dossier), method: :post, data: { confirm: "Confirmer vous le passage en construction de ce dossier ?" } do
.icon.edit
%span.icon.edit
.description
%h4 Repasser en construction
Vous permettrez à l'usager de modifier ses réponses au formulaire
%li.selected
.icon.in-progress
%span.icon.in-progress
.description
%h4 En instruction
L'usager ne peut modifier son dossier pendant l'instruction
%li{ onclick: "TPS.showMotivation('accept');" }
.icon.accept
%span.icon.accept
.description
%h4 Accepter
L'usager sera notifié que son dossier a été accepté
%li{ onclick: "TPS.showMotivation('without-continuation');" }
.icon.without-continuation
%span.icon.without-continuation
.description
%h4 Classer sans suite
L'usager ne recevra aucune notification
%li{ onclick: "TPS.showMotivation('refuse');" }
.icon.refuse
%span.icon.refuse
.description
%h4 Refuser
L'usager sera notifié que son dossier a été refusé

View file

@ -1,6 +1,6 @@
.motivation{ class: popup_class }
%h3
.icon{ class: popup_class }
%span.icon{ class: popup_class }
#{popup_title} nº #{dossier.id}
= form_tag(terminer_dossier_path(dossier.procedure, dossier), method: :post, class: 'form') do

View file

@ -1,19 +1,19 @@
- if dossier.en_construction_ou_instruction?
- if dossier_is_followed
= link_to unfollow_dossier_path(procedure, dossier), method: :patch, class: 'button' do
.icon.unfollow>
%span.icon.unfollow>
Ne plus suivre
- else
= link_to follow_dossier_path(procedure, dossier), method: :patch, class: 'button' do
.icon.follow>
%span.icon.follow>
Suivre le dossier
- elsif dossier.termine?
- if dossier.archived
= link_to unarchive_dossier_path(procedure, dossier), method: :patch, class: 'button' do
.icon.unarchive>
%span.icon.unarchive>
Désarchiver le dossier
- else
= link_to archive_dossier_path(procedure, dossier), method: :patch, class: 'button' do
.icon.archive>
%span.icon.archive>
Archiver le dossier

View file

@ -94,7 +94,7 @@
- @dossiers.each do |dossier|
%tr
%td.folder-col
.icon.folder
%span.icon.folder
- if current_gestionnaire.notifications_for_procedure(@procedure).include?(dossier.id)
%span.notifications{ 'aria-label': 'notifications' }

View file

@ -18,7 +18,7 @@
%tr
%td.number-col
= link_to(dossier_path(dossier.procedure, dossier), class: 'cell-link') do
.icon.folder>
%span.icon.folder>
= dossier.id
%td= link_to(dossier.procedure.libelle, dossier_path(dossier.procedure, dossier), class: 'cell-link')
%td= link_to(dossier.user.email, dossier_path(dossier.procedure, dossier), class: 'cell-link')

View file

@ -12,10 +12,10 @@
- if commentaire.piece_justificative
.attachment-link
= link_to commentaire.piece_justificative.content_url, class: "button", target: "_blank", title: "Télécharger" do
.icon.attachment
%span.icon.attachment
= commentaire.piece_justificative.original_filename
- elsif commentaire.file.present?
.attachment-link
= link_to commentaire.file_url, class: "button", target: "_blank", title: "Télécharger" do
.icon.attachment
%span.icon.attachment
= commentaire.file_identifier

View file

@ -2,20 +2,20 @@
.container
%h1 Icones
.icon.follow
.icon.unfollow
.icon.archive
.icon.unarchive
.icon.folder
.icon.accept
.icon.refuse
.icon.without-continuation
.icon.edit
.icon.in-progress
.icon.bubble
.icon.attachment
.icon.lock
.icon.printer
%span.icon.follow
%span.icon.unfollow
%span.icon.archive
%span.icon.unarchive
%span.icon.folder
%span.icon.accept
%span.icon.refuse
%span.icon.without-continuation
%span.icon.edit
%span.icon.in-progress
%span.icon.bubble
%span.icon.attachment
%span.icon.lock
%span.icon.printer
%h1 Formulaires
@ -42,23 +42,18 @@
= link_to ".button.accepted", "#", class: "button accepted"
= link_to "#", class: "button" do
%span.icon.follow
= "Bouton avec icone et texte"
= link_to "#", class: "button icon-only" do
%span.icon.follow
%p
= link_to ".button.large", "#", class: "button large"
= link_to ".button.large.primary", "#", class: "button large primary"
%p
= link_to "#", class: "button" do
.icon.follow
= ".icon.follow"
= link_to "#", class: "button" do
.icon.unfollow
= ".icon.unfollow"
= link_to "#", class: "button" do
.icon.archive
= ".icon.archive"
= link_to "#", class: "button" do
.icon.unarchive
= ".icon.unarchive"
%p
= link_to ".button.primary.expand", "#", class: "button primary expand"

View file

@ -1,7 +1,10 @@
require 'spec_helper'
describe ProcedureDecorator do
let(:procedure) { create(:procedure, :published, created_at: Time.new(2015, 12, 24, 14, 10)) }
let(:published_at) { Time.new(2017, 12, 24, 14, 12) }
let(:procedure) { create(:procedure, published_at: published_at, created_at: Time.new(2015, 12, 24, 14, 10)) }
let!(:procedure_path) { create(:procedure_path, administrateur: create(:administrateur), procedure: procedure) }
subject { procedure.decorate }
describe 'lien' do
@ -14,6 +17,16 @@ describe ProcedureDecorator do
it { is_expected.to eq('24/12/2015 14:10') }
end
describe 'published_at_fr' do
subject { super().published_at_fr }
it { is_expected.to eq('24/12/2017 14:12') }
context 'published_at is nil' do
let(:published_at) { nil }
it { is_expected.to eq(nil) }
end
end
describe 'logo_img' do
subject { super().logo_img }
it { is_expected.to match(/http.*#{ActionController::Base.helpers.image_url(LOGO_NAME)}/) }

View file

@ -0,0 +1,27 @@
describe DossierLinkHelper do
describe "#dossier_linked_path" do
context "when no access" do
let(:gestionnaire) { create(:gestionnaire) }
let(:dossier) { create(:dossier) }
it { expect(helper.dossier_linked_path(gestionnaire, dossier)).to be_nil }
end
context "when access as gestionnaire" do
let(:dossier) { create(:dossier ) }
let(:gestionnaire) { create(:gestionnaire) }
before { dossier.procedure.gestionnaires << gestionnaire }
it { expect(helper.dossier_linked_path(gestionnaire, dossier)).to eq(dossier_path(dossier.procedure, dossier)) }
end
context "when access as expert" do
let(:dossier) { create(:dossier ) }
let(:gestionnaire) { create(:gestionnaire) }
let!(:avis) { create(:avis, dossier: dossier, gestionnaire: gestionnaire) }
it { expect(helper.dossier_linked_path(gestionnaire, dossier)).to eq(avis_path(avis)) }
end
end
end

View file

@ -1,31 +1,51 @@
describe 'new_gestionnaire/dossiers/champs.html.haml', type: :view do
before { render 'new_gestionnaire/dossiers/champs.html.haml', champs: champs }
let(:gestionnaire) { create(:gestionnaire) }
before do
view.extend DossierLinkHelper
allow(view).to receive(:current_gestionnaire).and_return(gestionnaire)
end
subject { render 'new_gestionnaire/dossiers/champs.html.haml', champs: champs }
context "there are some champs" do
let(:dossier) { create(:dossier) }
let(:avis) { create :avis, dossier: dossier, gestionnaire: gestionnaire }
let(:champ1) { create(:champ, :checkbox, value: "true") }
let(:champ2) { create(:champ, :header_section, value: "Section") }
let(:champ3) { create(:champ, :explication, value: "mazette") }
let(:champ4) { create(:champ, :dossier_link, value: dossier.id) }
let(:champs) { [champ1, champ2, champ3, champ4] }
it { expect(rendered).to include(champ1.libelle) }
it { expect(rendered).to include(champ1.value) }
before { dossier.avis << avis }
it { expect(rendered).to have_css(".header-section") }
it { expect(rendered).to include(champ2.libelle) }
it { is_expected.to include(champ1.libelle) }
it { is_expected.to include(champ1.value) }
it { expect(rendered).not_to include(champ3.libelle) }
it { expect(rendered).not_to include(champ3.value) }
it { is_expected.to have_css(".header-section") }
it { is_expected.to include(champ2.libelle) }
it { expect(rendered).to have_link("Dossier nº #{dossier.id}") }
it { expect(rendered).to include(dossier.text_summary) }
it { is_expected.not_to include(champ3.libelle) }
it { is_expected.not_to include(champ3.value) }
it { is_expected.to have_link("Dossier nº #{dossier.id}") }
it { is_expected.to include(dossier.text_summary) }
end
context "with a dossier champ, but we are not authorized to acces the dossier" do
let(:dossier) { create(:dossier) }
let(:champ) { create(:champ, :dossier_link, value: dossier.id) }
let(:champs) { [champ] }
it { is_expected.not_to have_link("Dossier nº #{dossier.id}") }
it { is_expected.to include("Dossier nº #{dossier.id}") }
it { is_expected.to include(dossier.text_summary) }
end
context "with a dossier_link champ but without value" do
let(:champ) { create(:champ, :dossier_link, value: nil) }
let(:champs) { [champ] }
it { expect(rendered).to include("Pas de dossier associé") }
it { is_expected.to include("Pas de dossier associé") }
end
end