-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10878 from demarches-simplifiees/update-routage-i…
…nterface ETQ admin j'ai accès à une nouvelle interface de gestion des instructeurs
- Loading branch information
Showing
20 changed files
with
197 additions
and
117 deletions.
There are no files selected for viewing
3 changes: 0 additions & 3 deletions
3
app/components/procedure/groupes_ajout_component/groupes_ajout_component.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
|
||
class Procedure::ImportComponent < ApplicationComponent | ||
def initialize(procedure:) | ||
@procedure = procedure | ||
end | ||
|
||
def scope | ||
@procedure.routing_enabled? ? 'groupes' : 'instructeurs' | ||
end | ||
|
||
def template_file | ||
if @procedure.routing_enabled? | ||
'/csv/import-groupe-test.csv' | ||
else | ||
'/csv/import-instructeurs-test.csv' | ||
end | ||
end | ||
|
||
def template_detail | ||
"#{File.extname(csv_template.to_path).upcase.delete_prefix('.')} – #{number_to_human_size(csv_template.size)}" | ||
end | ||
|
||
def csv_max_size | ||
Administrateurs::GroupeInstructeursController::CSV_MAX_SIZE | ||
end | ||
|
||
private | ||
|
||
def csv_template | ||
template_path.open | ||
end | ||
|
||
def template_path | ||
Rails.public_path.join(template_file.delete_prefix('/')) | ||
end | ||
end |
14 changes: 14 additions & 0 deletions
14
app/components/procedure/import_component/import_component.en.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
en: | ||
csv_import: | ||
import_file: Import file | ||
import_file_alert: All instructors added to the procedure will be notified by email. Do you want to continue? | ||
file_to_import: File to import | ||
file_size_limit: "File size limit : %{max_file_size}." | ||
groupes: | ||
title: Bulk Import / Export | ||
notice_1_html: For the import, your csv file must have <strong>2 columns (Group, Email)</strong> (see file model below). The file size must be less than %{csv_max_size}. | ||
notice_2_html: The import does not overwrite existing groups and instructors. It only allows you to <strong>add them</strong>. | ||
instructeurs: | ||
title: Adding instructors with file import | ||
notice_1_html: For the import, your csv file must have <strong>1 column (Email)</strong> listing the email addresses of the instructors (see file model below). The file size must be less than %{csv_max_size}. | ||
notice_2_html: The import does not overwrite existing instructors. It only allows you to <strong>add them</strong>. |
15 changes: 15 additions & 0 deletions
15
app/components/procedure/import_component/import_component.fr.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
fr: | ||
csv_import: | ||
import_file: Importer le fichier | ||
import_file_alert: Tous les instructeurs ajoutés à la procédure vont être notifiés par email. Voulez-vous continuer ? | ||
file_to_import: Fichier à importer | ||
download_template: Modèle à télécharger | ||
file_size_limit: "Taille maximale : %{max_file_size}." | ||
groupes: | ||
title: Ajout de groupes / instructeurs avec import de fichier | ||
notice_1_html: Pour l’import, votre fichier csv doit comporter <strong>2 colonnes (Groupe, Email)</strong> (voir modèle de fichier ci-dessous). Le poids du fichier doit être inférieur à %{csv_max_size}. | ||
notice_2_html: L’import n’écrase pas les groupes et instructeurs existants. Il permet uniquement <strong>d’en ajouter</strong>. | ||
instructeurs: | ||
title: Ajout d’instructeurs avec import de fichier | ||
notice_1_html: Pour l’import, votre fichier csv doit comporter <strong>1 seule colonne (Email)</strong> listant les adresses emails des instructeurs (voir modèle de fichier ci-dessous). Le poids du fichier doit être inférieur à %{csv_max_size}. | ||
notice_2_html: L’import n’écrase pas les instructeurs existants. Il permet uniquement <strong>d’en ajouter</strong>. |
23 changes: 23 additions & 0 deletions
23
app/components/procedure/import_component/import_component.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
%section.fr-accordion.fr-mb-3w | ||
%h3.fr-accordion__title | ||
%button.fr-accordion__btn{ "aria-controls" => "accordion-106", "aria-expanded" => "false" } | ||
= t(".csv_import.#{scope}.title") | ||
.fr-collapse#accordion-106 | ||
.notice.fr-mb-1w | ||
= t(".csv_import.#{scope}.notice_1_html", csv_max_size: number_to_human_size(csv_max_size)) | ||
.notice | ||
= t(".csv_import.#{scope}.notice_2_html") | ||
|
||
= form_tag import_admin_procedure_groupe_instructeurs_path(@procedure), method: :post, multipart: true, class: "mt-4 column", "data-controller" => "enable-submit-if-uploaded" do | ||
%label.fr-label.font-weight-bold | ||
= t('.csv_import.file_to_import') | ||
.fr-download | ||
= link_to template_file, {class: "fr-download__link", download: ''} do | ||
= t('.csv_import.download_template') | ||
%span.fr-download__detail | ||
= template_detail | ||
.fr-hint-text.fr-mb-1w | ||
= t('.csv_import.file_size_limit', max_file_size: number_to_human_size(csv_max_size)) | ||
.flex.column | ||
= file_field_tag :csv_file, required: true, accept: 'text/csv', size: "1", class: 'fr-mb-2w' | ||
= submit_tag t('.csv_import.import_file'), class: 'fr-btn fr-btn--tertiary', id: 'submit-button', data: { disable_with: "Envoi...", confirm: t('.csv_import.import_file_alert') }, disabled: true |
6 changes: 6 additions & 0 deletions
6
...ents/procedure/instructeurs_management_component/instructeurs_management_component.en.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
en: | ||
title: Instructors management | ||
notification_alert: | ||
non_publiee: Even if your procedure is still in test / unpublished, all the instructors you add to the procedure will be notified by email. | ||
publiee: All the instructors you add to the procedure will be notified by email. |
6 changes: 6 additions & 0 deletions
6
...ents/procedure/instructeurs_management_component/instructeurs_management_component.fr.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
fr: | ||
title: Gestion des instructeurs | ||
notification_alert: | ||
non_publiee: Même si votre démarche est encore en test / non publiée, tous les instructeurs que vous ajouterez à la démarche seront notifiés par email. | ||
publiee: Tous les instructeurs que vous ajouterez à la démarche seront notifiés par email. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
app/components/procedure/instructeurs_menu_component/instructeurs_menu_component.en.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
en: | ||
instructeurs: | ||
one: "%{count} instructor" | ||
other: "%{count} instructors" |
3 changes: 1 addition & 2 deletions
3
...nents/procedure/one_groupe_management_component/one_groupe_management_component.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
app/javascript/controllers/enable_submit_if_uploaded_controller.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Controller } from '@hotwired/stimulus'; | ||
import { enable, disable } from '@utils'; | ||
|
||
export class EnableSubmitIfUploadedController extends Controller { | ||
connect() { | ||
const fileInput = document.querySelector( | ||
'input[type="file"]' | ||
) as HTMLInputElement; | ||
const submitButton = document.getElementById( | ||
'submit-button' | ||
) as HTMLButtonElement; | ||
|
||
fileInput.addEventListener('change', function () { | ||
if (fileInput.files && fileInput.files.length > 0) { | ||
enable(submitButton); | ||
} else { | ||
disable(submitButton); | ||
} | ||
}); | ||
} | ||
} |
28 changes: 0 additions & 28 deletions
28
app/views/administrateurs/groupe_instructeurs/_import_export.html.haml
This file was deleted.
Oops, something went wrong.
25 changes: 17 additions & 8 deletions
25
app/views/administrateurs/groupe_instructeurs/_instructeurs.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,46 @@ | ||
|
||
.card | ||
= render Procedure::InvitationWithTypoComponent.new(maybe_typos: @maybe_typos, url: add_instructeur_admin_procedure_groupe_instructeur_path(@procedure, groupe_instructeur.id), title: "Avant d'ajouter l'email, veuillez confirmer" ) | ||
.card-title Affectation des instructeurs | ||
.card-title= t('.instructeur_assignation') | ||
= form_for :instructeur, url: { action: :add_instructeur, id: groupe_instructeur.id }, html: { class: 'form' } do |f| | ||
.instructeur-wrapper | ||
- if !procedure.routing_enabled? | ||
%p Entrez les adresses email des instructeurs que vous souhaitez affecter à cette démarche | ||
%p= t('.instructeur_emails') | ||
%p.fr-hint-text= t('.copy_paste_hint') | ||
|
||
- if disabled_as_super_admin | ||
= f.select :emails, available_instructeur_emails, {}, disabled: disabled_as_super_admin, id: 'instructeur_emails' | ||
- else | ||
%react-fragment | ||
= render ReactComponent.new 'ComboBox/MultiComboBox', items: available_instructeur_emails, id: 'instructeur_emails', name: 'emails[]', allows_custom_value: true, 'aria-label': 'Emails' | ||
|
||
= f.submit 'Affecter', class: 'fr-btn', disabled: disabled_as_super_admin | ||
= f.submit t('.assign'), class: 'fr-btn fr-btn--tertiary', disabled: disabled_as_super_admin | ||
|
||
%table.fr-table.fr-mt-2w.width-100 | ||
%hr.fr-mt-4w | ||
|
||
.flex.justify-between.align-baseline | ||
.card-title= t('.assigned_instructeur', count: instructeurs.count) | ||
= button_to export_groupe_instructeurs_admin_procedure_groupe_instructeurs_path(procedure, format: :csv), method: :get, class: 'fr-btn fr-btn--tertiary fr-btn--icon-left fr-icon-download-line' do | ||
Exporter la liste (.CSV) | ||
|
||
%table.fr-table.fr-table--bordered.width-100 | ||
%thead | ||
%tr | ||
%th{ colspan: 2 }= t('.assigned_instructeur', count: instructeurs.count) | ||
%th= t('.title') | ||
%th.text-right= t('.actions') | ||
%tbody | ||
- instructeurs.each do |instructeur| | ||
%tr | ||
%td | ||
= dsfr_icon('fr-icon-user-fill') | ||
= dsfr_icon('fr-icon-user-line') | ||
#{instructeur.email} | ||
|
||
- confirmation_message = procedure.routing_enabled? ? "Êtes-vous sûr de vouloir retirer l’instructeur « #{instructeur.email} » du groupe « #{groupe_instructeur.label} » ?" : "Êtes-vous sûr de vouloir retirer l’instructeur « #{instructeur.email} » de la démarche ?" | ||
%td.actions= button_to 'Retirer', | ||
%td.actions= button_to t('.remove'), | ||
{ action: :remove_instructeur, id: groupe_instructeur.id }, | ||
{ method: :delete, | ||
data: { confirm: confirmation_message }, | ||
params: { instructeur: { id: instructeur.id }}, | ||
class: 'fr-btn fr-btn--secondary' } | ||
class: 'fr-btn fr-btn--secondary fr-btn--icon-left fr-icon-subtract-line' } | ||
|
||
= paginate instructeurs, views_prefix: 'shared' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.