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) }
|
@dossiers = @dossiers.sort_by { |d| filtered_sorted_paginated_ids.index(d.id) }
|
||||||
|
|
||||||
kaminarize(page, filtered_sorted_ids.count)
|
kaminarize(page, filtered_sorted_ids.count)
|
||||||
|
|
||||||
|
assign_exports
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_displayed_fields
|
def update_displayed_fields
|
||||||
|
@ -226,6 +228,13 @@ module Instructeurs
|
||||||
|
|
||||||
private
|
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)
|
def find_field(table, column)
|
||||||
procedure_presentation.fields.find { |c| c['table'] == table && c['column'] == column }
|
procedure_presentation.fields.find { |c| c['table'] == table && c['column'] == column }
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,27 +4,11 @@
|
||||||
Télécharger tous les dossiers
|
Télécharger tous les dossiers
|
||||||
.dropdown-content.fade-in-down{ style: 'width: 330px' }
|
.dropdown-content.fade-in-down{ style: 'width: 330px' }
|
||||||
%ul.dropdown-items
|
%ul.dropdown-items
|
||||||
%li
|
- [[xlsx_export, :xlsx], [csv_export, :csv], [ods_export, :ods]].each do |(export, format)|
|
||||||
- if procedure.xlsx_export_stale?
|
%li
|
||||||
- if procedure.xlsx_export_queued?
|
- if export.nil?
|
||||||
L'export au format .xlsx est en cours de préparation, vous recevrez un email lorsqu'il sera disponible.
|
= 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
|
- else
|
||||||
= link_to "Exporter au format .xlsx", download_export_instructeur_procedure_path(procedure, export_format: :xlsx), remote: true
|
L'export au format .#{format} est en cours de préparation
|
||||||
- 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"
|
|
||||||
|
|
|
@ -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 %>
|
<%= render_flash %>
|
||||||
|
|
|
@ -49,7 +49,8 @@
|
||||||
badge: @archived_dossiers.count)
|
badge: @archived_dossiers.count)
|
||||||
|
|
||||||
.procedure-actions
|
.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
|
.container
|
||||||
- if @statut == 'a-suivre'
|
- if @statut == 'a-suivre'
|
||||||
|
|
|
@ -2,7 +2,7 @@ describe 'instructeurs/procedures/_download_dossiers.html.haml', type: :view do
|
||||||
let(:current_instructeur) { create(:instructeur) }
|
let(:current_instructeur) { create(:instructeur) }
|
||||||
let(:procedure) { create(:procedure) }
|
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
|
context "when procedure has 0 dossier" do
|
||||||
it { is_expected.not_to include("Télécharger tous les dossiers") }
|
it { is_expected.not_to include("Télécharger tous les dossiers") }
|
||||||
|
|
Loading…
Reference in a new issue