demarches-normaliennes/app/components/dossiers/export_dropdown_component.rb
Colin Darie fc66f4b05d
refactor(exports): drop useless exports relation dependency for exports dropdown
Since the dropdown does not list download links anymore,
we don't have to pass them a dynamic exports list.

Co-Authored-By: Lisa Durand <lisa.c.durand@gmail.com>
2023-09-28 12:35:08 +02:00

31 lines
869 B
Ruby

class Dossiers::ExportDropdownComponent < ApplicationComponent
include ApplicationHelper
def initialize(procedure:, statut: nil, count: nil, class_btn: nil, export_url: nil)
@procedure = procedure
@statut = statut
@count = count
@class_btn = class_btn
@export_url = export_url
end
def formats
if @statut
Export::FORMATS.filter(&method(:allowed_format?))
else
Export::FORMATS_WITH_TIME_SPAN
end.map { _1[:format] }
end
def allowed_format?(item)
item.fetch(:format) != :json || @procedure.active_revision.carte?
end
def download_export_path(export_format:, force_export: false, no_progress_notification: nil)
@export_url.call(@procedure,
export_format: export_format,
statut: @statut,
force_export: force_export,
no_progress_notification: no_progress_notification)
end
end