proposition de simplification
This commit is contained in:
parent
e043645a88
commit
02e2128fb7
2 changed files with 53 additions and 88 deletions
|
@ -9,27 +9,13 @@ class RechercheController < ApplicationController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@search_terms = search_terms
|
@search_terms = search_terms
|
||||||
matching_dossiers_ids = []
|
|
||||||
instructeur_dossiers_ids = []
|
|
||||||
expert_dossiers_ids = []
|
|
||||||
|
|
||||||
if instructeur_signed_in?
|
@instructeur_dossiers_ids = current_instructeur&.dossiers&.ids || []
|
||||||
instructeur_dossiers_ids.concat(current_instructeur.dossiers.ids)
|
matching_dossiers_ids = DossierSearchService.matching_dossiers(@instructeur_dossiers_ids, @search_terms, true)
|
||||||
@followed_dossiers_id = current_instructeur.followed_dossiers.where(id: instructeur_dossiers_ids).ids
|
|
||||||
|
|
||||||
if instructeur_dossiers_ids.present?
|
@dossier_avis_ids_h = current_expert&.avis&.pluck(:dossier_id, :id).to_h || {}
|
||||||
matching_dossiers_ids.concat(DossierSearchService.matching_dossiers(instructeur_dossiers_ids, @search_terms, true))
|
expert_dossiers_ids = @dossier_avis_ids_h.keys
|
||||||
end
|
matching_dossiers_ids.concat(DossierSearchService.matching_dossiers(expert_dossiers_ids, @search_terms))
|
||||||
end
|
|
||||||
|
|
||||||
if expert_signed_in?
|
|
||||||
@dossier_avis_ids_h = current_expert.avis.pluck(:dossier_id, :id).to_h
|
|
||||||
expert_dossiers_ids.concat(@dossier_avis_ids_h.keys)
|
|
||||||
|
|
||||||
if expert_dossiers_ids.present?
|
|
||||||
matching_dossiers_ids.concat(DossierSearchService.matching_dossiers(expert_dossiers_ids, @search_terms))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@paginated_ids = Kaminari
|
@paginated_ids = Kaminari
|
||||||
.paginate_array(matching_dossiers_ids.uniq)
|
.paginate_array(matching_dossiers_ids.uniq)
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
- content_for(:title, "Recherche : #{@search_terms}")
|
- content_for(:title, "Recherche : #{@search_terms}")
|
||||||
- pagination = paginate @paginated_ids
|
- pagination = paginate @paginated_ids
|
||||||
- procedure_libelle_index = 0
|
|
||||||
- user_email_index = 1
|
|
||||||
|
|
||||||
.container
|
.container
|
||||||
.page-title
|
.page-title
|
||||||
Résultat de la recherche :
|
Résultat de la recherche :
|
||||||
= t('pluralize.dossier_trouve', count: @dossiers_count)
|
= t('pluralize.dossier_trouve', count: @dossiers_count)
|
||||||
|
|
||||||
|
= pagination
|
||||||
|
|
||||||
- if @projected_dossiers.present?
|
- if @projected_dossiers.present?
|
||||||
%table.table.dossiers-table.hoverable
|
%table.table.dossiers-table.hoverable
|
||||||
%thead
|
%thead
|
||||||
|
@ -20,84 +20,63 @@
|
||||||
%th.action-col.follow-col
|
%th.action-col.follow-col
|
||||||
%tbody
|
%tbody
|
||||||
- @projected_dossiers.each do |p|
|
- @projected_dossiers.each do |p|
|
||||||
- procedure_id = p.columns.last
|
- procedure_libelle, user_email, procedure_id = p.columns
|
||||||
- if current_expert.present?
|
- instructeur_dossier = @instructeur_dossiers_ids.include?(p.dossier_id)
|
||||||
- avis_id = @dossier_avis_ids_h[p.dossier_id]
|
- expert_dossier = @dossier_avis_ids_h[p.dossier_id].present?
|
||||||
|
- 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])
|
||||||
|
|
||||||
- if (current_expert.present? && current_instructeur.blank?) || (current_instructeur.present? && current_expert.blank?)
|
%tr
|
||||||
|
- if instructeur_and_expert_dossier
|
||||||
- path = current_instructeur.present? ? instructeur_dossier_path(procedure_id, p.dossier_id) : expert_avis_path(procedure_id, avis_id)
|
%td.folder-col.cell-link
|
||||||
|
|
||||||
%tr
|
|
||||||
%td.folder-col
|
|
||||||
= link_to(path, class: 'cell-link') do
|
|
||||||
%span.icon.folder
|
|
||||||
%td.number-col
|
|
||||||
= link_to(path, class: 'cell-link') do
|
|
||||||
= p.dossier_id
|
|
||||||
|
|
||||||
- p.columns.values_at(procedure_libelle_index, user_email_index).each do |column|
|
|
||||||
%td
|
|
||||||
%a.cell-link{ href: path }= column
|
|
||||||
|
|
||||||
%td.status-col
|
|
||||||
= link_to(path, class: 'cell-link') do
|
|
||||||
= status_badge(p.state)
|
|
||||||
|
|
||||||
- if current_instructeur.present?
|
|
||||||
%td.action-col.follow-col= render partial: "instructeurs/procedures/dossier_actions",
|
|
||||||
locals: { procedure_id: procedure_id,
|
|
||||||
dossier_id: p.dossier_id,
|
|
||||||
state: p.state,
|
|
||||||
archived: p.archived,
|
|
||||||
button_class: false,
|
|
||||||
dossier_is_followed: @followed_dossiers_id.include?(p.dossier_id) }
|
|
||||||
|
|
||||||
- else
|
|
||||||
%tr
|
|
||||||
%td.folder-col
|
|
||||||
%span.icon.folder
|
%span.icon.folder
|
||||||
%td.number-col
|
%td.number-col
|
||||||
.cell-link
|
.cell-link= p.dossier_id
|
||||||
= p.dossier_id
|
%td
|
||||||
|
.cell-link= procedure_libelle
|
||||||
|
%td
|
||||||
|
.cell-link= user_email
|
||||||
|
%td
|
||||||
|
.cell-link= status_badge(p.state)
|
||||||
|
|
||||||
- p.columns.values_at(procedure_libelle_index, user_email_index).each do |column|
|
- else
|
||||||
%td
|
%td.folder-col
|
||||||
.cell-link
|
%a.cell-link{ href: path }
|
||||||
= column
|
%span.icon.folder
|
||||||
|
|
||||||
|
%td.number-col
|
||||||
|
%a.cell-link{ href: path }= p.dossier_id
|
||||||
|
|
||||||
|
%td
|
||||||
|
%a.cell-link{ href: path }= procedure_libelle
|
||||||
|
|
||||||
|
%td
|
||||||
|
%a.cell-link{ href: path }= user_email
|
||||||
|
|
||||||
%td.status-col
|
%td.status-col
|
||||||
.cell-link
|
%a.cell-link{ href: path }= status_badge(p.state)
|
||||||
= status_badge(p.state)
|
|
||||||
|
|
||||||
|
- if instructeur_dossier && expert_dossier
|
||||||
%td.action-col.follow-col
|
%td.action-col.follow-col
|
||||||
.dropdown
|
.dropdown
|
||||||
.button.dropdown-button
|
.button.dropdown-button
|
||||||
Actions
|
Actions
|
||||||
.dropdown-content.fade-in-down
|
.dropdown-content.fade-in-down
|
||||||
%ul.dropdown-items.pl-0
|
%ul.dropdown-items
|
||||||
- if current_instructeur.present?
|
%li
|
||||||
%li
|
= link_to(instructeur_dossier_path(procedure_id, p.dossier_id)) do
|
||||||
.dropdown-description
|
%span.icon.in-progress>
|
||||||
%h4
|
.dropdown-description
|
||||||
= render partial: "instructeurs/procedures/dossier_actions",
|
Voir le dossier
|
||||||
locals: { procedure_id: procedure_id,
|
%li
|
||||||
dossier_id: p.dossier_id,
|
= link_to(expert_avis_path(procedure_id, @dossier_avis_ids_h[p.dossier_id])) do
|
||||||
state: p.state,
|
%span.icon.in-progress>
|
||||||
archived: p.archived,
|
.dropdown-description
|
||||||
button_class: false,
|
Donner mon avis
|
||||||
dossier_is_followed: @followed_dossiers_id.include?(p.dossier_id) }
|
- else
|
||||||
|
%td
|
||||||
|
|
||||||
%li
|
|
||||||
= link_to instructeur_dossier_path(procedure_id, p.dossier_id) do
|
|
||||||
%span.icon.in-progress
|
|
||||||
.dropdown-description
|
|
||||||
%h4 Instruire le dossier
|
|
||||||
- if avis_id.present?
|
|
||||||
%li
|
|
||||||
= link_to(expert_avis_path(procedure_id, avis_id)) do
|
|
||||||
%span.icon.in-progress
|
|
||||||
.dropdown-description
|
|
||||||
%h4 Donner mon avis
|
|
||||||
= pagination
|
= pagination
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue