list export templates for groupes instructeur of current instructeur

This commit is contained in:
Christophe Robillard 2024-03-13 13:51:22 +01:00 committed by simon lehericey
parent 2c28d97f3f
commit 43c862ed4d
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
7 changed files with 20 additions and 14 deletions

View file

@ -1,9 +1,9 @@
class Dossiers::ExportDropdownComponent < ApplicationComponent class Dossiers::ExportDropdownComponent < ApplicationComponent
include ApplicationHelper include ApplicationHelper
def initialize(procedure:, statut: nil, count: nil, class_btn: nil, export_url: nil) def initialize(procedure:, export_templates: nil, statut: nil, count: nil, class_btn: nil, export_url: nil)
@procedure = procedure @procedure = procedure
@export_templates = procedure.export_templates @export_templates = export_templates
@statut = statut @statut = statut
@count = count @count = count
@class_btn = class_btn @class_btn = class_btn

View file

@ -14,6 +14,8 @@
- menu.with_item do - menu.with_item do
= link_to download_export_path(export_format: format), role: 'menuitem', data: { turbo_method: :post, turbo: true } do = link_to download_export_path(export_format: format), role: 'menuitem', data: { turbo_method: :post, turbo: true } do
= t(".everything_#{format}_html") = t(".everything_#{format}_html")
- if export_templates.present?
- export_templates.each do |export_template| - export_templates.each do |export_template|
- menu.with_item do - menu.with_item do
= link_to download_export_path(export_template_id: export_template.id), role: 'menuitem', data: { turbo_method: :post, turbo: true } do = link_to download_export_path(export_template_id: export_template.id), role: 'menuitem', data: { turbo_method: :post, turbo: true } do

View file

@ -303,6 +303,10 @@ class Instructeur < ApplicationRecord
agent_connect_information.order(updated_at: :desc).first agent_connect_information.order(updated_at: :desc).first
end end
def export_templates_for(procedure)
procedure.export_templates.where(groupe_instructeur: groupe_instructeurs).order(:name)
end
private private
def annotations_hash(demande, annotations_privees, avis, messagerie) def annotations_hash(demande, annotations_privees, avis, messagerie)

View file

@ -1,4 +1,4 @@
-# not renderable as administrateur flagged as manager, so render it anyway -# not renderable as administrateur flagged as manager, so render it anyway
- if @can_download_dossiers - if @can_download_dossiers
= turbo_stream.update_all '.procedure-actions' do = turbo_stream.update_all '.procedure-actions' do
= render Dossiers::ExportDropdownComponent.new(procedure: @procedure, export_templates: current_instructeur.export_templates, 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))

View file

@ -11,7 +11,7 @@
.procedure-actions .procedure-actions
- if @can_download_dossiers - if @can_download_dossiers
= render Dossiers::ExportDropdownComponent.new(procedure: @procedure, export_url: method(:download_export_instructeur_procedure_path)) = render Dossiers::ExportDropdownComponent.new(procedure: @procedure, export_templates: current_instructeur.export_templates_for(@procedure), export_url: method(:download_export_instructeur_procedure_path))
.fr-container.flex= render partial: "tabs", locals: { procedure: @procedure, .fr-container.flex= render partial: "tabs", locals: { procedure: @procedure,
statut: @statut, statut: @statut,

View file

@ -2,10 +2,10 @@
- if @can_download_dossiers - if @can_download_dossiers
- if @statut.nil? - if @statut.nil?
= turbo_stream.update_all '.procedure-actions' do = turbo_stream.update_all '.procedure-actions' do
= render Dossiers::ExportDropdownComponent.new(procedure: @procedure, export_url: method(:download_export_instructeur_procedure_path)) = render Dossiers::ExportDropdownComponent.new(procedure: @procedure, export_templates: current_instructeur.export_templates_for(@procedure), export_url: method(:download_export_instructeur_procedure_path))
- else - else
= turbo_stream.update_all '.dossiers-export' do = turbo_stream.update_all '.dossiers-export' do
= render Dossiers::ExportDropdownComponent.new(procedure: @procedure, statut: @statut, count: @dossiers_count, export_url: method(:download_export_instructeur_procedure_path)) = render Dossiers::ExportDropdownComponent.new(procedure: @procedure, export_templates: current_instructeur.export_templates_for(@procedure), statut: @statut, count: @dossiers_count, export_url: method(:download_export_instructeur_procedure_path))
= turbo_stream.update "last-export-alert" do = turbo_stream.update "last-export-alert" do
= render partial: "last_export_alert", locals: { export: @last_export, statut: @statut } = render partial: "last_export_alert", locals: { export: @last_export, statut: @statut }

View file

@ -11,7 +11,7 @@
.procedure-actions .procedure-actions
- if @can_download_dossiers - if @can_download_dossiers
= render Dossiers::ExportDropdownComponent.new(procedure: @procedure, export_url: method(:download_export_instructeur_procedure_path)) = render Dossiers::ExportDropdownComponent.new(procedure: @procedure, export_templates: current_instructeur.export_templates_for(@procedure), export_url: method(:download_export_instructeur_procedure_path))
.fr-container.flex= render partial: "tabs", locals: { procedure: @procedure, .fr-container.flex= render partial: "tabs", locals: { procedure: @procedure,
statut: @statut, statut: @statut,
@ -72,7 +72,7 @@
- if @dossiers_count > 0 - if @dossiers_count > 0
%span.dossiers-export %span.dossiers-export
= render Dossiers::ExportDropdownComponent.new(procedure: @procedure, statut: @statut, count: @dossiers_count, class_btn: 'fr-btn--tertiary', export_url: method(:download_export_instructeur_procedure_path)) = render Dossiers::ExportDropdownComponent.new(procedure: @procedure, export_templates: current_instructeur.export_templates_for(@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 - 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 } = render partial: "dossiers_filter_tags", locals: { procedure: @procedure, procedure_presentation: @procedure_presentation, current_filters: @current_filters, statut: @statut }