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>
This commit is contained in:
parent
82dd05c189
commit
fc66f4b05d
8 changed files with 14 additions and 42 deletions
|
@ -1,33 +1,20 @@
|
|||
class Dossiers::ExportDropdownComponent < ApplicationComponent
|
||||
include ApplicationHelper
|
||||
|
||||
def initialize(procedure:, exports:, statut: nil, count: nil, class_btn: nil, export_url: nil)
|
||||
def initialize(procedure:, statut: nil, count: nil, class_btn: nil, export_url: nil)
|
||||
@procedure = procedure
|
||||
@exports = exports
|
||||
@statut = statut
|
||||
@count = count
|
||||
@class_btn = class_btn
|
||||
@export_url = export_url
|
||||
end
|
||||
|
||||
def exports
|
||||
def formats
|
||||
if @statut
|
||||
Export::FORMATS.filter(&method(:allowed_format?)).map do |item|
|
||||
export = @exports
|
||||
.fetch(item.fetch(:format))
|
||||
.fetch(:statut)
|
||||
.fetch(@statut, nil)
|
||||
item.merge(export: export)
|
||||
end
|
||||
Export::FORMATS.filter(&method(:allowed_format?))
|
||||
else
|
||||
Export::FORMATS_WITH_TIME_SPAN.map do |item|
|
||||
export = @exports
|
||||
.fetch(item.fetch(:format))
|
||||
.fetch(:time_span_type)
|
||||
.fetch(item.fetch(:time_span_type), nil)
|
||||
item.merge(export: export)
|
||||
end
|
||||
end
|
||||
Export::FORMATS_WITH_TIME_SPAN
|
||||
end.map { _1[:format] }
|
||||
end
|
||||
|
||||
def allowed_format?(item)
|
||||
|
|
|
@ -10,9 +10,7 @@
|
|||
- menu.with_button_inner_html do
|
||||
= @count.nil? ? t(".download_all") : t(".download", count: @count)
|
||||
|
||||
- exports.each do |item|
|
||||
- export = item[:export]
|
||||
|
||||
- formats.each do |format|
|
||||
- menu.with_item do
|
||||
= link_to download_export_path(export_format: item[:format]), role: 'menuitem', data: { turbo_method: :post, turbo: true } do
|
||||
= t(".everything_#{item[:format]}_html")
|
||||
= link_to download_export_path(export_format: format), role: 'menuitem', data: { turbo_method: :post, turbo: true } do
|
||||
= t(".everything_#{format}_html")
|
||||
|
|
|
@ -6,7 +6,6 @@ module Administrateurs
|
|||
def download
|
||||
export = Export.find_or_create_export(export_format, all_groupe_instructeurs, force: force_export?, **export_options)
|
||||
@dossiers_count = export.count
|
||||
assign_exports
|
||||
|
||||
if export.available?
|
||||
respond_to do |format|
|
||||
|
@ -53,9 +52,5 @@ module Administrateurs
|
|||
def all_groupe_instructeurs
|
||||
@procedure.groupe_instructeurs
|
||||
end
|
||||
|
||||
def assign_exports
|
||||
@exports = Export.find_for_groupe_instructeurs(all_groupe_instructeurs.map(&:id), nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -103,7 +103,6 @@ module Instructeurs
|
|||
@projected_dossiers = DossierProjectionService.project(@filtered_sorted_paginated_ids, procedure_presentation.displayed_fields)
|
||||
@disable_checkbox_all = @projected_dossiers.all? { _1.batch_operation_id.present? }
|
||||
|
||||
assign_exports
|
||||
@batch_operations = BatchOperation.joins(:groupe_instructeurs)
|
||||
.where(groupe_instructeurs: current_instructeur.groupe_instructeurs.where(procedure_id: @procedure.id))
|
||||
.where(seen_at: nil)
|
||||
|
@ -127,8 +126,6 @@ module Instructeurs
|
|||
@has_termine_notifications = notifications[:termines].present?
|
||||
|
||||
@statut = 'supprime'
|
||||
|
||||
assign_exports
|
||||
end
|
||||
|
||||
def update_displayed_fields
|
||||
|
@ -178,7 +175,6 @@ module Instructeurs
|
|||
@procedure = procedure
|
||||
@statut = export_options[:statut]
|
||||
@dossiers_count = export.count
|
||||
assign_exports
|
||||
|
||||
if export.available?
|
||||
respond_to do |format|
|
||||
|
@ -282,10 +278,6 @@ module Instructeurs
|
|||
.permit(:instant_expert_avis_email_notifications_enabled, :instant_email_dossier_notifications_enabled, :instant_email_message_notifications_enabled, :daily_email_notifications_enabled, :weekly_email_notifications_enabled)
|
||||
end
|
||||
|
||||
def assign_exports
|
||||
@exports = Export.find_for_groupe_instructeurs(groupe_instructeur_ids, procedure_presentation)
|
||||
end
|
||||
|
||||
def assign_tos
|
||||
@assign_tos ||= current_instructeur
|
||||
.assign_to
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
%h1.mb-2
|
||||
Archives
|
||||
-# index not renderable as administrateur flagged as manager, so render it anyway
|
||||
= render Dossiers::ExportDropdownComponent.new(procedure: @procedure, exports: @exports, export_url: method(:download_admin_procedure_exports_path))
|
||||
= render Dossiers::ExportDropdownComponent.new(procedure: @procedure, export_url: method(:download_admin_procedure_exports_path))
|
||||
= render Dossiers::ExportLinkComponent.new(procedure: @procedure, exports: @exports, export_url: method(:download_admin_procedure_exports_path))
|
||||
|
||||
= render partial: "shared/archives/notice"
|
||||
|
|
|
@ -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, exports: @exports, count: @dossiers_count, export_url: method(:admin_procedure_exports_path))
|
||||
= render Dossiers::ExportDropdownComponent.new(procedure: @procedure, count: @dossiers_count, export_url: method(:admin_procedure_exports_path))
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
- if @can_download_dossiers
|
||||
- if @statut.nil?
|
||||
= turbo_stream.update_all '.procedure-actions' do
|
||||
= render Dossiers::ExportDropdownComponent.new(procedure: @procedure, exports: @exports, export_url: method(:download_export_instructeur_procedure_path))
|
||||
= render Dossiers::ExportDropdownComponent.new(procedure: @procedure, export_url: method(:download_export_instructeur_procedure_path))
|
||||
- else
|
||||
= turbo_stream.update_all '.dossiers-export' do
|
||||
= render Dossiers::ExportDropdownComponent.new(procedure: @procedure, exports: @exports, statut: @statut, count: @dossiers_count, export_url: method(:download_export_instructeur_procedure_path))
|
||||
= render Dossiers::ExportDropdownComponent.new(procedure: @procedure, statut: @statut, count: @dossiers_count, export_url: method(:download_export_instructeur_procedure_path))
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
.procedure-actions
|
||||
- if @can_download_dossiers
|
||||
= render Dossiers::ExportDropdownComponent.new(procedure: @procedure, exports: @exports, export_url: method(:download_export_instructeur_procedure_path))
|
||||
= render Dossiers::ExportDropdownComponent.new(procedure: @procedure, export_url: method(:download_export_instructeur_procedure_path))
|
||||
|
||||
.fr-container.flex= render partial: "tabs", locals: { procedure: @procedure,
|
||||
statut: @statut,
|
||||
|
@ -72,7 +72,7 @@
|
|||
|
||||
- if @dossiers_count > 0
|
||||
%span.dossiers-export
|
||||
= render Dossiers::ExportDropdownComponent.new(procedure: @procedure, exports: @exports, statut: @statut, count: @dossiers_count, class_btn: 'fr-btn--tertiary', export_url: method(:download_export_instructeur_procedure_path))
|
||||
= render Dossiers::ExportDropdownComponent.new(procedure: @procedure, statut: @statut, count: @dossiers_count, class_btn: 'fr-btn--tertiary', export_url: method(:download_export_instructeur_procedure_path))
|
||||
|
||||
- if @filtered_sorted_paginated_ids.present? || @current_filters.count > 0
|
||||
= render partial: "dossiers_filter_tags", locals: { procedure: @procedure, procedure_presentation: @procedure_presentation, current_filters: @current_filters, statut: @statut }
|
||||
|
|
Loading…
Reference in a new issue