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
|
|
||||||
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))
|
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
|
||||||
- if (current_expert.present? && current_instructeur.blank?) || (current_instructeur.present? && current_expert.blank?)
|
- path = instructeur_dossier ? instructeur_dossier_path(procedure_id, p.dossier_id) : expert_avis_path(procedure_id, @dossier_avis_ids_h[p.dossier_id])
|
||||||
|
|
||||||
- path = current_instructeur.present? ? instructeur_dossier_path(procedure_id, p.dossier_id) : expert_avis_path(procedure_id, avis_id)
|
|
||||||
|
|
||||||
%tr
|
%tr
|
||||||
%td.folder-col
|
- if instructeur_and_expert_dossier
|
||||||
= link_to(path, class: 'cell-link') do
|
%td.folder-col.cell-link
|
||||||
%span.icon.folder
|
%span.icon.folder
|
||||||
%td.number-col
|
%td.number-col
|
||||||
= link_to(path, class: 'cell-link') do
|
.cell-link= p.dossier_id
|
||||||
= p.dossier_id
|
|
||||||
|
|
||||||
- p.columns.values_at(procedure_libelle_index, user_email_index).each do |column|
|
|
||||||
%td
|
%td
|
||||||
%a.cell-link{ href: path }= column
|
.cell-link= procedure_libelle
|
||||||
|
%td
|
||||||
%td.status-col
|
.cell-link= user_email
|
||||||
= link_to(path, class: 'cell-link') do
|
%td
|
||||||
= status_badge(p.state)
|
.cell-link= 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
|
- else
|
||||||
%tr
|
|
||||||
%td.folder-col
|
%td.folder-col
|
||||||
|
%a.cell-link{ href: path }
|
||||||
%span.icon.folder
|
%span.icon.folder
|
||||||
%td.number-col
|
|
||||||
.cell-link
|
|
||||||
= p.dossier_id
|
|
||||||
|
|
||||||
- p.columns.values_at(procedure_libelle_index, user_email_index).each do |column|
|
%td.number-col
|
||||||
|
%a.cell-link{ href: path }= p.dossier_id
|
||||||
|
|
||||||
%td
|
%td
|
||||||
.cell-link
|
%a.cell-link{ href: path }= procedure_libelle
|
||||||
= column
|
|
||||||
|
%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
|
||||||
|
%span.icon.in-progress>
|
||||||
.dropdown-description
|
.dropdown-description
|
||||||
%h4
|
Voir le dossier
|
||||||
= render partial: "instructeurs/procedures/dossier_actions",
|
%li
|
||||||
locals: { procedure_id: procedure_id,
|
= link_to(expert_avis_path(procedure_id, @dossier_avis_ids_h[p.dossier_id])) do
|
||||||
dossier_id: p.dossier_id,
|
%span.icon.in-progress>
|
||||||
state: p.state,
|
.dropdown-description
|
||||||
archived: p.archived,
|
Donner mon avis
|
||||||
button_class: false,
|
- else
|
||||||
dossier_is_followed: @followed_dossiers_id.include?(p.dossier_id) }
|
%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