Skip to content

Commit 9e7a323

Browse files
mfoclaude
andcommitted
views: extract envoyer_dossier and reaffectation into ViewComponents
Replace inline forms with Instructeurs::EnvoyerDossierFormComponent and Instructeurs::ReaffectationFormComponent. Both use DSFR fr-input-group/fr-select-group patterns with proper label[for] binding and i18n translations (fr/en). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8d67d3a commit 9e7a323

15 files changed

Lines changed: 179 additions & 139 deletions
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# frozen_string_literal: true
2+
3+
class Instructeurs::EnvoyerDossierFormComponent < ApplicationComponent
4+
attr_reader :dossier, :potential_recipients
5+
6+
def initialize(dossier:, potential_recipients:)
7+
@dossier = dossier
8+
@potential_recipients = potential_recipients
9+
end
10+
11+
private
12+
13+
def recipient_items
14+
potential_recipients.map { [it.email, it.id] }
15+
end
16+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
en:
2+
title: Send this file to another instructor
3+
hint: The recipient will automatically follow the file
4+
no_recipients: You are the only instructor assigned to this procedure
5+
submit: Send
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fr:
2+
title: Envoyer ce dossier à un autre instructeur
3+
hint: Le destinataire suivra automatiquement le dossier
4+
no_recipients: Vous êtes le seul instructeur assigné sur cette démarche
5+
submit: Envoyer
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<% if potential_recipients.empty? %>
2+
<p><%= t(".title") %></p>
3+
<p class="tab-paragraph"><%= t(".no_recipients") %></p>
4+
<% else %>
5+
<%= form_for dossier, url: send_to_instructeurs_instructeur_dossier_path(dossier.procedure, dossier), method: :post, html: { class: 'form recipients-form fr-mb-4w' } do |f| %>
6+
<div class="fr-select-group">
7+
<label class="fr-label fr-mb-1w" for="envoyer-dossier-select">
8+
<span id="envoyer-dossier-label"><%= t(".title") %></span>
9+
<span class="fr-hint-text"><%= t(".hint") %></span>
10+
</label>
11+
12+
<div class="fr-grid-row fr-grid-row--gutters fr-grid-row--top">
13+
<div class="fr-col-8">
14+
<react-fragment>
15+
<%= render ReactComponent.new "Select/MultipleSelect",
16+
triggerId: 'envoyer-dossier-select',
17+
'aria-labelledby': 'envoyer-dossier-label',
18+
items: recipient_items,
19+
name: 'recipients[]' %>
20+
</react-fragment>
21+
</div>
22+
23+
<div class="fr-col-4">
24+
<%= f.submit t(".submit"), class: "fr-btn" %>
25+
</div>
26+
</div>
27+
</div>
28+
<% end %>
29+
<% end %>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
class Instructeurs::ReaffectationFormComponent < ApplicationComponent
4+
attr_reader :dossier, :groupe_instructeur, :groupes_instructeurs
5+
6+
def initialize(dossier:, groupe_instructeur:, groupes_instructeurs:)
7+
@dossier = dossier
8+
@groupe_instructeur = groupe_instructeur
9+
@groupes_instructeurs = groupes_instructeurs
10+
end
11+
12+
private
13+
14+
def group_items
15+
groupes_instructeurs.map { |g| { label: g.label, value: g.id.to_s } }
16+
end
17+
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
en:
2+
title: "Reassign the file n° %{dossier_id} to another group"
3+
hint:
4+
one: "This file is assigned to group « %{label} ». You can reassign it to the other group"
5+
other: "This file is assigned to group « %{label} ». You can reassign it to one of the %{count} other groups"
6+
submit: Reassign the file to this group
7+
select: Select
8+
confirm: "Are you sure you want to reassign the file n° %{dossier_id} from the group « %{label} »?"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fr:
2+
title: "Réaffecter le dossier n° %{dossier_id} à un autre groupe instructeur"
3+
hint:
4+
one: "Ce dossier est affecté au groupe « %{label} ». Vous pouvez le réaffecter à lʼautre groupe instructeur"
5+
other: "Ce dossier est affecté au groupe « %{label} ». Vous pouvez le réaffecter à lʼun des %{count} autres groupes instructeurs"
6+
submit: Réaffecter le dossier à ce groupe
7+
select: Sélectionner
8+
confirm: "Êtes-vous sûr de vouloir réaffecter le dossier n° %{dossier_id} du groupe « %{label} » ?"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<div class="fr-mt-2w">
2+
<%= form_with url: reaffecter_instructeur_dossier_path(procedure_id: dossier.procedure.id, dossier_id: dossier.id), method: :post, local: true, data: { controller: 'enable-submit-if-filled', action: 'change->enable-submit-if-filled#fillCombobox' } do |form| %>
3+
<div class="fr-input-group">
4+
<label class="fr-label fr-mb-1w" for="reaffectation-input">
5+
<%= t(".title", dossier_id: dossier.id) %>
6+
7+
<span class="fr-hint-text">
8+
<%= t(".hint", label: groupe_instructeur.label, count: groupes_instructeurs.count) %>
9+
</span>
10+
</label>
11+
12+
<div class="fr-grid-row fr-grid-row--gutters fr-grid-row--bottom">
13+
<div class="fr-col-8">
14+
<react-fragment>
15+
<%= render ReactComponent.new "ComboBox/SingleComboBox",
16+
inputId: 'reaffectation-input',
17+
name: 'groupe_instructeur_id',
18+
placeholder: t(".select"),
19+
items: group_items,
20+
data: { enable_submit_if_filled_target: 'input' } %>
21+
</react-fragment>
22+
</div>
23+
24+
<div class="fr-col-4">
25+
<%= form.submit t(".submit"),
26+
class: 'fr-btn',
27+
data: { enable_submit_if_filled_target: 'submit', confirm: t(".confirm", dossier_id: dossier.id, label: groupe_instructeur.label) },
28+
disabled: true %>
29+
</div>
30+
</div>
31+
</div>
32+
<% end %>
33+
</div>

app/views/instructeurs/dossiers/_envoyer_dossier_block.html.haml

Lines changed: 0 additions & 15 deletions
This file was deleted.

app/views/instructeurs/dossiers/_personnes_impliquees_block.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
- if local_assigns[:title].present?
2-
.tab-title= title
2+
%p.fr-text--bold.fr-mb-1w= title
33

44
- if emails_collection.present?
55
%ul.tab-list

0 commit comments

Comments
 (0)