add a new tab traités on user dossiers

This commit is contained in:
kara Diaby 2021-11-10 17:36:24 +01:00 committed by Kara Diaby
parent a91960bd4f
commit eaac293da3
5 changed files with 53 additions and 22 deletions

View file

@ -16,7 +16,8 @@ module Users
before_action :store_user_location!, only: :new
def index
@user_dossiers = current_user.dossiers.includes(:procedure).order_by_updated_at.page(page)
@user_dossiers = current_user.dossiers.includes(:procedure).not_termine.order_by_updated_at.page(page)
@dossiers_traites = current_user.dossiers.includes(:procedure).termine.not_hidden_by_user.order_by_updated_at.page(page)
@dossiers_invites = current_user.dossiers_invites.includes(:procedure).order_by_updated_at.page(page)
@dossiers_supprimes = current_user.deleted_dossiers.order_by_updated_at.page(page)
@dossier_transfers = DossierTransfer
@ -25,7 +26,7 @@ module Users
.where(email: current_user.email)
.page(page)
@dossiers_close_to_expiration = current_user.dossiers.close_to_expiration.page(page)
@statut = statut(@user_dossiers, @dossiers_invites, @dossiers_supprimes, @dossier_transfers, @dossiers_close_to_expiration, params[:statut])
@statut = statut(@user_dossiers, @dossiers_traites, @dossiers_invites, @dossiers_supprimes, @dossier_transfers, @dossiers_close_to_expiration, params[:statut])
end
def show
@ -287,14 +288,22 @@ module Users
@transfer = DossierTransfer.new(dossiers: current_user.dossiers)
end
def hide_dossier
dossier = current_user.dossiers.includes(:user, procedure: :administrateurs).find(params[:id])
dossier.update(hidden_by_user_at: Time.zone.now)
flash.notice = t('users.dossiers.ask_deletion.deleted_dossier')
redirect_to dossiers_path
end
private
# if the status tab is filled, then this tab
# else first filled tab
# else mes-dossiers
def statut(mes_dossiers, dossiers_invites, dossiers_supprimes, dossier_transfers, dossiers_close_to_expiration, params_statut)
# else en-cours
def statut(mes_dossiers, dossiers_traites, dossiers_invites, dossiers_supprimes, dossier_transfers, dossiers_close_to_expiration, params_statut)
tabs = {
'mes-dossiers' => mes_dossiers.present?,
'en-cours' => mes_dossiers.present?,
'traites' => dossiers_traites.present?,
'dossiers-invites' => dossiers_invites.present?,
'dossiers-supprimes' => dossiers_supprimes.present?,
'dossiers-transferes' => dossier_transfers.present?,
@ -306,7 +315,7 @@ module Users
tabs
.filter { |_tab, filled| filled }
.map { |tab, _| tab }
.first || 'mes-dossiers'
.first || 'en-cours'
end
end

View file

@ -16,6 +16,7 @@
# en_instruction_at :datetime
# groupe_instructeur_updated_at :datetime
# hidden_at :datetime
# hidden_by_user_at :datetime
# identity_updated_at :datetime
# last_avis_updated_at :datetime
# last_champ_private_updated_at :datetime
@ -206,9 +207,11 @@ class Dossier < ApplicationRecord
scope :state_en_construction_ou_instruction, -> { where(state: EN_CONSTRUCTION_OU_INSTRUCTION) }
scope :state_instruction_commencee, -> { where(state: INSTRUCTION_COMMENCEE) }
scope :state_termine, -> { where(state: TERMINE) }
scope :state_not_termine, -> { where.not(state: TERMINE) }
scope :archived, -> { where(archived: true) }
scope :not_archived, -> { where(archived: false) }
scope :not_hidden_by_user, -> { where(hidden_by_user_at: nil) }
scope :order_by_updated_at, -> (order = :desc) { order(updated_at: order) }
scope :order_by_created_at, -> (order = :asc) { order(en_construction_at: order, created_at: order, id: order) }
@ -229,6 +232,7 @@ class Dossier < ApplicationRecord
scope :en_construction, -> { not_archived.state_en_construction }
scope :en_instruction, -> { not_archived.state_en_instruction }
scope :termine, -> { not_archived.state_termine }
scope :not_termine, -> { state_not_termine }
scope :processed_in_month, -> (month) do
state_termine
.joins(:traitements)
@ -1091,6 +1095,10 @@ class Dossier < ApplicationRecord
end
end
def hidden_by_user?
self.hidden_by_user_at.present?
end
private
def create_missing_traitemets

View file

@ -15,25 +15,31 @@
- else
%h1.page-title= t('views.users.dossiers.index.dossiers')
%ul.tabs
- if @user_dossiers.count > 0
= tab_item(t('pluralize.mes_dossiers', count: @user_dossiers.count),
dossiers_path(statut: 'mes-dossiers'),
active: @statut == 'mes-dossiers',
- if @user_dossiers.present?
= tab_item(t('pluralize.en_cours', count: @user_dossiers.count),
dossiers_path(statut: 'en-cours'),
active: @statut == 'en-cours',
badge: number_with_html_delimiter(@user_dossiers.count))
- if @dossiers_invites.count > 0
- if @dossiers_traites.present?
= tab_item(t('pluralize.traites', count: @dossiers_traites.count),
dossiers_path(statut: 'traites'),
active: @statut == 'traites',
badge: number_with_html_delimiter(@dossiers_traites.count))
- if @dossiers_invites.present?
= tab_item(t('pluralize.dossiers_invites', count: @dossiers_invites.count),
dossiers_path(statut: 'dossiers-invites'),
active: @statut == 'dossiers-invites',
badge: number_with_html_delimiter(@dossiers_invites.count))
- if @dossiers_supprimes.count > 0
- if @dossiers_supprimes.present?
= tab_item(t('pluralize.dossiers_supprimes', count: @dossiers_supprimes.count),
dossiers_path(statut: 'dossiers-supprimes'),
active: @statut == 'dossiers-supprimes',
badge: number_with_html_delimiter(@dossiers_supprimes.count))
- if @dossier_transfers.count > 0
- if @dossier_transfers.present?
= tab_item(t('pluralize.dossiers_transferes', count: @dossier_transfers.count),
dossiers_path(statut: 'dossiers-transferes'),
active: @statut == 'dossiers-transferes',
@ -46,9 +52,12 @@
badge: number_with_html_delimiter(@dossiers_close_to_expiration.count))
.container
- if @statut == "mes-dossiers"
- if @statut == "en-cours"
= render partial: "dossiers_list", locals: { dossiers: @user_dossiers }
- if @statut == "traites"
= render partial: "dossiers_list", locals: { dossiers: @dossiers_traites }
- if @statut == "dossiers-invites"
= render partial: "dossiers_list", locals: { dossiers: @dossiers_invites }

View file

@ -326,10 +326,10 @@ en:
zero: archived
one: archived
other: archived
mes_dossiers:
zero: my file
one: my file
other: my files
en_cours:
zero: in progress
one: in progress
other: in progres
dossiers_invites:
zero: guest file
one: guest file

View file

@ -188,6 +188,7 @@ fr:
start_other_dossier: "Commencer un autre dossier"
delete_dossier: "Supprimer le dossier"
transfer_dossier: "Transferer le dossier"
cacher_dossier: 'Cacher le dossier'
edit_draft: "Modifier le brouillon"
actions: "Actions"
sessions:
@ -334,10 +335,14 @@ fr:
zero: archivé
one: archivé
other: archivés
mes_dossiers:
zero: mon dossier
one: mon dossier
other: mes dossiers
en_cours:
zero: en cours
one: en cours
other: en cours
traites:
zero: traité
one: traité
other: traités
dossiers_invites:
zero: dossier invité
one: dossier invité