[Fix #871] Add the date at the end of exported files
This commit is contained in:
parent
847816ea4c
commit
5361e4e1e9
3 changed files with 15 additions and 3 deletions
|
@ -173,6 +173,17 @@ module NewGestionnaire
|
|||
redirect_back(fallback_location: procedure_url(procedure))
|
||||
end
|
||||
|
||||
def download_dossiers
|
||||
export = procedure.generate_export
|
||||
filename = "dossiers_#{procedure.procedure_path.path}_#{Time.now.strftime('%Y-%m-%d_%H-%M')}"
|
||||
|
||||
respond_to do |format|
|
||||
format.csv { send_data(SpreadsheetArchitect.to_csv(data: export[:data], headers: export[:headers]), filename: "#{filename}.csv") }
|
||||
format.xlsx { send_data(SpreadsheetArchitect.to_xlsx(data: export[:data], headers: export[:headers]), filename: "#{filename}.xlsx") }
|
||||
format.ods { send_data(SpreadsheetArchitect.to_ods(data: export[:data], headers: export[:headers]), filename: "#{filename}.ods") }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def statut
|
||||
|
|
|
@ -46,11 +46,11 @@
|
|||
.dropdown-content.fade-in-down
|
||||
%ul.dropdown-items
|
||||
%li
|
||||
= link_to "Au format .csv", backoffice_download_dossiers_tps_path(format: :csv, procedure_id: @procedure.id), target: "_blank"
|
||||
= link_to "Au format .csv", download_dossiers_procedure_path(format: :csv, procedure_id: @procedure.id), target: "_blank"
|
||||
%li
|
||||
= link_to "Au format .xlsx", backoffice_download_dossiers_tps_path(format: :xlsx, procedure_id: @procedure.id), target: "_blank"
|
||||
= link_to "Au format .xlsx", download_dossiers_procedure_path(format: :xlsx, procedure_id: @procedure.id), target: "_blank"
|
||||
%li
|
||||
= link_to "Au format .ods", backoffice_download_dossiers_tps_path(format: :ods, procedure_id: @procedure.id), target: "_blank"
|
||||
= link_to "Au format .ods", download_dossiers_procedure_path(format: :ods, procedure_id: @procedure.id), target: "_blank"
|
||||
|
||||
.container
|
||||
- if @dossiers.present? || @current_filters.count > 0
|
||||
|
|
|
@ -240,6 +240,7 @@ Rails.application.routes.draw do
|
|||
get 'update_sort/:table/:column' => 'procedures#update_sort', as: 'update_sort'
|
||||
post 'add_filter'
|
||||
get 'remove_filter/:statut/:table/:column' => 'procedures#remove_filter', as: 'remove_filter'
|
||||
get 'download_dossiers'
|
||||
|
||||
resources :dossiers, only: [:show], param: :dossier_id do
|
||||
member do
|
||||
|
|
Loading…
Reference in a new issue