Merge pull request #8894 from demarches-simplifiees/user-dashboard/add-alert-WIP-last-dossier
[refonte usager] Tableau de bord - Ajouter continuer à remplir dernier dossier
This commit is contained in:
commit
ae840de44a
12 changed files with 60 additions and 8 deletions
|
@ -4,13 +4,14 @@ class Dsfr::CalloutComponent < ApplicationComponent
|
|||
renders_one :html_body
|
||||
renders_one :bottom
|
||||
|
||||
attr_reader :title, :theme, :icon, :extra_class_names
|
||||
attr_reader :title, :theme, :icon, :extra_class_names, :heading_level
|
||||
|
||||
def initialize(title:, theme: :info, icon: nil, extra_class_names: nil)
|
||||
def initialize(title:, theme: :info, icon: nil, extra_class_names: nil, heading_level: 'h3')
|
||||
@title = title
|
||||
@theme = theme
|
||||
@icon = icon
|
||||
@extra_class_names = extra_class_names
|
||||
@heading_level = heading_level
|
||||
end
|
||||
|
||||
def callout_class
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
%div{ class: callout_class }
|
||||
- if title.present?
|
||||
%h3.fr-callout__title= title
|
||||
= content_tag(heading_level, class: 'fr-callout__title') do
|
||||
= title
|
||||
- if html_body?
|
||||
.fr-callout__text= html_body
|
||||
- if body?
|
||||
|
|
|
@ -28,6 +28,8 @@ module Users
|
|||
@dossiers_supprimes_definitivement = current_user.deleted_dossiers.order_by_updated_at.page(page)
|
||||
@dossier_transfers = DossierTransfer.for_email(current_user.email).page(page)
|
||||
@statut = statut(@user_dossiers, @dossiers_traites, @dossiers_invites, @dossiers_supprimes_recemment, @dossiers_supprimes_definitivement, @dossier_transfers, @dossiers_close_to_expiration, params[:statut])
|
||||
|
||||
@first_brouillon_recently_updated = current_user.dossiers.visible_by_user.brouillons_recently_updated.first
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
@ -296,6 +296,8 @@ class Dossier < ApplicationRecord
|
|||
champs: [:type_de_champ, piece_justificative_file_attachments: :blob]
|
||||
])
|
||||
}
|
||||
|
||||
scope :brouillons_recently_updated, -> { updated_since(2.days.ago).state_brouillon.order_by_updated_at }
|
||||
scope :with_annotations, -> {
|
||||
includes(champs_private: [
|
||||
:type_de_champ,
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
.dossiers-headers.sub-header
|
||||
.container
|
||||
%h1.page-title= t('views.users.dossiers.index.dossiers')
|
||||
%h1.page-title.fr-h2= t('views.users.dossiers.index.dossiers')
|
||||
- if current_user.dossiers.count > 2
|
||||
#search-2.fr-search-bar.fr-search-bar--lg{ role: "search", "aria-label": t('views.users.dossiers.search.search_file') }
|
||||
= form_tag recherche_dossiers_path, method: :get, :role => "search", class: "flex width-100 fr-mb-5w" do
|
||||
|
@ -69,6 +69,13 @@
|
|||
|
||||
- else
|
||||
- if @statut == "en-cours"
|
||||
- if @first_brouillon_recently_updated.present?
|
||||
= render Dsfr::CalloutComponent.new(title: t('users.dossiers.header.callout.first_brouillon_recently_updated_title'), heading_level: 'h2') do |c|
|
||||
- c.with_body do
|
||||
%p
|
||||
= t('users.dossiers.header.callout.first_brouillon_recently_updated_text', time_ago: time_ago_in_words(@first_brouillon_recently_updated.created_at), libelle: @first_brouillon_recently_updated.procedure.libelle )
|
||||
= link_to t('users.dossiers.header.callout.first_brouillon_recently_updated_button'), modifier_dossier_path(@first_brouillon_recently_updated), class: 'fr-btn'
|
||||
|
||||
= render partial: "dossiers_list", locals: { dossiers: @user_dossiers }
|
||||
|
||||
- if @statut == "traites"
|
||||
|
|
|
@ -447,7 +447,7 @@ en:
|
|||
simple: Search
|
||||
secondary_menu: Secondary menu
|
||||
index:
|
||||
dossiers: "Files"
|
||||
dossiers: "My files"
|
||||
dossiers_list:
|
||||
caption: My files
|
||||
procedure: "Procedure"
|
||||
|
|
|
@ -448,7 +448,7 @@ fr:
|
|||
simple: Rechercher
|
||||
secondary_menu: Menu secondaire
|
||||
index:
|
||||
dossiers: "Dossiers"
|
||||
dossiers: "Mes dossiers"
|
||||
dossiers_list:
|
||||
caption: Mes dossiers
|
||||
procedure: "Démarche"
|
||||
|
|
|
@ -19,3 +19,7 @@ en:
|
|||
button_delay_expiration:
|
||||
one: "Keep for %{count} more month"
|
||||
other: "Keep for %{count} more months"
|
||||
callout:
|
||||
first_brouillon_recently_updated_title: You already started to fill a file
|
||||
first_brouillon_recently_updated_text: "%{time_ago} ago you started to fill a file on « %{libelle} » procedure."
|
||||
first_brouillon_recently_updated_button: Keep filling this file
|
||||
|
|
|
@ -19,3 +19,7 @@ fr:
|
|||
button_delay_expiration:
|
||||
one: "Conserver %{count} mois supplémentaire"
|
||||
other: "Conserver %{count} mois supplémentaires"
|
||||
callout:
|
||||
first_brouillon_recently_updated_title: Vous avez déjà commencé à remplir un dossier
|
||||
first_brouillon_recently_updated_text: Il y a %{time_ago} vous avez commencé à remplir un dossier sur la démarche « %{libelle} ».
|
||||
first_brouillon_recently_updated_button: Continuer à remplir
|
||||
|
|
|
@ -795,6 +795,15 @@ describe Users::DossiersController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when the user has dossier in brouillon recently updated' do
|
||||
let!(:own_dossier) { create(:dossier, user: user) }
|
||||
let!(:own_dossier_2) { create(:dossier, user: user) }
|
||||
|
||||
before { get(:index) }
|
||||
|
||||
it { expect(assigns(:first_brouillon_recently_updated)).to match(own_dossier_2) }
|
||||
end
|
||||
|
||||
describe 'sort order' do
|
||||
before do
|
||||
Timecop.freeze(4.days.ago) { create(:dossier, user: user) }
|
||||
|
|
|
@ -18,6 +18,13 @@ describe Dossier do
|
|||
|
||||
it { expect(Dossier.without_followers.to_a).to eq([dossier_without_follower]) }
|
||||
end
|
||||
|
||||
describe 'brouillons_recently_updated' do
|
||||
let!(:dossier_en_brouillon) { create(:dossier) }
|
||||
let!(:dossier_en_brouillon_2) { create(:dossier) }
|
||||
|
||||
it { expect(Dossier.brouillons_recently_updated).to eq([dossier_en_brouillon_2, dossier_en_brouillon]) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'validations' do
|
||||
|
|
|
@ -36,6 +36,21 @@ describe 'users/dossiers/index.html.haml', type: :view do
|
|||
expect(rendered).to have_link(dossier_en_construction.id.to_s, href: dossier_path(dossier_en_construction))
|
||||
end
|
||||
|
||||
it 'n’affiche pas une alerte pour continuer à remplir un dossier' do
|
||||
expect(rendered).not_to have_selector('.fr-callout', count: 1)
|
||||
end
|
||||
|
||||
context 'quand il y a un dossier en brouillon récemment mis à jour' do
|
||||
before do
|
||||
assign(:first_brouillon_recently_updated, dossier_brouillon)
|
||||
render
|
||||
end
|
||||
it 'affiche une alerte pour continuer à remplir un dossier' do
|
||||
expect(rendered).to have_selector('.fr-callout', count: 1)
|
||||
expect(rendered).to have_link(href: modifier_dossier_path(dossier_brouillon))
|
||||
end
|
||||
end
|
||||
|
||||
context 'quand il n’y a aucun dossier' do
|
||||
let(:user_dossiers) { [] }
|
||||
let(:dossiers_invites) { [] }
|
||||
|
@ -53,7 +68,7 @@ describe 'users/dossiers/index.html.haml', type: :view do
|
|||
let(:dossiers_invites) { [] }
|
||||
|
||||
it 'affiche un titre adapté' do
|
||||
expect(rendered).to have_selector('h1', text: 'Dossiers')
|
||||
expect(rendered).to have_selector('h1', text: 'Mes dossiers')
|
||||
end
|
||||
|
||||
it 'n’affiche la barre d’onglets' do
|
||||
|
@ -65,7 +80,7 @@ describe 'users/dossiers/index.html.haml', type: :view do
|
|||
let(:dossiers_invites) { create_list(:dossier, 1) }
|
||||
|
||||
it 'affiche un titre adapté' do
|
||||
expect(rendered).to have_selector('h1', text: 'Dossiers')
|
||||
expect(rendered).to have_selector('h1', text: 'Mes dossiers')
|
||||
end
|
||||
|
||||
it 'affiche la barre d’onglets' do
|
||||
|
|
Loading…
Add table
Reference in a new issue