Simplify view
This commit is contained in:
parent
ce7ab89934
commit
745086cbb5
5 changed files with 21 additions and 26 deletions
|
@ -109,6 +109,8 @@ module Instructeurs
|
|||
@dossiers = @dossiers.sort_by { |d| filtered_sorted_paginated_ids.index(d.id) }
|
||||
|
||||
kaminarize(page, filtered_sorted_ids.count)
|
||||
|
||||
assign_exports
|
||||
end
|
||||
|
||||
def update_displayed_fields
|
||||
|
@ -226,6 +228,13 @@ module Instructeurs
|
|||
|
||||
private
|
||||
|
||||
def assign_exports
|
||||
groupe_instructeurs_for_procedure = current_instructeur.groupe_instructeurs.where(procedure: procedure)
|
||||
@xlsx_export = Export.find_for_format_and_groupe_instructeurs(:xlsx, groupe_instructeurs_for_procedure)
|
||||
@csv_export = Export.find_for_format_and_groupe_instructeurs(:csv, groupe_instructeurs_for_procedure)
|
||||
@ods_export = Export.find_for_format_and_groupe_instructeurs(:ods, groupe_instructeurs_for_procedure)
|
||||
end
|
||||
|
||||
def find_field(table, column)
|
||||
procedure_presentation.fields.find { |c| c['table'] == table && c['column'] == column }
|
||||
end
|
||||
|
|
|
@ -4,27 +4,11 @@
|
|||
Télécharger tous les dossiers
|
||||
.dropdown-content.fade-in-down{ style: 'width: 330px' }
|
||||
%ul.dropdown-items
|
||||
%li
|
||||
- if procedure.xlsx_export_stale?
|
||||
- if procedure.xlsx_export_queued?
|
||||
L'export au format .xlsx est en cours de préparation, vous recevrez un email lorsqu'il sera disponible.
|
||||
- [[xlsx_export, :xlsx], [csv_export, :csv], [ods_export, :ods]].each do |(export, format)|
|
||||
%li
|
||||
- if export.nil?
|
||||
= link_to "Exporter au format .#{format}", download_export_instructeur_procedure_path(procedure, export_format: format), remote: true
|
||||
- elsif export.ready?
|
||||
= link_to "Au format .#{format}", url_for(export.file), target: "_blank", rel: "noopener"
|
||||
- else
|
||||
= link_to "Exporter au format .xlsx", download_export_instructeur_procedure_path(procedure, export_format: :xlsx), remote: true
|
||||
- else
|
||||
= link_to "Au format .xlsx", url_for(procedure.xlsx_export_file), target: "_blank", rel: "noopener"
|
||||
%li
|
||||
- if procedure.ods_export_stale?
|
||||
- if procedure.ods_export_queued?
|
||||
L'export au format .ods est en cours de préparation, vous recevrez un email lorsqu'il sera disponible.
|
||||
- else
|
||||
= link_to "Exporter au format .ods", download_export_instructeur_procedure_path(procedure, export_format: :ods), remote: true
|
||||
- else
|
||||
= link_to "Au format .ods", url_for(procedure.ods_export_file), target: "_blank", rel: "noopener"
|
||||
%li
|
||||
- if procedure.csv_export_stale?
|
||||
- if procedure.csv_export_queued?
|
||||
L'export au format .csv est en cours de préparation, vous recevrez un email lorsqu'il sera disponible.
|
||||
- else
|
||||
= link_to "Exporter au format .csv", download_export_instructeur_procedure_path(procedure, export_format: :csv), remote: true
|
||||
- else
|
||||
= link_to "Au format .csv", url_for(procedure.csv_export_file), target: "_blank", rel: "noopener"
|
||||
L'export au format .#{format} est en cours de préparation
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
<%= render_to_element('.procedure-actions', partial: "download_dossiers", locals: { procedure: @procedure }) %>
|
||||
<%= render_to_element('.procedure-actions', partial: "download_dossiers",
|
||||
locals: { procedure: @procedure, xlsx_export: @xlsx_export, csv_export: @csv_export, ods_export: @ods_export }) %>
|
||||
<%= render_flash %>
|
||||
|
|
|
@ -49,7 +49,8 @@
|
|||
badge: @archived_dossiers.count)
|
||||
|
||||
.procedure-actions
|
||||
= render partial: "download_dossiers", locals: { procedure: @procedure }
|
||||
= render partial: "download_dossiers",
|
||||
locals: { procedure: @procedure, xlsx_export: @xlsx_export, csv_export: @csv_export, ods_export: @ods_export }
|
||||
|
||||
.container
|
||||
- if @statut == 'a-suivre'
|
||||
|
|
|
@ -2,7 +2,7 @@ describe 'instructeurs/procedures/_download_dossiers.html.haml', type: :view do
|
|||
let(:current_instructeur) { create(:instructeur) }
|
||||
let(:procedure) { create(:procedure) }
|
||||
|
||||
subject { render 'instructeurs/procedures/download_dossiers.html.haml', procedure: procedure }
|
||||
subject { render 'instructeurs/procedures/download_dossiers.html.haml', procedure: procedure, xlsx_export: nil, csv_export: nil, ods_export: nil }
|
||||
|
||||
context "when procedure has 0 dossier" do
|
||||
it { is_expected.not_to include("Télécharger tous les dossiers") }
|
||||
|
|
Loading…
Reference in a new issue