Merge pull request #11069 from demarches-simplifiees/first_simplification_dossier_projection
Tech: simplification de la construction de la page instructeur listant les dossiers d'une démarche
This commit is contained in:
commit
987ea9d017
13 changed files with 104 additions and 186 deletions
|
@ -1,12 +1,12 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Instructeurs::SVASVRDecisionBadgeComponent < ApplicationComponent
|
class Instructeurs::SVASVRDecisionBadgeComponent < ApplicationComponent
|
||||||
attr_reader :object
|
attr_reader :dossier
|
||||||
attr_reader :procedure
|
attr_reader :procedure
|
||||||
attr_reader :with_label
|
attr_reader :with_label
|
||||||
|
|
||||||
def initialize(projection_or_dossier:, procedure:, with_label: false)
|
def initialize(dossier:, procedure:, with_label: false)
|
||||||
@object = projection_or_dossier
|
@dossier = dossier
|
||||||
@procedure = procedure
|
@procedure = procedure
|
||||||
@decision = procedure.sva_svr_configuration.decision.to_sym
|
@decision = procedure.sva_svr_configuration.decision.to_sym
|
||||||
@with_label = with_label
|
@with_label = with_label
|
||||||
|
@ -15,11 +15,11 @@ class Instructeurs::SVASVRDecisionBadgeComponent < ApplicationComponent
|
||||||
def render?
|
def render?
|
||||||
return false unless procedure.sva_svr_enabled?
|
return false unless procedure.sva_svr_enabled?
|
||||||
|
|
||||||
[:en_construction, :en_instruction].include? object.state.to_sym
|
[:en_construction, :en_instruction].include? dossier.state.to_sym
|
||||||
end
|
end
|
||||||
|
|
||||||
def without_date?
|
def without_date?
|
||||||
object.sva_svr_decision_on.nil?
|
dossier.sva_svr_decision_on.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def classes
|
def classes
|
||||||
|
@ -31,17 +31,17 @@ class Instructeurs::SVASVRDecisionBadgeComponent < ApplicationComponent
|
||||||
end
|
end
|
||||||
|
|
||||||
def soon?
|
def soon?
|
||||||
return false if object.sva_svr_decision_on.nil?
|
return false if dossier.sva_svr_decision_on.nil?
|
||||||
|
|
||||||
object.sva_svr_decision_on < 7.days.from_now.to_date
|
dossier.sva_svr_decision_on < 7.days.from_now.to_date
|
||||||
end
|
end
|
||||||
|
|
||||||
def pending_correction?
|
def pending_correction?
|
||||||
object.pending_correction?
|
dossier.pending_correction?
|
||||||
end
|
end
|
||||||
|
|
||||||
def days_count
|
def days_count
|
||||||
(object.sva_svr_decision_on - Date.current).to_i
|
(dossier.sva_svr_decision_on - Date.current).to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
def sva?
|
def sva?
|
||||||
|
@ -66,7 +66,7 @@ class Instructeurs::SVASVRDecisionBadgeComponent < ApplicationComponent
|
||||||
elsif pending_correction?
|
elsif pending_correction?
|
||||||
t(".dossier_terminated_x_days_after_correction", count: days_count)
|
t(".dossier_terminated_x_days_after_correction", count: days_count)
|
||||||
else
|
else
|
||||||
t(".dossier_terminated_on", date: helpers.l(object.sva_svr_decision_on))
|
t(".dossier_terminated_on", date: helpers.l(dossier.sva_svr_decision_on))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -75,14 +75,10 @@ class Instructeurs::SVASVRDecisionBadgeComponent < ApplicationComponent
|
||||||
end
|
end
|
||||||
|
|
||||||
def previously_termine?
|
def previously_termine?
|
||||||
return if !object.respond_to?(:previously_termine?)
|
dossier.previously_termine?
|
||||||
|
|
||||||
object.previously_termine?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def depose_before_configuration?
|
def depose_before_configuration?
|
||||||
return if !object.respond_to?(:sva_svr_decision_triggered_at)
|
dossier.sva_svr_decision_on.nil? && dossier.sva_svr_decision_triggered_at.nil?
|
||||||
|
|
||||||
object.sva_svr_decision_on.nil? && object.sva_svr_decision_triggered_at.nil?
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -105,7 +105,7 @@ module Instructeurs
|
||||||
.per(ITEMS_PER_PAGE)
|
.per(ITEMS_PER_PAGE)
|
||||||
|
|
||||||
@projected_dossiers = DossierProjectionService.project(@filtered_sorted_paginated_ids, procedure_presentation.displayed_columns)
|
@projected_dossiers = DossierProjectionService.project(@filtered_sorted_paginated_ids, procedure_presentation.displayed_columns)
|
||||||
@disable_checkbox_all = @projected_dossiers.all? { _1.batch_operation_id.present? }
|
@disable_checkbox_all = @projected_dossiers.all? { _1.dossier.batch_operation_id.present? }
|
||||||
|
|
||||||
@batch_operations = BatchOperation.joins(:groupe_instructeurs)
|
@batch_operations = BatchOperation.joins(:groupe_instructeurs)
|
||||||
.where(groupe_instructeurs: current_instructeur.groupe_instructeurs.where(procedure_id: @procedure.id))
|
.where(groupe_instructeurs: current_instructeur.groupe_instructeurs.where(procedure_id: @procedure.id))
|
||||||
|
|
|
@ -896,7 +896,7 @@ class Dossier < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def previously_termine?
|
def previously_termine?
|
||||||
traitements.termine.exists?
|
traitements.any?(&:termine?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_titres_identite!
|
def remove_titres_identite!
|
||||||
|
|
|
@ -26,4 +26,6 @@ class Traitement < ApplicationRecord
|
||||||
self.browser_supported = BrowserSupport.supported?(browser)
|
self.browser_supported = BrowserSupport.supported?(browser)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def termine? = state.in?(Dossier::TERMINE)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,19 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class DossierProjectionService
|
class DossierProjectionService
|
||||||
class DossierProjection < Struct.new(:dossier_id, :state, :archived, :hidden_by_user_at, :hidden_by_administration_at, :hidden_by_reason, :for_tiers, :prenom, :nom, :batch_operation_id, :sva_svr_decision_on, :corrections, :columns) do
|
class DossierProjection < Struct.new(:dossier, :columns)
|
||||||
def pending_correction?
|
|
||||||
return false if corrections.blank?
|
|
||||||
|
|
||||||
corrections.any? { _1[:resolved_at].nil? }
|
|
||||||
end
|
|
||||||
|
|
||||||
def resolved_corrections?
|
|
||||||
return false if corrections.blank?
|
|
||||||
|
|
||||||
corrections.all? { _1[:resolved_at].present? }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.for_tiers_translation(array)
|
def self.for_tiers_translation(array)
|
||||||
|
@ -42,28 +30,18 @@ class DossierProjectionService
|
||||||
# - the order of the intermediary query results are unknown
|
# - the order of the intermediary query results are unknown
|
||||||
# - some values can be missing (if a revision added or removed them)
|
# - some values can be missing (if a revision added or removed them)
|
||||||
def self.project(dossiers_ids, columns)
|
def self.project(dossiers_ids, columns)
|
||||||
|
dossiers = Dossier.includes(:corrections, :pending_corrections, :traitements).find(dossiers_ids)
|
||||||
|
|
||||||
fields = columns.map do |c|
|
fields = columns.map do |c|
|
||||||
if c.is_a?(Columns::ChampColumn)
|
if c.is_a?(Columns::ChampColumn)
|
||||||
{ TABLE => c.table, STABLE_ID => c.stable_id, original_column: c }
|
{ TABLE => c.table, STABLE_ID => c.stable_id, original_column: c }
|
||||||
else
|
else
|
||||||
{ TABLE => c.table, COLUMN => c.column }
|
{ TABLE => c.table, COLUMN => c.column, original_column: c }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
champ_value = champ_value_formatter(dossiers_ids, fields)
|
champ_value = champ_value_formatter(dossiers_ids, fields)
|
||||||
|
|
||||||
state_field = { TABLE => 'self', COLUMN => 'state' }
|
fields
|
||||||
archived_field = { TABLE => 'self', COLUMN => 'archived' }
|
|
||||||
batch_operation_field = { TABLE => 'self', COLUMN => 'batch_operation_id' }
|
|
||||||
hidden_by_user_at_field = { TABLE => 'self', COLUMN => 'hidden_by_user_at' }
|
|
||||||
hidden_by_administration_at_field = { TABLE => 'self', COLUMN => 'hidden_by_administration_at' }
|
|
||||||
hidden_by_reason_field = { TABLE => 'self', COLUMN => 'hidden_by_reason' }
|
|
||||||
for_tiers_field = { TABLE => 'self', COLUMN => 'for_tiers' }
|
|
||||||
individual_first_name = { TABLE => 'individual', COLUMN => 'prenom' }
|
|
||||||
individual_last_name = { TABLE => 'individual', COLUMN => 'nom' }
|
|
||||||
sva_svr_decision_on_field = { TABLE => 'self', COLUMN => 'sva_svr_decision_on' }
|
|
||||||
dossier_corrections = { TABLE => 'dossier_corrections', COLUMN => 'resolved_at' }
|
|
||||||
|
|
||||||
([state_field, archived_field, sva_svr_decision_on_field, hidden_by_user_at_field, hidden_by_administration_at_field, hidden_by_reason_field, for_tiers_field, individual_first_name, individual_last_name, batch_operation_field, dossier_corrections] + fields)
|
|
||||||
.each { |f| f[:id_value_h] = {} }
|
.each { |f| f[:id_value_h] = {} }
|
||||||
.group_by { |f| f[TABLE] } # one query per table
|
.group_by { |f| f[TABLE] } # one query per table
|
||||||
.each do |table, fields|
|
.each do |table, fields|
|
||||||
|
@ -85,19 +63,17 @@ class DossierProjectionService
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
when 'self'
|
when 'self'
|
||||||
Dossier
|
dossiers.each do |dossier|
|
||||||
.where(id: dossiers_ids)
|
fields.each do |field|
|
||||||
.pluck(:id, *fields.map { |f| f[COLUMN].to_sym })
|
column = field[:original_column]
|
||||||
.each do |id, *columns|
|
value = column.value(dossier)
|
||||||
fields.zip(columns).each do |field, value|
|
field[:id_value_h][dossier.id] = if value.respond_to?(:strftime)
|
||||||
# SVA must remain a date: in other column we compute remaining delay with it
|
I18n.l(value.to_date)
|
||||||
field[:id_value_h][id] = if value.respond_to?(:strftime) && field != sva_svr_decision_on_field
|
else
|
||||||
I18n.l(value.to_date)
|
value
|
||||||
else
|
|
||||||
value
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
when 'individual'
|
when 'individual'
|
||||||
Individual
|
Individual
|
||||||
.where(dossier_id: dossiers_ids)
|
.where(dossier_id: dossiers_ids)
|
||||||
|
@ -175,18 +151,7 @@ class DossierProjectionService
|
||||||
|
|
||||||
dossiers_ids.map do |dossier_id|
|
dossiers_ids.map do |dossier_id|
|
||||||
DossierProjection.new(
|
DossierProjection.new(
|
||||||
dossier_id,
|
dossiers.find { _1.id == dossier_id },
|
||||||
state_field[:id_value_h][dossier_id],
|
|
||||||
archived_field[:id_value_h][dossier_id],
|
|
||||||
hidden_by_user_at_field[:id_value_h][dossier_id],
|
|
||||||
hidden_by_administration_at_field[:id_value_h][dossier_id],
|
|
||||||
hidden_by_reason_field[:id_value_h][dossier_id],
|
|
||||||
for_tiers_field[:id_value_h][dossier_id],
|
|
||||||
individual_first_name[:id_value_h][dossier_id],
|
|
||||||
individual_last_name[:id_value_h][dossier_id],
|
|
||||||
batch_operation_field[:id_value_h][dossier_id],
|
|
||||||
sva_svr_decision_on_field[:id_value_h][dossier_id],
|
|
||||||
dossier_corrections[:id_value_h][dossier_id],
|
|
||||||
fields.map { |f| f[:id_value_h][dossier_id] }
|
fields.map { |f| f[:id_value_h][dossier_id] }
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
= pending_correction_badge(:for_instructeur)
|
= pending_correction_badge(:for_instructeur)
|
||||||
- elsif dossier.en_construction? && dossier.last_correction_resolved?
|
- elsif dossier.en_construction? && dossier.last_correction_resolved?
|
||||||
= correction_resolved_badge
|
= correction_resolved_badge
|
||||||
= render Instructeurs::SVASVRDecisionBadgeComponent.new(projection_or_dossier: dossier, procedure: dossier.procedure, with_label: true)
|
= render Instructeurs::SVASVRDecisionBadgeComponent.new(dossier:, procedure: dossier.procedure, with_label: true)
|
||||||
|
|
||||||
|
|
||||||
.header-actions.fr-ml-auto
|
.header-actions.fr-ml-auto
|
||||||
|
|
|
@ -110,70 +110,71 @@
|
||||||
= render Dossiers::BatchSelectMoreComponent.new(dossiers_count: @dossiers_count, filtered_sorted_ids: @filtered_sorted_ids)
|
= render Dossiers::BatchSelectMoreComponent.new(dossiers_count: @dossiers_count, filtered_sorted_ids: @filtered_sorted_ids)
|
||||||
|
|
||||||
- @projected_dossiers.each do |p|
|
- @projected_dossiers.each do |p|
|
||||||
- path = instructeur_dossier_path(@procedure, p.dossier_id)
|
- dossier = p.dossier
|
||||||
%tr{ class: class_names("file-hidden-by-user" => p.hidden_by_user_at.present?), id: "table-dossiers-row-#{p.dossier_id}", "aria-selected" => "false", "data-row-key" => p.dossier_id }
|
- path = instructeur_dossier_path(@procedure, dossier.id)
|
||||||
|
%tr{ class: class_names("file-hidden-by-user" => dossier.hidden_by_user_at.present?), id: "table-dossiers-row-#{dossier.id}", "aria-selected" => "false", "data-row-key" => dossier.id }
|
||||||
- if batch_operation_component.render?
|
- if batch_operation_component.render?
|
||||||
%th.fr-cell--fixed{ scope: 'row' }
|
%th.fr-cell--fixed{ scope: 'row' }
|
||||||
.fr-checkbox-group.fr-checkbox-group--sm
|
.fr-checkbox-group.fr-checkbox-group--sm
|
||||||
- if p.batch_operation_id.present?
|
- if dossier.batch_operation_id.present?
|
||||||
= check_box_tag "batch_operation[dossier_ids][]", p.dossier_id, true, disabled: true,
|
= check_box_tag "batch_operation[dossier_ids][]", dossier.id, true, disabled: true,
|
||||||
id: dom_id(BatchOperation.new, "checkbox_#{p.dossier_id}"),
|
id: dom_id(BatchOperation.new, "checkbox_#{dossier.id}"),
|
||||||
aria: { label: t('views.instructeurs.dossiers.batch_operation.disabled', dossier_id: p.dossier_id) },
|
aria: { label: t('views.instructeurs.dossiers.batch_operation.disabled', dossier_id: dossier.id) },
|
||||||
data: { "fr-row-select" => "true" }
|
data: { "fr-row-select" => "true" }
|
||||||
- else
|
- else
|
||||||
= check_box_tag "batch_operation[dossier_ids][]", p.dossier_id, false,
|
= check_box_tag "batch_operation[dossier_ids][]", dossier.id, false,
|
||||||
data: { batch_operation_target: "input", action: "batch-operation#onCheckOne", operations: batch_operation_component.operations_for_dossier(p).join(','), "fr-row-select" => "true" },
|
data: { batch_operation_target: "input", action: "batch-operation#onCheckOne", operations: batch_operation_component.operations_for_dossier(dossier).join(','), "fr-row-select" => "true" },
|
||||||
form: dom_id(BatchOperation.new), id: dom_id(BatchOperation.new, "checkbox_#{p.dossier_id}"),
|
form: dom_id(BatchOperation.new), id: dom_id(BatchOperation.new, "checkbox_#{dossier.id}"),
|
||||||
aria: { label: t('views.instructeurs.dossiers.batch_operation.enabled', dossier_id: p.dossier_id) }
|
aria: { label: t('views.instructeurs.dossiers.batch_operation.enabled', dossier_id: dossier.id) }
|
||||||
= label_tag dom_id(BatchOperation.new, "checkbox_#{p.dossier_id}"), "Sélectionner le dossier #{p.dossier_id}", class: 'fr-label'
|
= label_tag dom_id(BatchOperation.new, "checkbox_#{dossier.id}"), "Sélectionner le dossier #{dossier.id}", class: 'fr-label'
|
||||||
|
|
||||||
%td.fr-cell--numeric
|
%td.fr-cell--numeric
|
||||||
- if p.hidden_by_administration_at.present?
|
- if dossier.hidden_by_administration_at.present?
|
||||||
%span= p.dossier_id
|
%span= dossier.id
|
||||||
- else
|
- else
|
||||||
%a.fr-link.relative{ href: path }
|
%a.fr-link.relative{ href: path }
|
||||||
= p.dossier_id
|
= dossier.id
|
||||||
- if @not_archived_notifications_dossier_ids.include?(p.dossier_id)
|
- if @not_archived_notifications_dossier_ids.include?(dossier.id)
|
||||||
%span.notifications{ 'aria-label': 'notifications' }
|
%span.notifications{ 'aria-label': 'notifications' }
|
||||||
|
|
||||||
|
|
||||||
- p.columns.each do |column|
|
- p.columns.each do |column|
|
||||||
%td.fr-cell--multiline
|
%td.fr-cell--multiline
|
||||||
- if p.hidden_by_administration_at.present?
|
- if dossier.hidden_by_administration_at.present?
|
||||||
%span
|
%span
|
||||||
= column.is_a?(Hash) ? tags_label(column[:value]) : column
|
= column.is_a?(Hash) ? tags_label(column[:value]) : column
|
||||||
- if p.hidden_by_user_at.present?
|
- if dossier.hidden_by_user_at.present?
|
||||||
= "- #{t("views.instructeurs.dossiers.deleted_reason.#{p.hidden_by_reason}")}"
|
= "- #{t("views.instructeurs.dossiers.deleted_reason.#{dossier.hidden_by_reason}")}"
|
||||||
- else
|
- else
|
||||||
%a{ href: path }
|
%a{ href: path }
|
||||||
= column.is_a?(Hash) ? tags_label(column[:value]) : column
|
= column.is_a?(Hash) ? tags_label(column[:value]) : column
|
||||||
= "- #{t("views.instructeurs.dossiers.deleted_reason.#{p.hidden_by_reason}")}" if p.hidden_by_user_at.present?
|
= "- #{t("views.instructeurs.dossiers.deleted_reason.#{dossier.hidden_by_reason}")}" if dossier.hidden_by_user_at.present?
|
||||||
|
|
||||||
%td
|
%td
|
||||||
- status = [status_badge(p.state)]
|
- status = [status_badge(dossier.state)]
|
||||||
- if p.pending_correction?
|
- if dossier.pending_correction?
|
||||||
- status << pending_correction_badge(:for_instructeur, html_class: "fr-mt-1v")
|
- status << pending_correction_badge(:for_instructeur, html_class: "fr-mt-1v")
|
||||||
- elsif p.state.to_sym == :en_construction && p.resolved_corrections?
|
- elsif dossier.last_correction_resolved?
|
||||||
- status << correction_resolved_badge(html_class: "fr-mt-1v")
|
- status << correction_resolved_badge(html_class: "fr-mt-1v")
|
||||||
= link_to_if(p.hidden_by_administration_at.blank?, safe_join(status), path, class: "flex column")
|
= link_to_if(dossier.hidden_by_administration_at.blank?, safe_join(status), path, class: "flex column")
|
||||||
|
|
||||||
- if @procedure.sva_svr_enabled?
|
- if @procedure.sva_svr_enabled?
|
||||||
%td
|
%td
|
||||||
%span
|
%span
|
||||||
= link_to_if p.hidden_by_administration_at.blank?, render(Instructeurs::SVASVRDecisionBadgeComponent.new(projection_or_dossier: p, procedure: @procedure)), path
|
= link_to_if dossier.hidden_by_administration_at.blank?, render(Instructeurs::SVASVRDecisionBadgeComponent.new(dossier:, procedure: @procedure)), path
|
||||||
|
|
||||||
%td.follow-col
|
%td.follow-col
|
||||||
%ul.fr-btns-group.fr-btns-group--sm.fr-btns-group--inline.fr-btns-group--icon-right
|
%ul.fr-btns-group.fr-btns-group--sm.fr-btns-group--inline.fr-btns-group--icon-right
|
||||||
= render partial: 'instructeurs/procedures/dossier_actions', locals: { procedure_id: @procedure.id,
|
= render partial: 'instructeurs/procedures/dossier_actions', locals: { procedure_id: @procedure.id,
|
||||||
dossier_id: p.dossier_id,
|
dossier_id: dossier.id,
|
||||||
state: p.state,
|
state: dossier.state,
|
||||||
archived: p.archived,
|
archived: dossier.archived,
|
||||||
dossier_is_followed: @followed_dossiers_id.include?(p.dossier_id),
|
dossier_is_followed: @followed_dossiers_id.include?(dossier.id),
|
||||||
close_to_expiration: @statut == 'expirant',
|
close_to_expiration: @statut == 'expirant',
|
||||||
hidden_by_administration: @statut == 'supprimes',
|
hidden_by_administration: @statut == 'supprimes',
|
||||||
hidden_by_expired: p.hidden_by_reason == 'expired',
|
hidden_by_expired: dossier.hidden_by_reason == 'expired',
|
||||||
sva_svr: @procedure.sva_svr_enabled?,
|
sva_svr: @procedure.sva_svr_enabled?,
|
||||||
has_blocking_pending_correction: @procedure.feature_enabled?(:blocking_pending_correction) && p.pending_correction?,
|
has_blocking_pending_correction: @procedure.feature_enabled?(:blocking_pending_correction) && dossier.pending_correction?,
|
||||||
turbo: false,
|
turbo: false,
|
||||||
with_menu: false }
|
with_menu: false }
|
||||||
|
|
||||||
|
|
|
@ -27,23 +27,24 @@
|
||||||
%th.follow-col
|
%th.follow-col
|
||||||
%tbody
|
%tbody
|
||||||
- @projected_dossiers.each do |p|
|
- @projected_dossiers.each do |p|
|
||||||
|
- dossier = p.dossier
|
||||||
- procedure_libelle, user_email, procedure_id = p.columns
|
- procedure_libelle, user_email, procedure_id = p.columns
|
||||||
- instructeur_dossier = @instructeur_dossiers_ids.include?(p.dossier_id)
|
- instructeur_dossier = @instructeur_dossiers_ids.include?(dossier.id)
|
||||||
- expert_dossier = @dossier_avis_ids_h[p.dossier_id].present?
|
- expert_dossier = @dossier_avis_ids_h[dossier.id].present?
|
||||||
- hidden_by_administration = p.hidden_by_administration_at.present?
|
- hidden_by_administration = dossier.hidden_by_administration_at.present?
|
||||||
- instructeur_and_expert_dossier = instructeur_dossier && expert_dossier
|
- instructeur_and_expert_dossier = instructeur_dossier && expert_dossier
|
||||||
- path = instructeur_dossier ? instructeur_dossier_path(procedure_id, p.dossier_id) : expert_avis_path(procedure_id, @dossier_avis_ids_h[p.dossier_id])
|
- path = instructeur_dossier ? instructeur_dossier_path(procedure_id, dossier.id) : expert_avis_path(procedure_id, @dossier_avis_ids_h[dossier.id])
|
||||||
|
|
||||||
%tr{ class: [p.hidden_by_administration_at.present? && "file-hidden-by-user"] }
|
%tr{ class: [dossier.hidden_by_administration_at.present? && "file-hidden-by-user"] }
|
||||||
- if instructeur_and_expert_dossier
|
- if instructeur_and_expert_dossier
|
||||||
%td.fr-cell--numeric
|
%td.fr-cell--numeric
|
||||||
.relative
|
.relative
|
||||||
= p.dossier_id
|
= dossier.id
|
||||||
- if @notifications_dossier_ids.include?(p.dossier_id)
|
- if @notifications_dossier_ids.include?(dossier.id)
|
||||||
%span.notifications{ 'aria-label': 'notifications' }
|
%span.notifications{ 'aria-label': 'notifications' }
|
||||||
%td.fr-cell--multiline= procedure_libelle
|
%td.fr-cell--multiline= procedure_libelle
|
||||||
%td= user_email
|
%td= user_email
|
||||||
%td.flex.column= status_badge(p.state)
|
%td.flex.column= status_badge(dossier.state)
|
||||||
|
|
||||||
- elsif hidden_by_administration
|
- elsif hidden_by_administration
|
||||||
= render partial: "recherche/hidden_dossier", locals: {p: p, procedure_libelle: procedure_libelle, user_email: user_email}
|
= render partial: "recherche/hidden_dossier", locals: {p: p, procedure_libelle: procedure_libelle, user_email: user_email}
|
||||||
|
@ -51,8 +52,8 @@
|
||||||
- else
|
- else
|
||||||
%td.fr-cell--numeric
|
%td.fr-cell--numeric
|
||||||
%a.fr-link.relative{ href: path }
|
%a.fr-link.relative{ href: path }
|
||||||
= p.dossier_id
|
= dossier.id
|
||||||
- if @notifications_dossier_ids.include?(p.dossier_id)
|
- if @notifications_dossier_ids.include?(dossier.id)
|
||||||
%span.notifications{ 'aria-label': 'notifications' }
|
%span.notifications{ 'aria-label': 'notifications' }
|
||||||
|
|
||||||
%td
|
%td
|
||||||
|
@ -62,8 +63,7 @@
|
||||||
%a{ href: path }= user_email
|
%a{ href: path }= user_email
|
||||||
|
|
||||||
%td
|
%td
|
||||||
%a.flex.column{ href: path }= status_badge(p.state)
|
%a.flex.column{ href: path }= status_badge(dossier.state)
|
||||||
|
|
||||||
|
|
||||||
- if instructeur_dossier && expert_dossier
|
- if instructeur_dossier && expert_dossier
|
||||||
%td.follow-col
|
%td.follow-col
|
||||||
|
@ -72,13 +72,13 @@
|
||||||
Actions
|
Actions
|
||||||
|
|
||||||
- menu.with_item do
|
- menu.with_item do
|
||||||
= link_to(instructeur_dossier_path(procedure_id, p.dossier_id), role: 'menuitem') do
|
= link_to(instructeur_dossier_path(procedure_id, dossier.id), role: 'menuitem') do
|
||||||
= dsfr_icon('fr-icon-file-text-fill', :sm)
|
= dsfr_icon('fr-icon-file-text-fill', :sm)
|
||||||
.dropdown-description
|
.dropdown-description
|
||||||
Voir le dossier
|
Voir le dossier
|
||||||
|
|
||||||
- menu.with_item do
|
- menu.with_item do
|
||||||
= link_to(expert_avis_path(procedure_id, @dossier_avis_ids_h[p.dossier_id]), role: 'menuitem') do
|
= link_to(expert_avis_path(procedure_id, @dossier_avis_ids_h[dossier.id]), role: 'menuitem') do
|
||||||
= dsfr_icon('fr-icon-chat-3-fill', :sm)
|
= dsfr_icon('fr-icon-chat-3-fill', :sm)
|
||||||
.dropdown-description
|
.dropdown-description
|
||||||
Donner mon avis
|
Donner mon avis
|
||||||
|
@ -86,7 +86,7 @@
|
||||||
- elsif instructeur_dossier
|
- elsif instructeur_dossier
|
||||||
- if hidden_by_administration
|
- if hidden_by_administration
|
||||||
%td.follow-col
|
%td.follow-col
|
||||||
= link_to restore_instructeur_dossier_path(procedure_id, p.dossier_id), method: :patch, class: "button primary" do
|
= link_to restore_instructeur_dossier_path(procedure_id, dossier.id), method: :patch, class: "button primary" do
|
||||||
= t('views.instructeurs.dossiers.restore')
|
= t('views.instructeurs.dossiers.restore')
|
||||||
|
|
||||||
- else
|
- else
|
||||||
|
@ -94,15 +94,15 @@
|
||||||
%ul.fr-btns-group.fr-btns-group--sm.fr-btns-group--inline-lg.fr-btns-group--icon-right
|
%ul.fr-btns-group.fr-btns-group--sm.fr-btns-group--inline-lg.fr-btns-group--icon-right
|
||||||
= render partial: "instructeurs/procedures/dossier_actions",
|
= render partial: "instructeurs/procedures/dossier_actions",
|
||||||
locals: { procedure_id: procedure_id,
|
locals: { procedure_id: procedure_id,
|
||||||
dossier_id: p.dossier_id,
|
dossier_id: dossier.id,
|
||||||
state: p.state,
|
state: dossier.state,
|
||||||
archived: p.archived,
|
archived: dossier.archived,
|
||||||
dossier_is_followed: @followed_dossiers_id.include?(p.dossier_id),
|
dossier_is_followed: @followed_dossiers_id.include?(dossier.id),
|
||||||
close_to_expiration: nil,
|
close_to_expiration: nil,
|
||||||
hidden_by_administration: nil,
|
hidden_by_administration: nil,
|
||||||
hidden_by_expired: nil,
|
hidden_by_expired: nil,
|
||||||
sva_svr: p.sva_svr_decision_on.present?,
|
sva_svr: dossier.sva_svr_decision_on.present?,
|
||||||
has_blocking_pending_correction: p.pending_correction? && Flipper.enabled?(:blocking_pending_correction, ProcedureFlipperActor.new(procedure_id)),
|
has_blocking_pending_correction: dossier.pending_correction? && Flipper.enabled?(:blocking_pending_correction, ProcedureFlipperActor.new(procedure_id)),
|
||||||
turbo: false,
|
turbo: false,
|
||||||
with_menu: false }
|
with_menu: false }
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,8 @@ en:
|
||||||
true: 'yes'
|
true: 'yes'
|
||||||
false: 'no'
|
false: 'no'
|
||||||
question_answer_with_count:
|
question_answer_with_count:
|
||||||
true: "yes : %{count}"
|
true: "yes : %{count}"
|
||||||
false: "no : %{count}"
|
false: "no : %{count}"
|
||||||
confirmation:
|
confirmation:
|
||||||
revoke: "Would you like to revoke the opinion request to %{email} ?"
|
revoke: "Would you like to revoke the opinion request to %{email} ?"
|
||||||
remind: "Would you like to remind %{email} ?"
|
remind: "Would you like to remind %{email} ?"
|
||||||
|
|
|
@ -22,8 +22,8 @@ fr:
|
||||||
true: oui
|
true: oui
|
||||||
false: non
|
false: non
|
||||||
question_answer_with_count:
|
question_answer_with_count:
|
||||||
true: "oui : %{count}"
|
true: "oui : %{count}"
|
||||||
false: "non : %{count}"
|
false: "non : %{count}"
|
||||||
confirmation:
|
confirmation:
|
||||||
revoke: "Souhaitez-vous révoquer la demande d’avis à %{email} ?"
|
revoke: "Souhaitez-vous révoquer la demande d’avis à %{email} ?"
|
||||||
remind: "Souhaitez-vous relancer %{email} ?"
|
remind: "Souhaitez-vous relancer %{email} ?"
|
||||||
|
|
|
@ -10,7 +10,7 @@ RSpec.describe Instructeurs::SVASVRDecisionBadgeComponent, type: :component do
|
||||||
|
|
||||||
context 'with dossier object' do
|
context 'with dossier object' do
|
||||||
subject do
|
subject do
|
||||||
render_inline(described_class.new(projection_or_dossier: dossier, procedure:, with_label:))
|
render_inline(described_class.new(dossier:, procedure:, with_label:))
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:title) { subject.at_css("span")["title"] }
|
let(:title) { subject.at_css("span")["title"] }
|
||||||
|
@ -54,22 +54,4 @@ RSpec.describe Instructeurs::SVASVRDecisionBadgeComponent, type: :component do
|
||||||
it { expect(subject).to have_text("4 j. après correction") }
|
it { expect(subject).to have_text("4 j. après correction") }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with projection object' do
|
|
||||||
subject do
|
|
||||||
render_inline(described_class.new(projection_or_dossier: projection, procedure:, with_label:))
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'dossier en instruction' do
|
|
||||||
let(:projection) { DossierProjectionService::DossierProjection.new(dossier_id: 12, state: :en_instruction, sva_svr_decision_on: Date.new(2023, 9, 5)) }
|
|
||||||
|
|
||||||
it { expect(subject).to have_text("dans 4 jours") }
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'dossier without sva decision date' do
|
|
||||||
let(:projection) { DossierProjectionService::DossierProjection.new(dossier_id: 12, state: :en_instruction) }
|
|
||||||
|
|
||||||
it { expect(subject).to have_text("Instruction manuelle") }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,7 +48,7 @@ describe RechercheController, type: :controller do
|
||||||
|
|
||||||
it 'returns the expected dossier' do
|
it 'returns the expected dossier' do
|
||||||
expect(assigns(:projected_dossiers).count).to eq(1)
|
expect(assigns(:projected_dossiers).count).to eq(1)
|
||||||
expect(assigns(:projected_dossiers).first.dossier_id).to eq(dossier.id)
|
expect(assigns(:projected_dossiers).first.dossier).to eq(dossier)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ describe RechercheController, type: :controller do
|
||||||
|
|
||||||
it 'returns the expected dossier' do
|
it 'returns the expected dossier' do
|
||||||
expect(assigns(:projected_dossiers).count).to eq(1)
|
expect(assigns(:projected_dossiers).count).to eq(1)
|
||||||
expect(assigns(:projected_dossiers).first.dossier_id).to eq(dossier_with_expert.id)
|
expect(assigns(:projected_dossiers).first.dossier).to eq(dossier_with_expert)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ describe RechercheController, type: :controller do
|
||||||
it 'returns the expected dossier' do
|
it 'returns the expected dossier' do
|
||||||
subject
|
subject
|
||||||
expect(assigns(:projected_dossiers).count).to eq(1)
|
expect(assigns(:projected_dossiers).count).to eq(1)
|
||||||
expect(assigns(:projected_dossiers).first.dossier_id).to eq(dossier.id)
|
expect(assigns(:projected_dossiers).first.dossier).to eq(dossier)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when dossier has notification' do
|
context 'when dossier has notification' do
|
||||||
|
@ -170,7 +170,7 @@ describe RechercheController, type: :controller do
|
||||||
it 'returns only the dossier available to the expert' do
|
it 'returns only the dossier available to the expert' do
|
||||||
subject
|
subject
|
||||||
expect(assigns(:projected_dossiers).count).to eq(1)
|
expect(assigns(:projected_dossiers).count).to eq(1)
|
||||||
expect(assigns(:projected_dossiers).first.dossier_id).to eq(dossier_with_expert.id)
|
expect(assigns(:projected_dossiers).first.dossier).to eq(dossier_with_expert)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -184,7 +184,7 @@ describe RechercheController, type: :controller do
|
||||||
|
|
||||||
it 'returns the expected dossier' do
|
it 'returns the expected dossier' do
|
||||||
expect(assigns(:projected_dossiers).count).to eq(1)
|
expect(assigns(:projected_dossiers).count).to eq(1)
|
||||||
expect(assigns(:projected_dossiers).first.dossier_id).to eq(dossier_with_expert.id)
|
expect(assigns(:projected_dossiers).first.dossier).to eq(dossier_with_expert)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'as an expert' do
|
context 'as an expert' do
|
||||||
|
|
|
@ -29,17 +29,17 @@ describe DossierProjectionService do
|
||||||
it 'respects the dossiers_ids order, returns state, archived and nil for empty result' do
|
it 'respects the dossiers_ids order, returns state, archived and nil for empty result' do
|
||||||
expect(result.length).to eq(3)
|
expect(result.length).to eq(3)
|
||||||
|
|
||||||
expect(result[0].dossier_id).to eq(dossier_3.id)
|
expect(result[0].dossier.id).to eq(dossier_3.id)
|
||||||
expect(result[1].dossier_id).to eq(dossier_1.id)
|
expect(result[1].dossier.id).to eq(dossier_1.id)
|
||||||
expect(result[2].dossier_id).to eq(dossier_2.id)
|
expect(result[2].dossier.id).to eq(dossier_2.id)
|
||||||
|
|
||||||
expect(result[0].state).to eq('en_instruction')
|
expect(result[0].dossier.state).to eq('en_instruction')
|
||||||
expect(result[1].state).to eq('brouillon')
|
expect(result[1].dossier.state).to eq('brouillon')
|
||||||
expect(result[2].state).to eq('en_construction')
|
expect(result[2].dossier.state).to eq('en_construction')
|
||||||
|
|
||||||
expect(result[0].archived).to be false
|
expect(result[0].dossier.archived).to be false
|
||||||
expect(result[1].archived).to be false
|
expect(result[1].dossier.archived).to be false
|
||||||
expect(result[2].archived).to be true
|
expect(result[2].dossier.archived).to be true
|
||||||
|
|
||||||
expect(result[0].columns[0]).to be nil
|
expect(result[0].columns[0]).to be nil
|
||||||
expect(result[1].columns[0]).to eq('champ_1')
|
expect(result[1].columns[0]).to eq('champ_1')
|
||||||
|
@ -66,7 +66,7 @@ describe DossierProjectionService do
|
||||||
|
|
||||||
it 'returns champ value' do
|
it 'returns champ value' do
|
||||||
expect(result.length).to eq(1)
|
expect(result.length).to eq(1)
|
||||||
expect(result[0].dossier_id).to eq(dossier.id)
|
expect(result[0].dossier.id).to eq(dossier.id)
|
||||||
expect(result[0].columns[0]).to eq('Châteldon (63290)')
|
expect(result[0].columns[0]).to eq('Châteldon (63290)')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -249,34 +249,6 @@ describe DossierProjectionService do
|
||||||
|
|
||||||
it { is_expected.to eq('38') }
|
it { is_expected.to eq('38') }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for dossier corrections table' do
|
|
||||||
let(:table) { 'dossier_corrections' }
|
|
||||||
let(:column) { 'resolved_at' }
|
|
||||||
let(:procedure) { create(:procedure) }
|
|
||||||
let(:columns) { [Column.new(procedure_id: procedure.id, table:, column:)] } # should somehow be present in column concern
|
|
||||||
let(:dossier) { create(:dossier, :en_construction, procedure:) }
|
|
||||||
subject { described_class.project(dossiers_ids, columns)[0] }
|
|
||||||
|
|
||||||
context "when dossier has pending correction" do
|
|
||||||
before { create(:dossier_correction, dossier:) }
|
|
||||||
|
|
||||||
it { expect(subject.pending_correction?).to be(true) }
|
|
||||||
it { expect(subject.resolved_corrections?).to eq(false) }
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when dossier has a resolved correction" do
|
|
||||||
before { create(:dossier_correction, :resolved, dossier:) }
|
|
||||||
|
|
||||||
it { expect(subject.pending_correction?).to eq(false) }
|
|
||||||
it { expect(subject.resolved_corrections?).to eq(true) }
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when dossier has no correction at all" do
|
|
||||||
it { expect(subject.pending_correction?).to eq(false) }
|
|
||||||
it { expect(subject.resolved_corrections?).to eq(false) }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue