Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ETQ admin je suis informé des infos remontées par le champ SIRET #11013

Merged
merged 3 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions app/assets/stylesheets/flex.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,19 @@
.flex-1 {
flex: 1;
}

.two-column-list {
display: flex;
flex-wrap: wrap;

li {
flex: 0 0 50%;
box-sizing: border-box;
}

@media (max-width: 62em) {
li {
flex: 0 0 100%;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
fr:
en:
modal:
title: "Your file does not match submission criteria"
close: "Close"
close_alt: "Close this modal"
body: "The procedure « %{procedure_libelle} » have submission criteria, unfortunately your file does not match them. You can not submit your file"
title: 'Your file does not match submission criteria'
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
fr:
modal:
title: "Vous ne pouvez pas déposer votre dossier"
close: "Fermer"
close_alt: "Fermer la fenêtre modale"
title: 'Vous ne pouvez pas déposer votre dossier'
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
.fr-col-12.fr-col-md-8.fr-col-lg-6
.fr-modal__body
.fr-modal__header
%button.fr-btn--close.fr-btn{ aria: { controls: 'modal-eligibilite-rules-dialog' }, title: t('.modal.close_alt') }= t('.modal.close')
%button.fr-btn--close.fr-btn{ aria: { controls: 'modal-eligibilite-rules-dialog' }, title: t('utils.modal_close_alt') }= t('utils.modal_close')
.fr-modal__content
%h1#fr-modal-title-modal-1.fr-modal__title
%span.fr-icon-arrow-right-line.fr-icon--lg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
= form.label :type_champ, "Type de champ", for: dom_id(type_de_champ, :type_champ)
= form.select :type_champ, grouped_options_for_select(types_of_type_de_champ, type_de_champ.type_champ), {}, class: 'fr-select small-margin small inline width-100', id: dom_id(type_de_champ, :type_champ), disabled: coordinate.used_by_routing_rules? || coordinate.used_by_ineligibilite_rules?

- if type_de_champ.siret?
.cell.fr-mt-1w
= button_tag("Liste des informations remontées", type: :button, class: "fr-btn fr-icon-info-line fr-btn--icon-left fr-btn--tertiary-no-outline fr-btn--sm",
data: { "fr-opened" => "false", "turbo-frame" => "api-champ-columns", action: "lazy-modal#load" },
src: api_champ_columns_admin_procedure_path(id: procedure.id, stable_id: type_de_champ.stable_id),
"aria-controls" => "api-champ-columns-modal")

.flex.column.justify-start.flex-grow
.cell
.flex.align-center
Expand Down Expand Up @@ -66,7 +73,6 @@
= render Attachment::EditComponent.new(**notice_explicative_options)



.flex.justify-start.fr-mt-1w.flex-gap
- if type_de_champ.any_drop_down_list?
.flex.column.justify-start.width-33
Expand Down
22 changes: 21 additions & 1 deletion app/controllers/administrateurs/procedures_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
layout 'all', only: [:all, :administrateurs]
respond_to :html, :xlsx

before_action :retrieve_procedure, only: [:champs, :annotations, :modifications, :edit, :zones, :monavis, :update_monavis, :accuse_lecture, :update_accuse_lecture, :jeton, :update_jeton, :publication, :publish, :transfert, :close, :confirmation, :allow_expert_review, :allow_expert_messaging, :experts_require_administrateur_invitation, :reset_draft, :publish_revision, :check_path]
before_action :retrieve_procedure, only: [:champs, :annotations, :modifications, :edit, :zones, :monavis, :update_monavis, :accuse_lecture, :update_accuse_lecture, :jeton, :update_jeton, :publication, :publish, :transfert, :close, :confirmation, :allow_expert_review, :allow_expert_messaging, :experts_require_administrateur_invitation, :reset_draft, :publish_revision, :check_path, :api_champ_columns]
before_action :draft_valid?, only: [:apercu]
after_action :reset_procedure, only: [:update]

Expand Down Expand Up @@ -422,6 +422,26 @@
@admins = paginate(@admins, 'users.email')
end

def api_champ_columns
_, @type_de_champ = @procedure.draft_revision.coordinate_and_tdc(params[:stable_id])
regex_prefix = /^#{Regexp.escape(@type_de_champ.libelle)}([^\p{L}]+SIRET)?[^\p{L}]+/

Check warning on line 427 in app/controllers/administrateurs/procedures_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/administrateurs/procedures_controller.rb#L426-L427

Added lines #L426 - L427 were not covered by tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

je trouve ça dommage de sortir de la grosse artillerie alors qu'on a l'information.

contre proposition

  • on ajoute les attributs prefix et name aux colonnes
  • on définit def label = prefix + name

et tu fais un simple filter_map { _1.name }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Au départ j'étais parti sur un truc dans ce genre là. Ça amenait bcp de code "juste pour ça" ici surtout que c'est plus qu'une histoire de préfixe. Je sais plus bien mais ya déjà une notion de prefix et label qui a une logique un peu différente, ça menait de la confusion et exposait de nouvelles méthodes publiques. Avec je sais plus qui on était pas chaud pour changer le contrat maintenant.

Par contre sur le moyen terme quand on aura déployé ça à autre tdc , le bloc personne morale etc, et qu'on y verra plus clair sur nos besoins, on pourra carrément un plan plus uniforme


@column_labels = @type_de_champ

Check warning on line 429 in app/controllers/administrateurs/procedures_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/administrateurs/procedures_controller.rb#L429

Added line #L429 was not covered by tests
.columns(procedure: @procedure)
.filter_map do |column|
# Remove tdc libelle prefix added in columns:
# Numéro SIRET - Entreprise SIREN => Entreprise SIREN
column.label.sub(regex_prefix, '')

Check warning on line 434 in app/controllers/administrateurs/procedures_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/administrateurs/procedures_controller.rb#L434

Added line #L434 was not covered by tests
end

if @type_de_champ.type_champ == "siret"
@column_labels.concat Etablissement::EXPORTABLE_COLUMNS.dup.map { I18n.t(_1, scope: [:activerecord, :attributes, :procedure_presentation, :fields, :etablissement]) }

# Hardcode non columns data
@column_labels << "Bilans BDF"

Check warning on line 441 in app/controllers/administrateurs/procedures_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/administrateurs/procedures_controller.rb#L441

Added line #L441 was not covered by tests
end
end

private

def paginated_published_procedures
Expand Down
21 changes: 21 additions & 0 deletions app/javascript/controllers/lazy_modal_controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ApplicationController } from './application_controller';

interface HTMLTurboFrameElement extends HTMLElement {
src: string | null;
}

export default class LazyModalController extends ApplicationController {
static targets = ['frame'];

declare readonly frameTarget: HTMLTurboFrameElement;

load(event: Event): void {
const button = event.currentTarget as HTMLButtonElement;
const frame = this.frameTarget;

const src = button.getAttribute('src');
if (src) {
frame.src = src;
}
}
}
26 changes: 1 addition & 25 deletions app/models/concerns/columns_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,31 +162,7 @@ def moral_columns

others = %w[code_postal].map { |column| dossier_col(table: 'etablissement', column:) }

for_export = %w[
siege_social
code_naf
adresse
numero_voie
type_voie
nom_voie
complement_adresse
localite
code_insee_localite
entreprise_capital_social
entreprise_numero_tva_intracommunautaire
entreprise_forme_juridique_code
entreprise_code_effectif_entreprise
entreprise_etat_administratif
entreprise_siret_siege_social
entreprise_nom
entreprise_prenom
association_rna
association_titre
association_objet
association_date_creation
association_date_declaration
association_date_publication
].map { |column| dossier_col(table: 'etablissement', column:, displayable: false, filterable: false) }
for_export = Etablissement::EXPORTABLE_COLUMNS.map { |column| dossier_col(table: 'etablissement', column:) }

[siret_column, etablissements, others, for_export].flatten
end
Expand Down
26 changes: 26 additions & 0 deletions app/models/etablissement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,32 @@ class Etablissement < ApplicationRecord
"libelle_naf" => { type: :text }
}.freeze

EXPORTABLE_COLUMNS = %w[
siege_social
code_naf
adresse
numero_voie
type_voie
nom_voie
complement_adresse
localite
code_insee_localite
entreprise_capital_social
entreprise_numero_tva_intracommunautaire
entreprise_forme_juridique_code
entreprise_code_effectif_entreprise
entreprise_etat_administratif
entreprise_siret_siege_social
entreprise_nom
entreprise_prenom
association_rna
association_titre
association_objet
association_date_creation
association_date_declaration
association_date_publication
].freeze

def entreprise_raison_sociale
read_attribute(:entreprise_raison_sociale).presence || raison_sociale_for_ei
end
Expand Down
16 changes: 16 additions & 0 deletions app/views/administrateurs/procedures/api_champ_columns.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
= turbo_frame_tag("api-champ-columns") do
%h1#fr-modal-api-champ-columns-h1.fr-modal__title
= t('.title', type_de_champ: t(@type_de_champ.type_champ, scope: 'activerecord.attributes.type_de_champ.type_champs'))

%p.fr-hint-text
= t('.hint_html')

%ul.two-column-list.fr-mb-3w
- @column_labels.each do |label|
%li= label.upcase_first

- if @type_de_champ.type_champ == "siret"
%p.fr-hint-text
Nous affichons aussi aux instructeurs un lien vers l’annuaire de l‘entreprise,
qui comporte davantage d’informations comme des données équivalentes aux extraits KBIS.
= link_to("Voir un exemple", annuaire_link("35600000000048"), **external_link_attributes)
13 changes: 12 additions & 1 deletion app/views/administrateurs/procedures/champs.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,20 @@
= render NestedForms::FormOwnerComponent.new
.fr-grid-row
= render TypesDeChampEditor::HeaderSectionsSummaryComponent.new(procedure: @procedure, is_private: false)
.fr-col
.fr-col{ data: { controller: "lazy-modal" } }
= render TypesDeChampEditor::EditorComponent.new(revision: @procedure.draft_revision, is_annotation: false)

%dialog#api-champ-columns-modal.fr-modal{ "aria-labelledby" => 'fr-modal-api-champ-columns-h1', role: "dialog" }
.fr-container.fr-container--fluid.fr-container-md
.fr-grid-row.fr-grid-row--center
.fr-col-12.fr-col-md-8
.fr-modal__body
.fr-modal__header
%button.fr-btn--close.fr-btn{ aria: { controls: "api-champ-columns-modal" }, title: t('utils.modal_close_alt') }= t('utils.modal_close')
.fr-modal__content
= turbo_frame_tag "api-champ-columns", data: { "lazy-modal-target": "frame" }


.padded-fixed-footer
.fixed-footer
.fr-container
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_display_theme_modal.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.fr-col-12.fr-col-md-6.fr-col-lg-4
.fr-modal__body
.fr-modal__header
%button#button-5622.fr-btn--close.fr-btn{ "aria-controls" => "fr-theme-modal", title: "Fermer" } Fermer
%button#button-5622.fr-btn--close.fr-btn{ "aria-controls" => "fr-theme-modal", title: t('utils.modal_close_alt') }= t('utils.modal_close')
.fr-modal__content
%h1#fr-theme-modal-title.fr-modal__title Paramètres d’affichage
#fr-display.fr-display
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_header.haml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

#modal-header__menu.fr-header__menu.fr-modal{ "aria-labelledby": "navbar-burger-button" }
.fr-container
%button.fr-btn--close.fr-btn{ "aria-controls" => "modal-header__menu", title: t('close_modal', scope: [:layouts, :header]) }= t('close_modal', scope: [:layouts, :header])
%button.fr-btn--close.fr-btn{ "aria-controls" => "modal-header__menu", title: t('utils.modal_close_alt') }= t('utils.modal_close')
.fr-header__menu-links
-# populated by dsfr js

Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_search_dossiers_form.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#search-modal.fr-header__search.fr-modal{ "aria-label": t('views.users.dossiers.search.search_file') }
.fr-container.fr-container-lg--fluid
%button.fr-btn--close.fr-btn{ "aria-controls" => "search-modal", :title => t('close_modal', scope: [:layouts, :header]) }= t('close_modal', scope: [:layouts, :header])
%button.fr-btn--close.fr-btn{ "aria-controls" => "search-modal", title: t('utils.modal_close_alt') }= t('utils.modal_close')
#search-473.fr-search-bar.fr-search-bar--lg
= form_tag recherche_index_path, method: :get, :role => "search", class: "flex width-100" do
= hidden_field_tag :context, local_assigns[:context]
Expand Down
3 changes: 2 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ en:
no_mandatory: (optional)
send_mail: Send message
new_tab: New tab
modal_close: "Close"
modal_close_alt: "Close this modal"
helpers:
procedure:
testing_procedure: testing procedure
Expand All @@ -80,7 +82,6 @@ en:
are_you_new: First time on %{app_name}?
my_account: My account
header:
close_modal: 'Close'
back: "Back"
back_title: "Back to my administration's website"
main_menu: "Main menu"
Expand Down
3 changes: 2 additions & 1 deletion config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ fr:
no_mandatory: (facultatif)
send_mail: Envoyer le message
new_tab: "Nouvel onglet"
modal_close: "Fermer"
modal_close_alt: "Fermer la fenêtre modale"
helpers:
procedure:
testing_procedure: démarche en test
Expand All @@ -71,7 +73,6 @@ fr:
are_you_new: Vous êtes nouveau sur %{app_name} ?
my_account: Mon compte
header:
close_modal: 'Fermer'
back: "Revenir en arrière"
back_title: "Revenir en arrière, sur le site de mon administration"
main_menu: "Menu principal"
Expand Down
5 changes: 5 additions & 0 deletions config/locales/views/administrateurs/procedures/en.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
en:
administrateurs:
procedures:
api_champ_columns:
title: 'Informations complementary to the field %{type_de_champ}'
hint_html: |
The following data is automatically retrieved via API and displayed in files or exports.
<strong>No need to ask the user for this information in other fields!</strong>
close:
page_title: Close the procedure
replacement_procedure_callout_title: You are about to close a procedure
Expand Down
7 changes: 6 additions & 1 deletion config/locales/views/administrateurs/procedures/fr.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
fr:
administrateurs:
procedures:
api_champ_columns:
title: 'Informations complémentaires au champ %{type_de_champ}'
hint_html: |
Les données suivantes sont automatiquement récupérées par API et affichées dans les dossiers ou exports.
<strong> Inutile de les redemander à l’usager dans d’autres champs !</strong>
close:
page_title: Clore la démarche
replacement_procedure_callout_title: Vous êtes sur le point de clore une démarche
Expand All @@ -19,7 +24,7 @@ fr:
other: Souhaitez-vous envoyer un email aux %{count} utilisateurs avec un dossier en brouillon ?
email_content_brouillon: Contenu de l'email
email_toggle_en_cours:
one : Souhaitez-vous envoyer un email à l'utilisateur avec un dossier déposé ?
one: Souhaitez-vous envoyer un email à l'utilisateur avec un dossier déposé ?
other: Souhaitez-vous envoyer un email aux %{count} utilisateurs avec un dossier déposé ?
email_content_en_cours: Contenu de l'email
preview_unavailable: Aperçu non disponible car la démarche est mal configurée
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@
put :allow_expert_messaging
put :experts_require_administrateur_invitation
put :restore
get 'api_champ_columns'
end

get :api_particulier, controller: 'jeton_particulier'
Expand Down
25 changes: 25 additions & 0 deletions spec/system/administrateurs/types_de_champ_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -413,4 +413,29 @@
expect(page).not_to have_selector('.sticky-header.sticky-header-warning')
end
end

context "SIRET field modal" do
let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :siret, libelle: "SIRET de test" }]) }

scenario "loads modal content only when clicked" do
visit champs_admin_procedure_path(procedure)

expect(page).not_to have_content("Informations complémentaires au champ Numéro Siret")

click_button "Liste des informations remontées"

within "#api-champ-columns-modal" do
expect(page).to have_content("Informations complémentaires au champ Numéro Siret")
expect(page).to have_content("Entreprise raison sociale")
expect(page).not_to have_content("SIRET de test – Commune") # no champ libelle

click_button "Fermer"
end

expect(page).not_to have_selector("#api-champ-columns-modal[open]")

click_button "Liste des informations remontées"
expect(page).to have_content("Informations complémentaires au champ Numéro Siret")
end
end
end
Loading