can use export template from export_dropdown_component

This commit is contained in:
Christophe Robillard 2024-03-08 17:15:47 +01:00 committed by simon lehericey
parent 357c07456c
commit 2a4bfdd40b
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
3 changed files with 13 additions and 3 deletions

View file

@ -3,6 +3,7 @@ class Dossiers::ExportDropdownComponent < ApplicationComponent
def initialize(procedure:, statut: nil, count: nil, class_btn: nil, export_url: nil)
@procedure = procedure
@export_templates = procedure.export_templates
@statut = statut
@count = count
@class_btn = class_btn
@ -21,10 +22,15 @@ class Dossiers::ExportDropdownComponent < ApplicationComponent
item.fetch(:format) != :json || @procedure.active_revision.carte?
end
def download_export_path(export_format:, no_progress_notification: nil)
def download_export_path(export_format: nil, export_template_id: nil, no_progress_notification: nil)
@export_url.call(@procedure,
export_format: export_format,
export_format:,
export_template_id:,
statut: @statut,
no_progress_notification: no_progress_notification)
end
def export_templates
@export_templates
end
end

View file

@ -14,3 +14,7 @@
- menu.with_item do
= link_to download_export_path(export_format: format), role: 'menuitem', data: { turbo_method: :post, turbo: true } do
= t(".everything_#{format}_html")
- export_templates.each do |export_template|
- menu.with_item do
= link_to download_export_path(export_template_id: export_template.id), role: 'menuitem', data: { turbo_method: :post, turbo: true } do
= "Exporter à partir du modèle #{export_template.name}"

View file

@ -1,4 +1,4 @@
-# not renderable as administrateur flagged as manager, so render it anyway
- if @can_download_dossiers
= turbo_stream.update_all '.procedure-actions' do
= render Dossiers::ExportDropdownComponent.new(procedure: @procedure, count: @dossiers_count, export_url: method(:admin_procedure_exports_path))
= render Dossiers::ExportDropdownComponent.new(procedure: @procedure, export_templates: current_instructeur.export_templates, count: @dossiers_count, export_url: method(:admin_procedure_exports_path))