Merge pull request #2199 from betagouv/new-dossiers-list-fixup

Petits correctifs sur la liste des dossiers
This commit is contained in:
gregoirenovel 2018-07-04 12:06:47 +02:00 committed by GitHub
commit b76aa95eed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 23 deletions

View file

@ -7,6 +7,20 @@ module NewUser
before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update] before_action :ensure_dossier_can_be_updated, only: [:update_identite, :update]
before_action :forbid_invite_submission!, only: [:update] before_action :forbid_invite_submission!, only: [:update]
def index
@user_dossiers = current_user.dossiers.includes(:procedure).order_by_updated_at.page(page)
@dossiers_invites = current_user.dossiers_invites.includes(:procedure).order_by_updated_at.page(page)
@current_tab = current_tab(@user_dossiers.count, @dossiers_invites.count)
@dossiers = case @current_tab
when 'mes-dossiers'
@user_dossiers
when 'dossiers-invites'
@dossiers_invites
end
end
def attestation def attestation
send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf') send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
end end
@ -87,20 +101,6 @@ module NewUser
@dossier = current_user.dossiers.includes(:procedure).find(params[:id]) @dossier = current_user.dossiers.includes(:procedure).find(params[:id])
end end
def index
@user_dossiers = current_user.dossiers.includes(:procedure).order_by_updated_at.page(page)
@dossiers_invites = current_user.dossiers_invites.includes(:procedure).order_by_updated_at.page(page)
@current_tab = current_tab(@user_dossiers.count, @dossiers_invites.count)
@dossiers = case @current_tab
when 'mes-dossiers'
@user_dossiers
when 'dossiers-invites'
@dossiers_invites
end
end
def ask_deletion def ask_deletion
dossier = current_user.dossiers.includes(:user, procedure: :administrateur).find(params[:id]) dossier = current_user.dossiers.includes(:user, procedure: :administrateur).find(params[:id])

View file

@ -16,9 +16,7 @@ module DossierHelper
end end
def url_for_dossier(dossier) def url_for_dossier(dossier)
if dossier.kind_of? Invite if dossier.brouillon?
users_dossiers_invite_path(id: dossier.id)
elsif dossier.brouillon?
modifier_dossier_path(dossier) modifier_dossier_path(dossier)
else else
users_dossier_recapitulatif_path(dossier) users_dossier_recapitulatif_path(dossier)

View file

@ -56,5 +56,5 @@
- else - else
.dossiers-table-empty .dossiers-table-empty
%h2.empty-text Aucun dossier. %h2.empty-text Aucun dossier.
%p.empty-text-details Pour linstant vous navez commencé aucune démarche. %p.empty-text-details Vous navez pas encore commencé de démarche.
= link_to "Commencer une nouvelle démarche", new_demarche_url, class: "button primary" = link_to "Commencer une nouvelle démarche", new_demarche_url, class: "button primary"

View file

@ -29,11 +29,6 @@ RSpec.describe DossierHelper, type: :helper do
describe ".url_for_dossier" do describe ".url_for_dossier" do
subject { url_for_dossier(dossier) } subject { url_for_dossier(dossier) }
context "when the dossier is an invitation" do
let(:dossier) { create(:invite) }
it { is_expected.to eq "/users/dossiers/invites/#{dossier.id}" }
end
context "when the dossier is in the brouillon state" do context "when the dossier is in the brouillon state" do
let(:dossier) { create(:dossier, state: 'brouillon') } let(:dossier) { create(:dossier, state: 'brouillon') }
it { is_expected.to eq "/dossiers/#{dossier.id}/modifier" } it { is_expected.to eq "/dossiers/#{dossier.id}/modifier" }