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 :html_body
|
||||||
renders_one :bottom
|
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
|
@title = title
|
||||||
@theme = theme
|
@theme = theme
|
||||||
@icon = icon
|
@icon = icon
|
||||||
@extra_class_names = extra_class_names
|
@extra_class_names = extra_class_names
|
||||||
|
@heading_level = heading_level
|
||||||
end
|
end
|
||||||
|
|
||||||
def callout_class
|
def callout_class
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
%div{ class: callout_class }
|
%div{ class: callout_class }
|
||||||
- if title.present?
|
- if title.present?
|
||||||
%h3.fr-callout__title= title
|
= content_tag(heading_level, class: 'fr-callout__title') do
|
||||||
|
= title
|
||||||
- if html_body?
|
- if html_body?
|
||||||
.fr-callout__text= html_body
|
.fr-callout__text= html_body
|
||||||
- if body?
|
- if body?
|
||||||
|
|
|
@ -28,6 +28,8 @@ module Users
|
||||||
@dossiers_supprimes_definitivement = current_user.deleted_dossiers.order_by_updated_at.page(page)
|
@dossiers_supprimes_definitivement = current_user.deleted_dossiers.order_by_updated_at.page(page)
|
||||||
@dossier_transfers = DossierTransfer.for_email(current_user.email).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])
|
@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
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|
|
@ -296,6 +296,8 @@ class Dossier < ApplicationRecord
|
||||||
champs: [:type_de_champ, piece_justificative_file_attachments: :blob]
|
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, -> {
|
scope :with_annotations, -> {
|
||||||
includes(champs_private: [
|
includes(champs_private: [
|
||||||
:type_de_champ,
|
:type_de_champ,
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
.dossiers-headers.sub-header
|
.dossiers-headers.sub-header
|
||||||
.container
|
.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
|
- 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') }
|
#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
|
= form_tag recherche_dossiers_path, method: :get, :role => "search", class: "flex width-100 fr-mb-5w" do
|
||||||
|
@ -69,6 +69,13 @@
|
||||||
|
|
||||||
- else
|
- else
|
||||||
- if @statut == "en-cours"
|
- 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 }
|
= render partial: "dossiers_list", locals: { dossiers: @user_dossiers }
|
||||||
|
|
||||||
- if @statut == "traites"
|
- if @statut == "traites"
|
||||||
|
|
|
@ -447,7 +447,7 @@ en:
|
||||||
simple: Search
|
simple: Search
|
||||||
secondary_menu: Secondary menu
|
secondary_menu: Secondary menu
|
||||||
index:
|
index:
|
||||||
dossiers: "Files"
|
dossiers: "My files"
|
||||||
dossiers_list:
|
dossiers_list:
|
||||||
caption: My files
|
caption: My files
|
||||||
procedure: "Procedure"
|
procedure: "Procedure"
|
||||||
|
|
|
@ -448,7 +448,7 @@ fr:
|
||||||
simple: Rechercher
|
simple: Rechercher
|
||||||
secondary_menu: Menu secondaire
|
secondary_menu: Menu secondaire
|
||||||
index:
|
index:
|
||||||
dossiers: "Dossiers"
|
dossiers: "Mes dossiers"
|
||||||
dossiers_list:
|
dossiers_list:
|
||||||
caption: Mes dossiers
|
caption: Mes dossiers
|
||||||
procedure: "Démarche"
|
procedure: "Démarche"
|
||||||
|
|
|
@ -19,3 +19,7 @@ en:
|
||||||
button_delay_expiration:
|
button_delay_expiration:
|
||||||
one: "Keep for %{count} more month"
|
one: "Keep for %{count} more month"
|
||||||
other: "Keep for %{count} more months"
|
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:
|
button_delay_expiration:
|
||||||
one: "Conserver %{count} mois supplémentaire"
|
one: "Conserver %{count} mois supplémentaire"
|
||||||
other: "Conserver %{count} mois supplémentaires"
|
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
|
||||||
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
|
describe 'sort order' do
|
||||||
before do
|
before do
|
||||||
Timecop.freeze(4.days.ago) { create(:dossier, user: user) }
|
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]) }
|
it { expect(Dossier.without_followers.to_a).to eq([dossier_without_follower]) }
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe 'validations' do
|
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))
|
expect(rendered).to have_link(dossier_en_construction.id.to_s, href: dossier_path(dossier_en_construction))
|
||||||
end
|
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
|
context 'quand il n’y a aucun dossier' do
|
||||||
let(:user_dossiers) { [] }
|
let(:user_dossiers) { [] }
|
||||||
let(:dossiers_invites) { [] }
|
let(:dossiers_invites) { [] }
|
||||||
|
@ -53,7 +68,7 @@ describe 'users/dossiers/index.html.haml', type: :view do
|
||||||
let(:dossiers_invites) { [] }
|
let(:dossiers_invites) { [] }
|
||||||
|
|
||||||
it 'affiche un titre adapté' do
|
it 'affiche un titre adapté' do
|
||||||
expect(rendered).to have_selector('h1', text: 'Dossiers')
|
expect(rendered).to have_selector('h1', text: 'Mes dossiers')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'n’affiche la barre d’onglets' do
|
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) }
|
let(:dossiers_invites) { create_list(:dossier, 1) }
|
||||||
|
|
||||||
it 'affiche un titre adapté' do
|
it 'affiche un titre adapté' do
|
||||||
expect(rendered).to have_selector('h1', text: 'Dossiers')
|
expect(rendered).to have_selector('h1', text: 'Mes dossiers')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'affiche la barre d’onglets' do
|
it 'affiche la barre d’onglets' do
|
||||||
|
|
Loading…
Reference in a new issue