From df71c6a68916934c20168a0440f1a80e1862c4a9 Mon Sep 17 00:00:00 2001 From: Christophe Robillard Date: Fri, 25 Oct 2024 14:09:14 +0200 Subject: [PATCH 01/15] align columns naming and order for filter and add for export Co-authored-by: mfo --- app/models/concerns/columns_concern.rb | 109 +++++++++++---- app/models/dossier.rb | 4 + .../models/procedure_presentation/en.yml | 50 ++++++- .../models/procedure_presentation/fr.yml | 64 +++++++-- ...edure_presentation_to_columns.rake_spec.rb | 2 +- spec/models/concerns/columns_concern_spec.rb | 128 +++++++++++++++++- spec/models/export_spec.rb | 4 +- spec/models/procedure_presentation_spec.rb | 6 +- spec/services/dossier_filter_service_spec.rb | 38 +++--- .../dossier_projection_service_spec.rb | 8 +- .../instructeurs/procedure_filters_spec.rb | 4 +- 11 files changed, 338 insertions(+), 79 deletions(-) diff --git a/app/models/concerns/columns_concern.rb b/app/models/concerns/columns_concern.rb index 943d772a7..78a533a7c 100644 --- a/app/models/concerns/columns_concern.rb +++ b/app/models/concerns/columns_concern.rb @@ -25,49 +25,97 @@ module ColumnsConcern columns.concat(standard_columns) columns.concat(individual_columns) if for_individual columns.concat(moral_columns) if !for_individual + columns.concat(chorus_columns) columns.concat(types_de_champ_columns) end end + def chorus_columns + if chorusable? && chorus_configuration.complete? + ['domaine_fonctionnel', 'referentiel_prog', 'centre_de_cout'] + .map { |column| Column.new(procedure_id: id, table: 'procedure', column:, displayable: false, filterable: false) } + else + [] + end + end + + def all_usager_columns_for_export + common = [ + dossier_id_column, + Column.new(procedure_id: id, table: 'self', column: 'user_email_for_display', filterable: false, displayable: false), + Column.new(procedure_id: id, table: 'self', column: 'user_from_france_connect?', filterable: false, displayable: false) + ] + + individual_or_moral_columns = for_individual? ? individual_columns : moral_columns + + [common, individual_or_moral_columns, chorus_columns].flatten.compact + end + + def all_dossier_columns_for_export + states = [dossier_state_column] + + for_export_before_date = ['archived'] + .map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :text, displayable: false, filterable: false) } + for_export_after_date = ['motivation'] + .map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :text, displayable: false, filterable: false) } + routing = + if self.routing_enabled? + [Column.new(procedure_id: id, table: 'groupe_instructeur', column: 'id')] + else + [] + end + + instructeurs = [Column.new(procedure_id: id, table: 'followers_instructeurs', column: 'email')] + + [states, for_export_before_date, dossier_dates_columns, for_export_after_date, sva_svr_columns(for_export: true), routing, instructeurs].flatten.compact + end + def dossier_id_column - Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'id', type: :number) + Column.new(procedure_id: id, table: 'self', column: 'id', type: :number) end def dossier_state_column - Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'state', type: :enum, scope: 'instructeurs.dossiers.filterable_state', displayable: false) + Column.new(procedure_id: id, table: 'self', column: 'state', label: I18n.t('activerecord.attributes.procedure_presentation.fields.self.state'), type: :enum, scope: 'instructeurs.dossiers.filterable_state', displayable: false) end def notifications_column - Columns::DossierColumn.new(procedure_id: id, table: 'notifications', column: 'notifications', label: "notifications", filterable: false) + Column.new(procedure_id: id, table: 'notifications', column: 'notifications', label: "notifications", filterable: false) end def dossier_columns common = [dossier_id_column, notifications_column] - dates = ['created_at', 'updated_at', 'depose_at', 'en_construction_at', 'en_instruction_at', 'processed_at'] - .map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'self', column:, type: :date) } - - non_displayable_dates = ['updated_since', 'depose_since', 'en_construction_since', 'en_instruction_since', 'processed_since'] - .map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'self', column:, type: :date, displayable: false) } - states = [dossier_state_column] - [common, dates, sva_svr_columns, non_displayable_dates, states].flatten.compact + non_displayable_dates = ['updated_since', 'depose_since', 'en_construction_since', 'en_instruction_since', 'processed_since'] + .map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :date, displayable: false) } + + for_export_before_date = ['archived'] + .map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :text, displayable: false, filterable: false) } + for_export_after_date = ['motivation'] + .map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :text, displayable: false, filterable: false) } + + [common, states, for_export_before_date, dossier_dates_columns, for_export_after_date, sva_svr_columns(for_export: false), non_displayable_dates].flatten.compact end - def sva_svr_columns + def dossier_dates_columns + ['created_at', 'updated_at', 'last_champ_updated_at', 'depose_at', 'en_construction_at', 'en_instruction_at', 'processed_at'] + .map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :date) } + end + + def sva_svr_columns(for_export: false) return if !sva_svr_enabled? scope = [:activerecord, :attributes, :procedure_presentation, :fields, :self] columns = [ - Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'sva_svr_decision_on', type: :date, - label: I18n.t("#{sva_svr_decision}_decision_on", scope:)) + Column.new(procedure_id: id, table: 'self', column: 'sva_svr_decision_on', type: :date, + label: I18n.t("#{sva_svr_decision}_decision_on", scope:, type: sva_svr_configuration.human_decision)) ] - - columns << Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'sva_svr_decision_before', type: :date, displayable: false, - label: I18n.t("#{sva_svr_decision}_decision_before", scope:)) - + if !for_export + columns << Column.new(procedure_id: id, table: 'self', column: 'sva_svr_decision_before', type: :date, displayable: false, + label: I18n.t("#{sva_svr_decision}_decision_before", scope:)) + end columns end @@ -80,31 +128,38 @@ module ColumnsConcern private def email_column - Columns::DossierColumn.new(procedure_id: id, table: 'user', column: 'email') + Column.new(procedure_id: id, table: 'user', column: 'email') end def standard_columns [ email_column, - Columns::DossierColumn.new(procedure_id: id, table: 'followers_instructeurs', column: 'email'), - Columns::DossierColumn.new(procedure_id: id, table: 'groupe_instructeur', column: 'id', type: :enum), - Columns::DossierColumn.new(procedure_id: id, table: 'avis', column: 'question_answer', filterable: false) # not filterable ? + Column.new(procedure_id: id, table: 'self', column: 'user_email_for_display', filterable: false, displayable: false), + Column.new(procedure_id: id, table: 'followers_instructeurs', column: 'email'), + Column.new(procedure_id: id, table: 'groupe_instructeur', column: 'id', type: :enum), + Column.new(procedure_id: id, table: 'avis', column: 'question_answer', filterable: false), + Column.new(procedure_id: id, table: 'user', column: 'id', filterable: false, displayable: false), + Column.new(procedure_id: id, table: 'self', column: 'user_from_france_connect?', filterable: false, displayable: false) ] end def individual_columns - ['nom', 'prenom', 'gender'].map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'individual', column:) } + ['gender', 'nom', 'prenom'].map { |column| Column.new(procedure_id: id, table: 'individual', column:) } + .concat ['for_tiers', 'mandataire_last_name', 'mandataire_first_name'].map { |column| Column.new(procedure_id: id, table: 'self', column:) } end def moral_columns - etablissements = ['entreprise_siren', 'entreprise_forme_juridique', 'entreprise_nom_commercial', 'entreprise_raison_sociale', 'entreprise_siret_siege_social'] - .map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'etablissement', column:) } + etablissements = ['entreprise_forme_juridique', 'entreprise_siren', 'entreprise_nom_commercial', 'entreprise_raison_sociale', 'entreprise_siret_siege_social'] + .map { |column| Column.new(procedure_id: id, table: 'etablissement', column:) } - etablissement_dates = ['entreprise_date_creation'].map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'etablissement', column:, type: :date) } + etablissement_dates = ['entreprise_date_creation'].map { |column| Column.new(procedure_id: id, table: 'etablissement', column:, type: :date) } - other = ['siret', 'libelle_naf', 'code_postal'].map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'etablissement', column:) } + for_export = ["siege_social", "naf", "adresse", "numero_voie", "type_voie", "nom_voie", "complement_adresse", "localite", "code_insee_localite", "entreprise_siren", "entreprise_capital_social", "entreprise_numero_tva_intracommunautaire", "entreprise_forme_juridique_code", "entreprise_code_effectif_entreprise", "entreprise_etat_administratif", "entreprise_nom", "entreprise_prenom", "association_rna", "association_titre", "association_objet", "association_date_creation", "association_date_declaration", "association_date_publication"] + .map { |column| Column.new(procedure_id: id, table: 'etablissement', column:, displayable: false, filterable: false) } - [etablissements, etablissement_dates, other].flatten + other = ['siret', 'libelle_naf', 'code_postal'].map { |column| Column.new(procedure_id: id, table: 'etablissement', column:) } + + [etablissements, etablissement_dates, other, for_export].flatten end def types_de_champ_columns diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 90ca00d4f..2f9a469aa 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -450,6 +450,10 @@ class Dossier < ApplicationRecord end end + def user_email_for_display + user_email_for(:display) + end + def expiration_started? [ brouillon_close_to_expiration_notice_sent_at, diff --git a/config/locales/models/procedure_presentation/en.yml b/config/locales/models/procedure_presentation/en.yml index 069e2853e..fc12fb311 100644 --- a/config/locales/models/procedure_presentation/en.yml +++ b/config/locales/models/procedure_presentation/en.yml @@ -5,24 +5,34 @@ en: fields: self: id: File Nº + user_email_for_display: Email state: State created_at: Created on updated_at: Updated on depose_at: First submission on en_construction_at: Submitted on - en_instruction_at: En instruction on + en_instruction_at: Instructed on processed_at: Done on depose_since: First Submission since updated_since: Updated since en_construction_since: Submitted since en_instruction_since: Instructed since processed_since: Finished since - sva_decision_on: SVA decision date + sva_decision_on: Date décision %{type} sva_decision_before: SVA decision date before - svr_decision_on: SVR decision date + svr_decision_on: Date décision %{type} svr_decision_before: SVR decision date before + user_from_france_connect?: "FranceConnect ?" + for_tiers: "For tiers" + mandataire_last_name: "Tier last name" + mandataire_first_name: "Tier first name" user: + id: User Id email: Requester + procedure: + domaine_fonctionnel: Domaine Fonctionnel + referentiel_prog: Référentiel De Programmation + centre_de_cout: Centre De Coût followers_instructeurs: email: Email instructeur groupe_instructeur: @@ -36,12 +46,38 @@ en: answer: Opinion question_answer: Opinion yes/no etablissement: - entreprise_siren: SIREN + entreprise_etat_administratif: 'Entreprise état administratif' entreprise_forme_juridique: Forme juridique entreprise_nom_commercial: Commercial name entreprise_raison_sociale: Raison sociale entreprise_siret_siege_social: SIRET siège social - entreprise_date_creation: Creation date - siret: SIRET + entreprise_date_creation: Entreprise date de création + siret: Établissement SIRET libelle_naf: Libellé NAF - code_postal: Postal code + siege_social: "Établissement siège social" + naf: "Établissement NAF" + adresse: "Établissement Adresse" + numero_voie: "Établissement numero voie" + type_voie: "Établissement type voie" + nom_voie: "Établissement nom voie" + complement_adresse: "Établissement complément adresse" + code_postal: "Établissement code postal" + localite: "Établissement localité" + code_insee_localite: "Établissement code INSEE localité" + entreprise_siren: SIREN + entreprise_capital_social: "Entreprise capital social" + entreprise_numero_tva_intracommunautaire: "Entreprise numero TVA intracommunautaire" + entreprise_forme_juridique: "Entreprise forme juridique" + entreprise_forme_juridique_code: "Entreprise forme juridique code" + entreprise_nom_commercial: "Entreprise nom commercial" + entreprise_raison_sociale: "Entreprise raison sociale" + entreprise_siret_siege_social: "Entreprise SIRET siège social" + entreprise_code_effectif_entreprise: "Entreprise code effectif entreprise" + entreprise_nom: 'Entreprise nom' + entreprise_prenom: 'Entreprise prénom' + association_rna: 'Association RNA' + association_titre: 'Association titre' + association_objet: 'Association objet' + association_date_creation: 'Association date de création' + association_date_declaration: 'Association date de déclaration' + association_date_publication: 'Association date de publication' diff --git a/config/locales/models/procedure_presentation/fr.yml b/config/locales/models/procedure_presentation/fr.yml index a5e3fe196..c6fba136f 100644 --- a/config/locales/models/procedure_presentation/fr.yml +++ b/config/locales/models/procedure_presentation/fr.yml @@ -5,26 +5,40 @@ fr: fields: self: id: Nº dossier - state: Statut + user_email_for_display: Email + state: État du dossier created_at: Créé le - updated_at: Mis à jour le + updated_at: Dernière mise à jour le depose_at: Déposé le - en_construction_at: En construction le - en_instruction_at: En instruction le - processed_at: Terminé le + en_construction_at: Passé en construction le + en_instruction_at: Passé en instruction le + processed_at: Traité le updated_since: Mis à jour depuis depose_since: Déposé depuis en_construction_since: En construction depuis en_instruction_since: En instruction depuis processed_since: Terminé depuis - sva_decision_on: Date décision SVA + sva_decision_on: Date décision %{type} sva_decision_before: Date décision SVA avant - svr_decision_on: Date décision SVR + svr_decision_on: Date décision %{type} svr_decision_before: Date décision SVR avant + user_from_france_connect?: "FranceConnect ?" + for_tiers: "Dépôt pour un tiers" + mandataire_last_name: "Nom du mandataire" + mandataire_first_name: "Prénom du mandataire" + archived: 'Archivé' + dossier_state: 'État du dossier' + last_champ_updated_at: 'Dernière mise à jour du dossier le' + motivation: 'Motivation de la décision' user: + id: Identifiant du demandeur email: Demandeur + procedure: + domaine_fonctionnel: Domaine Fonctionnel + referentiel_prog: Référentiel De Programmation + centre_de_cout: Centre De Coût followers_instructeurs: - email: Email instructeur + email: Instructeurs groupe_instructeur: id: Groupe instructeur label: Groupe instructeur @@ -36,12 +50,38 @@ fr: answer: Avis question_answer: Avis oui/non etablissement: - entreprise_siren: SIREN + entreprise_etat_administratif: 'Entreprise état administratif' entreprise_forme_juridique: Forme juridique entreprise_nom_commercial: Nom commercial entreprise_raison_sociale: Raison sociale entreprise_siret_siege_social: SIRET siège social - entreprise_date_creation: Date de création - siret: SIRET + entreprise_date_creation: Entreprise date de création + siret: Établissement SIRET libelle_naf: Libellé NAF - code_postal: Code postal + siege_social: "Établissement siège social" + naf: "Établissement NAF" + adresse: "Établissement Adresse" + numero_voie: "Établissement numero voie" + type_voie: "Établissement type voie" + nom_voie: "Établissement nom voie" + complement_adresse: "Établissement complément adresse" + code_postal: "Établissement code postal" + localite: "Établissement localité" + code_insee_localite: "Établissement code INSEE localité" + entreprise_siren: "Entreprise SIREN" + entreprise_capital_social: "Entreprise capital social" + entreprise_numero_tva_intracommunautaire: "Entreprise numero TVA intracommunautaire" + entreprise_forme_juridique: "Entreprise forme juridique" + entreprise_forme_juridique_code: "Entreprise forme juridique code" + entreprise_nom_commercial: "Entreprise nom commercial" + entreprise_raison_sociale: "Entreprise raison sociale" + entreprise_siret_siege_social: "Entreprise SIRET siège social" + entreprise_code_effectif_entreprise: "Entreprise code effectif entreprise" + entreprise_nom: 'Entreprise nom' + entreprise_prenom: 'Entreprise prénom' + association_rna: 'Association RNA' + association_titre: 'Association titre' + association_objet: 'Association objet' + association_date_creation: 'Association date de création' + association_date_declaration: 'Association date de déclaration' + association_date_publication: 'Association date de publication' diff --git a/spec/lib/tasks/deployment/20240920130741_migrate_procedure_presentation_to_columns.rake_spec.rb b/spec/lib/tasks/deployment/20240920130741_migrate_procedure_presentation_to_columns.rake_spec.rb index 795736c26..1e2dfcc10 100644 --- a/spec/lib/tasks/deployment/20240920130741_migrate_procedure_presentation_to_columns.rake_spec.rb +++ b/spec/lib/tasks/deployment/20240920130741_migrate_procedure_presentation_to_columns.rake_spec.rb @@ -38,7 +38,7 @@ describe '20240920130741_migrate_procedure_presentation_to_columns.rake' do it 'populates the columns' do procedure_id = procedure.id - expect(procedure_presentation.displayed_columns.map(&:label)).to eq(["Raison sociale", procedure.active_revision.types_de_champ.first.libelle]) + expect(procedure_presentation.displayed_columns.map(&:label)).to eq(["Entreprise raison sociale", procedure.active_revision.types_de_champ.first.libelle]) order, column_id = procedure_presentation .sorted_column diff --git a/spec/models/concerns/columns_concern_spec.rb b/spec/models/concerns/columns_concern_spec.rb index 27d062f32..7a518f0fa 100644 --- a/spec/models/concerns/columns_concern_spec.rb +++ b/spec/models/concerns/columns_concern_spec.rb @@ -29,7 +29,7 @@ describe ColumnsConcern do let(:tdc_private_2) { procedure.active_revision.types_de_champ_private[1] } let(:expected) { [ - { label: 'Nº dossier', table: 'self', column: 'id', displayable: true, type: :number, scope: '', value_column: :value, filterable: true }, + { label: 'Dossier ID', table: 'self', column: 'id', displayable: true, type: :number, scope: '', value_column: :value, filterable: true }, { label: 'notifications', table: 'notifications', column: 'notifications', displayable: true, type: :text, scope: '', value_column: :value, filterable: false }, { label: 'Créé le', table: 'self', column: 'created_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true }, { label: 'Mis à jour le', table: 'self', column: 'updated_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true }, @@ -43,10 +43,15 @@ describe ColumnsConcern do { label: "En instruction depuis", table: "self", column: "en_instruction_since", displayable: false, type: :date, scope: '', value_column: :value, filterable: true }, { label: "Terminé depuis", table: "self", column: "processed_since", displayable: false, type: :date, scope: '', value_column: :value, filterable: true }, { label: "Statut", table: "self", column: "state", displayable: false, scope: 'instructeurs.dossiers.filterable_state', type: :enum, value_column: :value, filterable: true }, + { label: "Archivé", table: "self", column: "archived", displayable: false, scope: '', type: :text, value_column: :value, filterable: false }, + { label: "Motivation de la décision", table: "self", column: "motivation", displayable: false, scope: '', type: :text, value_column: :value, filterable: false }, + { label: "Dernière mise à jour du dossier le", table: "self", column: "last_champ_updated_at", displayable: false, scope: '', type: :text, value_column: :value, filterable: false }, { label: 'Demandeur', table: 'user', column: 'email', displayable: true, type: :text, scope: '', value_column: :value, filterable: true }, { label: 'Email instructeur', table: 'followers_instructeurs', column: 'email', displayable: true, type: :text, scope: '', value_column: :value, filterable: true }, { label: 'Groupe instructeur', table: 'groupe_instructeur', column: 'id', displayable: true, type: :enum, scope: '', value_column: :value, filterable: true }, { label: 'Avis oui/non', table: 'avis', column: 'question_answer', displayable: true, type: :text, scope: '', value_column: :value, filterable: false }, + { label: 'Identifiant du demandeur', table: 'user', column: 'id', displayable: false, type: :text, scope: '', value_column: :value, filterable: false }, + { label: 'FranceConnect ?', table: 'self', column: 'user_from_france_connect?', displayable: false, type: :text, scope: '', value_column: :value, filterable: false }, { label: 'SIREN', table: 'etablissement', column: 'entreprise_siren', displayable: true, type: :text, scope: '', value_column: :value, filterable: true }, { label: 'Forme juridique', table: 'etablissement', column: 'entreprise_forme_juridique', displayable: true, type: :text, scope: '', value_column: :value, filterable: true }, { label: 'Nom commercial', table: 'etablissement', column: 'entreprise_nom_commercial', displayable: true, type: :text, scope: '', value_column: :value, filterable: true }, @@ -73,7 +78,11 @@ describe ColumnsConcern do procedure.active_revision.types_de_champ_private[3].update_attribute(:type_champ, TypeDeChamp.type_champs.fetch(:explication)) end - it { expect(subject).to eq(expected) } + it { + expected.each do |expected| + expect(subject).to include(expected) + end + } end context 'with rna' do @@ -125,4 +134,119 @@ describe ColumnsConcern do it { is_expected.to include(decision_on, decision_before_field) } end end + + describe 'export' do + let(:procedure) { create(:procedure_with_dossiers, :published, types_de_champ_public:, for_individual:) } + let(:for_individual) { true } + let(:types_de_champ_public) do + [ + { type: :text, libelle: "Ca va ?", mandatory: true, stable_id: 1 }, + { type: :communes, libelle: "Commune", mandatory: true, stable_id: 17 }, + { type: :siret, libelle: 'siret', stable_id: 20 }, + { type: :repetition, mandatory: true, stable_id: 7, libelle: "Champ répétable", children: [{ type: 'text', libelle: 'Qqchose à rajouter?', stable_id: 8 }] } + ] + end + + describe '#all_usager_columns_for_export' do + context 'for individual procedure' do + let(:for_individual) { true } + + it "returns all usager columns" do + expected = [ + procedure.find_column(label: "Nº dossier"), + procedure.find_column(label: "Email"), + procedure.find_column(label: "FranceConnect ?"), + procedure.find_column(label: "Civilité"), + procedure.find_column(label: "Nom"), + procedure.find_column(label: "Prénom"), + procedure.find_column(label: "Dépôt pour un tiers"), + procedure.find_column(label: "Nom du mandataire"), + procedure.find_column(label: "Prénom du mandataire") + ] + actuals = procedure.all_usager_columns_for_export.map(&:h_id) + expected.each do |expected_col| + expect(actuals).to include(expected_col.h_id) + end + end + end + + context 'for entreprise procedure' do + let(:for_individual) { false } + + it "returns all usager columns" do + expected = [ + procedure.find_column(label: "Nº dossier"), + procedure.find_column(label: "Email"), + procedure.find_column(label: "FranceConnect ?"), + procedure.find_column(label: "Établissement SIRET"), + procedure.find_column(label: "Établissement siège social"), + procedure.find_column(label: "Établissement NAF"), + procedure.find_column(label: "Libellé NAF"), + procedure.find_column(label: "Établissement Adresse"), + procedure.find_column(label: "Établissement numero voie"), + procedure.find_column(label: "Établissement type voie"), + procedure.find_column(label: "Établissement nom voie"), + procedure.find_column(label: "Établissement complément adresse"), + procedure.find_column(label: "Établissement code postal"), + procedure.find_column(label: "Établissement localité"), + procedure.find_column(label: "Établissement code INSEE localité"), + procedure.find_column(label: "Entreprise SIREN"), + procedure.find_column(label: "Entreprise capital social"), + procedure.find_column(label: "Entreprise numero TVA intracommunautaire"), + procedure.find_column(label: "Entreprise forme juridique"), + procedure.find_column(label: "Entreprise forme juridique code"), + procedure.find_column(label: "Entreprise nom commercial"), + procedure.find_column(label: "Entreprise raison sociale"), + procedure.find_column(label: "Entreprise SIRET siège social"), + procedure.find_column(label: "Entreprise code effectif entreprise") + ] + actuals = procedure.all_usager_columns_for_export + expected.each do |expected_col| + expect(actuals.map(&:h_id)).to include(expected_col.h_id) + end + + expect(actuals.any? { _1.label == "Nom" }).to eq false + end + end + + context 'when procedure chorusable' do + let(:procedure) { create(:procedure_with_dossiers, :filled_chorus, types_de_champ_public:) } + it 'returns specific chorus columns' do + allow_any_instance_of(Procedure).to receive(:chorusable?).and_return(true) + expected = [ + procedure.find_column(label: "Domaine Fonctionnel"), + procedure.find_column(label: "Référentiel De Programmation"), + procedure.find_column(label: "Centre De Coût") + ] + actuals = procedure.all_usager_columns_for_export.map(&:h_id) + expected.each do |expected_col| + expect(actuals).to include(expected_col.h_id) + end + end + end + end + + describe '#all_dossier_columns_for_export' do + let(:procedure) { create(:procedure_with_dossiers, :routee, :published, types_de_champ_public:, for_individual:) } + + it "returns all dossier columns" do + expected = [ + procedure.find_column(label: "Archivé"), + procedure.find_column(label: "État du dossier"), + procedure.find_column(label: "Dernière mise à jour le"), + procedure.find_column(label: "Dernière mise à jour du dossier le"), + procedure.find_column(label: "Déposé le"), + procedure.find_column(label: "Passé en instruction le"), + procedure.find_column(label: "Traité le"), + procedure.find_column(label: "Motivation de la décision"), + procedure.find_column(label: "Instructeurs"), + procedure.find_column(label: "Groupe instructeur") + ] + actuals = procedure.all_dossier_columns_for_export.map(&:h_id) + expected.each do |expected_col| + expect(actuals).to include(expected_col.h_id) + end + end + end + end end diff --git a/spec/models/export_spec.rb b/spec/models/export_spec.rb index 3a796ce93..4d219553f 100644 --- a/spec/models/export_spec.rb +++ b/spec/models/export_spec.rb @@ -95,7 +95,7 @@ RSpec.describe Export, type: :model do expect { Export.find_or_create_fresh_export(:zip, [gi_1], instructeur, time_span_type: Export.time_span_types.fetch(:everything), statut: Export.statuts.fetch(:tous), procedure_presentation: pp) } .to change { Export.count }.by(1) - update_at_column = FilteredColumn.new(column: procedure.find_column(label: 'Mis à jour le'), filter: '10/12/2021') + update_at_column = FilteredColumn.new(column: procedure.find_column(label: 'Dernière mise à jour le'), filter: '10/12/2021') pp.update(tous_filters: [created_at_column, update_at_column]) expect { Export.find_or_create_fresh_export(:zip, [gi_1], instructeur, time_span_type: Export.time_span_types.fetch(:everything), statut: Export.statuts.fetch(:tous), procedure_presentation: pp) } @@ -181,7 +181,7 @@ RSpec.describe Export, type: :model do let(:statut) { 'tous' } let(:procedure_presentation) do - statut_column = procedure.find_column(label: 'Statut') + statut_column = procedure.find_column(label: 'État du dossier') en_construction_filter = FilteredColumn.new(column: statut_column, filter: 'en_construction') create(:procedure_presentation, procedure:, diff --git a/spec/models/procedure_presentation_spec.rb b/spec/models/procedure_presentation_spec.rb index ac30ea06e..0a74640ec 100644 --- a/spec/models/procedure_presentation_spec.rb +++ b/spec/models/procedure_presentation_spec.rb @@ -77,7 +77,7 @@ describe ProcedurePresentation do end context 'when filter is state' do - let(:filtered_column) { to_filter(['Statut', "en_construction"]) } + let(:filtered_column) { to_filter(['État du dossier', "en_construction"]) } it 'should get i18n value' do expect(subject).to eq("En construction") @@ -94,8 +94,8 @@ describe ProcedurePresentation do end describe '#update_displayed_fields' do - let(:en_construction_column) { procedure.find_column(label: 'En construction le') } - let(:mise_a_jour_column) { procedure.find_column(label: 'Mis à jour le') } + let(:en_construction_column) { procedure.find_column(label: 'Passé en construction le') } + let(:mise_a_jour_column) { procedure.find_column(label: 'Dernière mise à jour le') } let(:procedure_presentation) do create(:procedure_presentation, assign_to:).tap do |pp| diff --git a/spec/services/dossier_filter_service_spec.rb b/spec/services/dossier_filter_service_spec.rb index 5997d46b1..f883161cd 100644 --- a/spec/services/dossier_filter_service_spec.rb +++ b/spec/services/dossier_filter_service_spec.rb @@ -41,7 +41,7 @@ describe DossierFilterService do context 'when a filter is present' do let(:filtered_ids) { [dossier_1, dossier_2, dossier_3].map(&:id) } - let(:filters) { [to_filter(['Statut', 'en_construction'])] } + let(:filters) { [to_filter(['État du dossier', 'en_construction'])] } before do expect(described_class).to receive(:filtered_ids).and_return(filtered_ids) @@ -110,7 +110,7 @@ describe DossierFilterService do end context 'for en_construction_at column' do - let!(:column) { procedure.find_column(label: 'En construction le') } + let!(:column) { procedure.find_column(label: 'Passé en construction le') } let!(:recent_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 17)) } let!(:older_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2013, 1, 1)) } @@ -118,7 +118,7 @@ describe DossierFilterService do end context 'for updated_at column' do - let(:column) { procedure.find_column(label: 'Mis à jour le') } + let(:column) { procedure.find_column(label: 'Dernière mise à jour le') } let(:recent_dossier) { create(:dossier, procedure:) } let(:older_dossier) { create(:dossier, procedure:) } @@ -251,7 +251,7 @@ describe DossierFilterService do end context 'for email column' do - let(:column) { procedure.find_column(label: 'Email instructeur') } + let(:column) { procedure.find_column(label: 'Instructeurs') } it { is_expected.to eq([dossier_a, dossier_z, dossier_without_instructeur].map(&:id)) } end @@ -275,7 +275,7 @@ describe DossierFilterService do context 'for other tables' do # All other columns and tables work the same so it’s ok to test only one - let(:column) { procedure.find_column(label: 'Code postal') } + let(:column) { procedure.find_column(label: 'Établissement code postal') } let(:order) { 'asc' } # Desc works the same, no extra test required let!(:huitieme_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, code_postal: '75008')) } @@ -306,7 +306,7 @@ describe DossierFilterService do end context 'for en_construction_at column' do - let(:filter) { ['En construction le', '17/10/2018'] } + let(:filter) { ['Passé en construction le', '17/10/2018'] } let!(:kept_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 17)) } let!(:discarded_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2013, 1, 1)) } @@ -315,7 +315,7 @@ describe DossierFilterService do end context 'for updated_at column' do - let(:filter) { ['Mis à jour le', '18/9/2018'] } + let(:filter) { ['Dernière mise à jour le', '18/9/2018'] } let(:kept_dossier) { create(:dossier, procedure:) } let(:discarded_dossier) { create(:dossier, procedure:) } @@ -362,7 +362,7 @@ describe DossierFilterService do end context 'ignore time of day' do - let(:filter) { ['En construction le', '17/10/2018 19:30'] } + let(:filter) { ['Passé en construction le', '17/10/2018 19:30'] } let!(:kept_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 17, 15, 56)) } let!(:discarded_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 18, 5, 42)) } @@ -372,20 +372,20 @@ describe DossierFilterService do context 'for a malformed date' do context 'when its a string' do - let(:filter) { ['Mis à jour le', 'malformed date'] } + let(:filter) { ['Dernière mise à jour le', 'malformed date'] } it { is_expected.to match([]) } end context 'when its a number' do - let(:filter) { ['Mis à jour le', '177500'] } + let(:filter) { ['Dernière mise à jour le', '177500'] } it { is_expected.to match([]) } end end context 'with multiple search values' do - let(:filters) { [['En construction le', '17/10/2018'], ['En construction le', '19/10/2018']] } + let(:filters) { [['Passé en construction le', '17/10/2018'], ['Passé en construction le', '19/10/2018']] } let!(:kept_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 17)) } let!(:other_kept_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 19)) } @@ -397,7 +397,7 @@ describe DossierFilterService do end context 'with multiple state filters' do - let(:filters) { [['Statut', 'en_construction'], ['Statut', 'en_instruction']] } + let(:filters) { [['État du dossier', 'en_construction'], ['État du dossier', 'en_instruction']] } let!(:kept_dossier) { create(:dossier, :en_construction, procedure:) } let!(:other_kept_dossier) { create(:dossier, :en_instruction, procedure:) } @@ -409,7 +409,7 @@ describe DossierFilterService do end context 'with en_construction state filters' do - let(:filter) { ['Statut', 'en_construction'] } + let(:filter) { ['État du dossier', 'en_construction'] } let!(:en_construction) { create(:dossier, :en_construction, procedure:) } let!(:en_construction_with_correction) { create(:dossier, :en_construction, procedure:) } @@ -580,7 +580,7 @@ describe DossierFilterService do context 'for etablissement table' do context 'for entreprise_date_creation column' do - let(:filter) { ['Date de création', '21/6/2018'] } + let(:filter) { ['Entreprise date de création', '21/6/2018'] } let!(:kept_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, entreprise_date_creation: Time.zone.local(2018, 6, 21))) } let!(:discarded_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, entreprise_date_creation: Time.zone.local(2008, 6, 21))) } @@ -588,7 +588,7 @@ describe DossierFilterService do it { is_expected.to contain_exactly(kept_dossier.id) } context 'with multiple search values' do - let(:filters) { [['Date de création', '21/6/2016'], ['Date de création', '21/6/2018']] } + let(:filters) { [['Entreprise date de création', '21/6/2016'], ['Entreprise date de création', '21/6/2018']] } let!(:other_kept_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, entreprise_date_creation: Time.zone.local(2016, 6, 21))) } @@ -601,7 +601,7 @@ describe DossierFilterService do context 'for code_postal column' do # All columns except entreprise_date_creation work exacly the same, just testing one - let(:filter) { ['Code postal', '75017'] } + let(:filter) { ['Établissement code postal', '75017'] } let!(:kept_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, code_postal: '75017')) } let!(:discarded_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, code_postal: '25000')) } @@ -609,7 +609,7 @@ describe DossierFilterService do it { is_expected.to contain_exactly(kept_dossier.id) } context 'with multiple search values' do - let(:filters) { [['Code postal', '75017'], ['Code postal', '88100']] } + let(:filters) { [['Établissement code postal', '75017'], ['Établissement code postal', '88100']] } let!(:other_kept_dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, code_postal: '88100')) } @@ -674,7 +674,7 @@ describe DossierFilterService do end context 'for followers_instructeurs table' do - let(:filter) { ['Email instructeur', 'keepmail'] } + let(:filter) { ['Instructeurs', 'keepmail'] } let!(:kept_dossier) { create(:dossier, procedure:) } let!(:discarded_dossier) { create(:dossier, procedure:) } @@ -687,7 +687,7 @@ describe DossierFilterService do it { is_expected.to contain_exactly(kept_dossier.id) } context 'with multiple search values' do - let(:filters) { [['Email instructeur', 'keepmail'], ['Email instructeur', 'beta.gouv.fr']] } + let(:filters) { [['Instructeurs', 'keepmail'], ['Instructeurs', 'beta.gouv.fr']] } let(:other_kept_dossier) { create(:dossier, procedure:) } diff --git a/spec/services/dossier_projection_service_spec.rb b/spec/services/dossier_projection_service_spec.rb index 7671bdda5..9cdd52d16 100644 --- a/spec/services/dossier_projection_service_spec.rb +++ b/spec/services/dossier_projection_service_spec.rb @@ -87,7 +87,7 @@ describe DossierProjectionService do end context 'for en_construction_at column' do - let(:label) { 'En construction le' } + let(:label) { 'Passé en construction le' } let(:dossier) { create(:dossier, :en_construction, en_construction_at: Time.zone.local(2018, 10, 17), procedure:) } it { is_expected.to eq('17/10/2018') } @@ -101,7 +101,7 @@ describe DossierProjectionService do end context 'for updated_at column' do - let(:label) { 'Mis à jour le' } + let(:label) { 'Dernière mise à jour le' } let(:dossier) { create(:dossier, procedure:) } before { dossier.touch(time: Time.zone.local(2018, 9, 25)) } @@ -142,7 +142,7 @@ describe DossierProjectionService do end context 'for etablissement table' do - let(:label) { 'Code postal' } + let(:label) { 'Établissement code postal' } let!(:dossier) { create(:dossier, procedure:, etablissement: create(:etablissement, code_postal: '75008')) } @@ -158,7 +158,7 @@ describe DossierProjectionService do end context 'for followers_instructeurs table' do - let(:label) { 'Email instructeur' } + let(:label) { 'Instructeurs' } let(:dossier) { create(:dossier, procedure:) } let!(:follow1) { create(:follow, dossier: dossier, instructeur: create(:instructeur, email: 'b@host.fr')) } diff --git a/spec/system/instructeurs/procedure_filters_spec.rb b/spec/system/instructeurs/procedure_filters_spec.rb index 85555764f..5814335a8 100644 --- a/spec/system/instructeurs/procedure_filters_spec.rb +++ b/spec/system/instructeurs/procedure_filters_spec.rb @@ -99,10 +99,10 @@ describe "procedure filters" do scenario "should be able to user custom fiters", js: true do # use date filter - add_filter("En construction le", "10/10/2010", type: :date) + add_filter("Passé en construction le", "10/10/2010", type: :date) # use statut dropdown filter - add_filter('Statut', 'En construction', type: :enum) + add_filter('État du dossier', 'En construction', type: :enum) # use choice dropdown filter add_filter('Choix unique', 'val1', type: :enum) From 8afe4374c7d611d0052a8792b020bc61492e6bc1 Mon Sep 17 00:00:00 2001 From: mfo Date: Mon, 28 Oct 2024 17:01:27 +0100 Subject: [PATCH 02/15] review(pull/10591#discussion_r1818744664): extract some column builder --- app/models/concerns/columns_concern.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/models/concerns/columns_concern.rb b/app/models/concerns/columns_concern.rb index 78a533a7c..91acfcf80 100644 --- a/app/models/concerns/columns_concern.rb +++ b/app/models/concerns/columns_concern.rb @@ -42,8 +42,8 @@ module ColumnsConcern def all_usager_columns_for_export common = [ dossier_id_column, - Column.new(procedure_id: id, table: 'self', column: 'user_email_for_display', filterable: false, displayable: false), - Column.new(procedure_id: id, table: 'self', column: 'user_from_france_connect?', filterable: false, displayable: false) + email_for_display_column, + france_connected_column ] individual_or_moral_columns = for_individual? ? individual_columns : moral_columns @@ -78,6 +78,10 @@ module ColumnsConcern Column.new(procedure_id: id, table: 'self', column: 'state', label: I18n.t('activerecord.attributes.procedure_presentation.fields.self.state'), type: :enum, scope: 'instructeurs.dossiers.filterable_state', displayable: false) end + def email_for_display_column = Column.new(procedure_id: id, table: 'self', column: 'user_email_for_display', filterable: false, displayable: false) + + def france_connected_column = Column.new(procedure_id: id, table: 'self', column: 'user_from_france_connect?', filterable: false, displayable: false) + def notifications_column Column.new(procedure_id: id, table: 'notifications', column: 'notifications', label: "notifications", filterable: false) end @@ -134,12 +138,12 @@ module ColumnsConcern def standard_columns [ email_column, - Column.new(procedure_id: id, table: 'self', column: 'user_email_for_display', filterable: false, displayable: false), + email_for_display_column, Column.new(procedure_id: id, table: 'followers_instructeurs', column: 'email'), Column.new(procedure_id: id, table: 'groupe_instructeur', column: 'id', type: :enum), Column.new(procedure_id: id, table: 'avis', column: 'question_answer', filterable: false), Column.new(procedure_id: id, table: 'user', column: 'id', filterable: false, displayable: false), - Column.new(procedure_id: id, table: 'self', column: 'user_from_france_connect?', filterable: false, displayable: false) + france_connected_column ] end From d9fc48ad706248e514dffa9965c5b646b91cbf05 Mon Sep 17 00:00:00 2001 From: mfo Date: Mon, 28 Oct 2024 17:07:22 +0100 Subject: [PATCH 03/15] review(10591#discussion_r1818752344): homogenize interface for columns builders --- app/models/concerns/columns_concern.rb | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/app/models/concerns/columns_concern.rb b/app/models/concerns/columns_concern.rb index 91acfcf80..120b47698 100644 --- a/app/models/concerns/columns_concern.rb +++ b/app/models/concerns/columns_concern.rb @@ -31,24 +31,17 @@ module ColumnsConcern end def chorus_columns - if chorusable? && chorus_configuration.complete? - ['domaine_fonctionnel', 'referentiel_prog', 'centre_de_cout'] - .map { |column| Column.new(procedure_id: id, table: 'procedure', column:, displayable: false, filterable: false) } - else - [] - end + ['domaine_fonctionnel', 'referentiel_prog', 'centre_de_cout'] + .map { |column| Column.new(procedure_id: id, table: 'procedure', column:, displayable: false, filterable: false) } end def all_usager_columns_for_export - common = [ - dossier_id_column, - email_for_display_column, - france_connected_column - ] + columns = [dossier_id_column, email_for_display_column, france_connected_column] + columns.concat(individual_columns) if for_individual + columns.concat(moral_columns) if !for_individual + columns.concat(chorus_columns) if chorusable? && chorus_configuration.complete? - individual_or_moral_columns = for_individual? ? individual_columns : moral_columns - - [common, individual_or_moral_columns, chorus_columns].flatten.compact + columns.flatten.compact end def all_dossier_columns_for_export From fc45e537cfe2945d902c477e88f6a6ffd655481e Mon Sep 17 00:00:00 2001 From: mfo Date: Mon, 28 Oct 2024 17:14:07 +0100 Subject: [PATCH 04/15] review(pull/10591#discussion_r1818914395): extract and dry archived/motivation column --- app/models/concerns/columns_concern.rb | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/app/models/concerns/columns_concern.rb b/app/models/concerns/columns_concern.rb index 120b47698..acab0d098 100644 --- a/app/models/concerns/columns_concern.rb +++ b/app/models/concerns/columns_concern.rb @@ -47,10 +47,6 @@ module ColumnsConcern def all_dossier_columns_for_export states = [dossier_state_column] - for_export_before_date = ['archived'] - .map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :text, displayable: false, filterable: false) } - for_export_after_date = ['motivation'] - .map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :text, displayable: false, filterable: false) } routing = if self.routing_enabled? [Column.new(procedure_id: id, table: 'groupe_instructeur', column: 'id')] @@ -60,7 +56,7 @@ module ColumnsConcern instructeurs = [Column.new(procedure_id: id, table: 'followers_instructeurs', column: 'email')] - [states, for_export_before_date, dossier_dates_columns, for_export_after_date, sva_svr_columns(for_export: true), routing, instructeurs].flatten.compact + [states, dossier_archived_column, dossier_dates_columns, dossier_motivation_column, sva_svr_columns(for_export: true), routing, instructeurs].flatten.compact end def dossier_id_column @@ -87,12 +83,7 @@ module ColumnsConcern non_displayable_dates = ['updated_since', 'depose_since', 'en_construction_since', 'en_instruction_since', 'processed_since'] .map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :date, displayable: false) } - for_export_before_date = ['archived'] - .map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :text, displayable: false, filterable: false) } - for_export_after_date = ['motivation'] - .map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :text, displayable: false, filterable: false) } - - [common, states, for_export_before_date, dossier_dates_columns, for_export_after_date, sva_svr_columns(for_export: false), non_displayable_dates].flatten.compact + [common, states, dossier_archived_column, dossier_dates_columns, dossier_motivation_column, sva_svr_columns(for_export: false), non_displayable_dates].flatten.compact end def dossier_dates_columns @@ -122,6 +113,10 @@ module ColumnsConcern def default_displayed_columns = [email_column] + def dossier_archived_column = Column.new(procedure_id: id, table: 'self', column: 'archived', type: :text, displayable: false, filterable: false); + + def dossier_motivation_column = Column.new(procedure_id: id, table: 'self', column: 'motivation', type: :text, displayable: false, filterable: false); + private def email_column From 3bed049a292581fc245a3636234f1cca372c1401 Mon Sep 17 00:00:00 2001 From: mfo Date: Mon, 28 Oct 2024 17:16:48 +0100 Subject: [PATCH 05/15] tech(style): prefix columns builders by their table, easier to understand --- app/models/concerns/columns_concern.rb | 44 ++++++++++++-------------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/app/models/concerns/columns_concern.rb b/app/models/concerns/columns_concern.rb index acab0d098..b33e6b9e9 100644 --- a/app/models/concerns/columns_concern.rb +++ b/app/models/concerns/columns_concern.rb @@ -25,21 +25,16 @@ module ColumnsConcern columns.concat(standard_columns) columns.concat(individual_columns) if for_individual columns.concat(moral_columns) if !for_individual - columns.concat(chorus_columns) + columns.concat(procedure_chorus_columns) columns.concat(types_de_champ_columns) end end - def chorus_columns - ['domaine_fonctionnel', 'referentiel_prog', 'centre_de_cout'] - .map { |column| Column.new(procedure_id: id, table: 'procedure', column:, displayable: false, filterable: false) } - end - def all_usager_columns_for_export - columns = [dossier_id_column, email_for_display_column, france_connected_column] + columns = [dossier_id_column, user_email_for_display_column, user_france_connected_column] columns.concat(individual_columns) if for_individual columns.concat(moral_columns) if !for_individual - columns.concat(chorus_columns) if chorusable? && chorus_configuration.complete? + columns.concat(procedure_chorus_columns) if chorusable? && chorus_configuration.complete? columns.flatten.compact end @@ -59,20 +54,25 @@ module ColumnsConcern [states, dossier_archived_column, dossier_dates_columns, dossier_motivation_column, sva_svr_columns(for_export: true), routing, instructeurs].flatten.compact end - def dossier_id_column - Column.new(procedure_id: id, table: 'self', column: 'id', type: :number) - end + #### - def dossier_state_column - Column.new(procedure_id: id, table: 'self', column: 'state', label: I18n.t('activerecord.attributes.procedure_presentation.fields.self.state'), type: :enum, scope: 'instructeurs.dossiers.filterable_state', displayable: false) - end + def dossier_archived_column = Column.new(procedure_id: id, table: 'self', column: 'archived', type: :text, displayable: false, filterable: false); - def email_for_display_column = Column.new(procedure_id: id, table: 'self', column: 'user_email_for_display', filterable: false, displayable: false) + def dossier_motivation_column = Column.new(procedure_id: id, table: 'self', column: 'motivation', type: :text, displayable: false, filterable: false); - def france_connected_column = Column.new(procedure_id: id, table: 'self', column: 'user_from_france_connect?', filterable: false, displayable: false) + def dossier_id_column = Column.new(procedure_id: id, table: 'self', column: 'id', type: :number) - def notifications_column - Column.new(procedure_id: id, table: 'notifications', column: 'notifications', label: "notifications", filterable: false) + def dossier_state_column = Column.new(procedure_id: id, table: 'self', column: 'state', label: I18n.t('activerecord.attributes.procedure_presentation.fields.self.state'), type: :enum, scope: 'instructeurs.dossiers.filterable_state', displayable: false) + + def notifications_column = Column.new(procedure_id: id, table: 'notifications', column: 'notifications', label: "notifications", filterable: false) + + def user_email_for_display_column = Column.new(procedure_id: id, table: 'self', column: 'user_email_for_display', filterable: false, displayable: false) + + def user_france_connected_column = Column.new(procedure_id: id, table: 'self', column: 'user_from_france_connect?', filterable: false, displayable: false) + + def procedure_chorus_columns + ['domaine_fonctionnel', 'referentiel_prog', 'centre_de_cout'] + .map { |column| Column.new(procedure_id: id, table: 'procedure', column:, displayable: false, filterable: false) } end def dossier_columns @@ -113,10 +113,6 @@ module ColumnsConcern def default_displayed_columns = [email_column] - def dossier_archived_column = Column.new(procedure_id: id, table: 'self', column: 'archived', type: :text, displayable: false, filterable: false); - - def dossier_motivation_column = Column.new(procedure_id: id, table: 'self', column: 'motivation', type: :text, displayable: false, filterable: false); - private def email_column @@ -126,12 +122,12 @@ module ColumnsConcern def standard_columns [ email_column, - email_for_display_column, + user_email_for_display_column, Column.new(procedure_id: id, table: 'followers_instructeurs', column: 'email'), Column.new(procedure_id: id, table: 'groupe_instructeur', column: 'id', type: :enum), Column.new(procedure_id: id, table: 'avis', column: 'question_answer', filterable: false), Column.new(procedure_id: id, table: 'user', column: 'id', filterable: false, displayable: false), - france_connected_column + user_france_connected_column ] end From cbb9854f4ce862685947b9f7fefaee82df28b8b2 Mon Sep 17 00:00:00 2001 From: mfo Date: Mon, 28 Oct 2024 17:38:48 +0100 Subject: [PATCH 06/15] review(pull/10591#discussion_r1818916426): extract groupe_instructeurs_column and followers_instructeurs_email_column --- app/models/concerns/columns_concern.rb | 51 +++++++++++++------------- app/models/procedure_presentation.rb | 7 ++-- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/app/models/concerns/columns_concern.rb b/app/models/concerns/columns_concern.rb index b33e6b9e9..3a473ba58 100644 --- a/app/models/concerns/columns_concern.rb +++ b/app/models/concerns/columns_concern.rb @@ -40,21 +40,30 @@ module ColumnsConcern end def all_dossier_columns_for_export - states = [dossier_state_column] - - routing = - if self.routing_enabled? - [Column.new(procedure_id: id, table: 'groupe_instructeur', column: 'id')] - else - [] - end - - instructeurs = [Column.new(procedure_id: id, table: 'followers_instructeurs', column: 'email')] - - [states, dossier_archived_column, dossier_dates_columns, dossier_motivation_column, sva_svr_columns(for_export: true), routing, instructeurs].flatten.compact + columns = [dossier_state_column] + columns.concat([dossier_archived_column]) + columns.concat(dossier_dates_columns) + columns.concat([dossier_motivation_column]) + columns.concat(sva_svr_columns(for_export: true)) if sva_svr_enabled? + columns.concat([groupe_instructeurs_id_column]) + columns.concat([followers_instructeurs_email_column]) + columns.flatten.compact end - #### + def dossier_columns + dossier_columns = [dossier_id_column, notifications_column] + dossier_columns.concat([dossier_state_column]) + dossier_columns.concat([dossier_archived_column]) + dossier_columns.concat(dossier_dates_columns) + dossier_columns.concat([dossier_motivation_column]) + dossier_columns.concat(sva_svr_columns(for_export: false)) if sva_svr_enabled? + dossier_columns.concat(dossier_non_displayable_dates_columns) + dossier_columns.flatten.compact + end + + def groupe_instructeurs_id_column = Column.new(procedure_id: id, table: 'groupe_instructeur', column: 'id', type: :enum) + + def followers_instructeurs_email_column = Column.new(procedure_id: id, table: 'followers_instructeurs', column: 'email') def dossier_archived_column = Column.new(procedure_id: id, table: 'self', column: 'archived', type: :text, displayable: false, filterable: false); @@ -75,15 +84,9 @@ module ColumnsConcern .map { |column| Column.new(procedure_id: id, table: 'procedure', column:, displayable: false, filterable: false) } end - def dossier_columns - common = [dossier_id_column, notifications_column] - - states = [dossier_state_column] - - non_displayable_dates = ['updated_since', 'depose_since', 'en_construction_since', 'en_instruction_since', 'processed_since'] + def dossier_non_displayable_dates_columns + ['updated_since', 'depose_since', 'en_construction_since', 'en_instruction_since', 'processed_since'] .map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :date, displayable: false) } - - [common, states, dossier_archived_column, dossier_dates_columns, dossier_motivation_column, sva_svr_columns(for_export: false), non_displayable_dates].flatten.compact end def dossier_dates_columns @@ -92,8 +95,6 @@ module ColumnsConcern end def sva_svr_columns(for_export: false) - return if !sva_svr_enabled? - scope = [:activerecord, :attributes, :procedure_presentation, :fields, :self] columns = [ @@ -123,8 +124,8 @@ module ColumnsConcern [ email_column, user_email_for_display_column, - Column.new(procedure_id: id, table: 'followers_instructeurs', column: 'email'), - Column.new(procedure_id: id, table: 'groupe_instructeur', column: 'id', type: :enum), + followers_instructeurs_email_column, + groupe_instructeurs_id_column, Column.new(procedure_id: id, table: 'avis', column: 'question_answer', filterable: false), Column.new(procedure_id: id, table: 'user', column: 'id', filterable: false, displayable: false), user_france_connected_column diff --git a/app/models/procedure_presentation.rb b/app/models/procedure_presentation.rb index 07365e9b7..c45e6ac20 100644 --- a/app/models/procedure_presentation.rb +++ b/app/models/procedure_presentation.rb @@ -34,12 +34,13 @@ class ProcedurePresentation < ApplicationRecord def filters_name_for(statut) = statut.tr('-', '_').then { "#{_1}_filters" } def displayed_fields_for_headers - [ + columns = [ procedure.dossier_id_column, *displayed_columns, - procedure.dossier_state_column, - *procedure.sva_svr_columns + procedure.dossier_state_column ] + columns.concat(procedure.sva_svr_columns) if procedure.sva_svr_enabled? + columns end def human_value_for_filter(filtered_column) From fa50e21101c4f79faa6c85d37758d61adeb9850c Mon Sep 17 00:00:00 2001 From: mfo Date: Mon, 28 Oct 2024 17:40:14 +0100 Subject: [PATCH 07/15] review(pull/10591#discussion_r1818919818): export without user id --- app/models/concerns/columns_concern.rb | 1 - spec/models/concerns/columns_concern_spec.rb | 1 - 2 files changed, 2 deletions(-) diff --git a/app/models/concerns/columns_concern.rb b/app/models/concerns/columns_concern.rb index 3a473ba58..bc963da8d 100644 --- a/app/models/concerns/columns_concern.rb +++ b/app/models/concerns/columns_concern.rb @@ -127,7 +127,6 @@ module ColumnsConcern followers_instructeurs_email_column, groupe_instructeurs_id_column, Column.new(procedure_id: id, table: 'avis', column: 'question_answer', filterable: false), - Column.new(procedure_id: id, table: 'user', column: 'id', filterable: false, displayable: false), user_france_connected_column ] end diff --git a/spec/models/concerns/columns_concern_spec.rb b/spec/models/concerns/columns_concern_spec.rb index 7a518f0fa..8262588c4 100644 --- a/spec/models/concerns/columns_concern_spec.rb +++ b/spec/models/concerns/columns_concern_spec.rb @@ -50,7 +50,6 @@ describe ColumnsConcern do { label: 'Email instructeur', table: 'followers_instructeurs', column: 'email', displayable: true, type: :text, scope: '', value_column: :value, filterable: true }, { label: 'Groupe instructeur', table: 'groupe_instructeur', column: 'id', displayable: true, type: :enum, scope: '', value_column: :value, filterable: true }, { label: 'Avis oui/non', table: 'avis', column: 'question_answer', displayable: true, type: :text, scope: '', value_column: :value, filterable: false }, - { label: 'Identifiant du demandeur', table: 'user', column: 'id', displayable: false, type: :text, scope: '', value_column: :value, filterable: false }, { label: 'FranceConnect ?', table: 'self', column: 'user_from_france_connect?', displayable: false, type: :text, scope: '', value_column: :value, filterable: false }, { label: 'SIREN', table: 'etablissement', column: 'entreprise_siren', displayable: true, type: :text, scope: '', value_column: :value, filterable: true }, { label: 'Forme juridique', table: 'etablissement', column: 'entreprise_forme_juridique', displayable: true, type: :text, scope: '', value_column: :value, filterable: true }, From 26a078bc451120d10714bc88984db7481378005d Mon Sep 17 00:00:00 2001 From: mfo Date: Mon, 28 Oct 2024 17:48:14 +0100 Subject: [PATCH 08/15] feat(naming): enhance naming of dates columns. --- .../models/procedure_presentation/en.yml | 2 +- .../models/procedure_presentation/fr.yml | 20 +++++++------- spec/models/concerns/columns_concern_spec.rb | 26 +++++++++---------- spec/models/export_spec.rb | 6 ++--- spec/models/procedure_presentation_spec.rb | 6 ++--- spec/services/dossier_filter_service_spec.rb | 22 ++++++++-------- .../dossier_projection_service_spec.rb | 8 +++--- .../instructeurs/procedure_filters_spec.rb | 6 ++--- 8 files changed, 48 insertions(+), 48 deletions(-) diff --git a/config/locales/models/procedure_presentation/en.yml b/config/locales/models/procedure_presentation/en.yml index fc12fb311..78957508d 100644 --- a/config/locales/models/procedure_presentation/en.yml +++ b/config/locales/models/procedure_presentation/en.yml @@ -22,7 +22,7 @@ en: sva_decision_before: SVA decision date before svr_decision_on: Date décision %{type} svr_decision_before: SVR decision date before - user_from_france_connect?: "FranceConnect ?" + user_from_france_connect?: "France connecté ?" for_tiers: "For tiers" mandataire_last_name: "Tier last name" mandataire_first_name: "Tier first name" diff --git a/config/locales/models/procedure_presentation/fr.yml b/config/locales/models/procedure_presentation/fr.yml index c6fba136f..b46c82a37 100644 --- a/config/locales/models/procedure_presentation/fr.yml +++ b/config/locales/models/procedure_presentation/fr.yml @@ -7,28 +7,28 @@ fr: id: Nº dossier user_email_for_display: Email state: État du dossier - created_at: Créé le - updated_at: Dernière mise à jour le - depose_at: Déposé le - en_construction_at: Passé en construction le - en_instruction_at: Passé en instruction le - processed_at: Traité le - updated_since: Mis à jour depuis + created_at: Date de création + updated_at: Date du dernier évènement + depose_at: Date de dépot + en_construction_at: Date de passage en construction + en_instruction_at: Date de passage en instruction + processed_at: Date de traitement + updated_since: Dernier évènement depuis depose_since: Déposé depuis en_construction_since: En construction depuis en_instruction_since: En instruction depuis - processed_since: Terminé depuis + processed_since: Traité depuis sva_decision_on: Date décision %{type} sva_decision_before: Date décision SVA avant svr_decision_on: Date décision %{type} svr_decision_before: Date décision SVR avant - user_from_france_connect?: "FranceConnect ?" + user_from_france_connect?: "France connecté ?" for_tiers: "Dépôt pour un tiers" mandataire_last_name: "Nom du mandataire" mandataire_first_name: "Prénom du mandataire" archived: 'Archivé' dossier_state: 'État du dossier' - last_champ_updated_at: 'Dernière mise à jour du dossier le' + last_champ_updated_at: Date de dernière modification (usager) motivation: 'Motivation de la décision' user: id: Identifiant du demandeur diff --git a/spec/models/concerns/columns_concern_spec.rb b/spec/models/concerns/columns_concern_spec.rb index 8262588c4..d1386be36 100644 --- a/spec/models/concerns/columns_concern_spec.rb +++ b/spec/models/concerns/columns_concern_spec.rb @@ -31,26 +31,26 @@ describe ColumnsConcern do [ { label: 'Dossier ID', table: 'self', column: 'id', displayable: true, type: :number, scope: '', value_column: :value, filterable: true }, { label: 'notifications', table: 'notifications', column: 'notifications', displayable: true, type: :text, scope: '', value_column: :value, filterable: false }, - { label: 'Créé le', table: 'self', column: 'created_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true }, + { label: 'Date de création', table: 'self', column: 'created_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true }, { label: 'Mis à jour le', table: 'self', column: 'updated_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true }, - { label: 'Déposé le', table: 'self', column: 'depose_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true }, + { label: 'Date de dépot', table: 'self', column: 'depose_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true }, { label: 'En construction le', table: 'self', column: 'en_construction_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true }, { label: 'En instruction le', table: 'self', column: 'en_instruction_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true }, { label: 'Terminé le', table: 'self', column: 'processed_at', displayable: true, type: :date, scope: '', value_column: :value, filterable: true }, - { label: "Mis à jour depuis", table: "self", column: "updated_since", displayable: false, type: :date, scope: '', value_column: :value, filterable: true }, + { label: "Dernier évènement depuis", table: "self", column: "updated_since", displayable: false, type: :date, scope: '', value_column: :value, filterable: true }, { label: "Déposé depuis", table: "self", column: "depose_since", displayable: false, type: :date, scope: '', value_column: :value, filterable: true }, { label: "En construction depuis", table: "self", column: "en_construction_since", displayable: false, type: :date, scope: '', value_column: :value, filterable: true }, { label: "En instruction depuis", table: "self", column: "en_instruction_since", displayable: false, type: :date, scope: '', value_column: :value, filterable: true }, - { label: "Terminé depuis", table: "self", column: "processed_since", displayable: false, type: :date, scope: '', value_column: :value, filterable: true }, + { label: "Traité depuis", table: "self", column: "processed_since", displayable: false, type: :date, scope: '', value_column: :value, filterable: true }, { label: "Statut", table: "self", column: "state", displayable: false, scope: 'instructeurs.dossiers.filterable_state', type: :enum, value_column: :value, filterable: true }, { label: "Archivé", table: "self", column: "archived", displayable: false, scope: '', type: :text, value_column: :value, filterable: false }, { label: "Motivation de la décision", table: "self", column: "motivation", displayable: false, scope: '', type: :text, value_column: :value, filterable: false }, - { label: "Dernière mise à jour du dossier le", table: "self", column: "last_champ_updated_at", displayable: false, scope: '', type: :text, value_column: :value, filterable: false }, + { label: "Date de dernière modification (usager)", table: "self", column: "last_champ_updated_at", displayable: false, scope: '', type: :text, value_column: :value, filterable: false }, { label: 'Demandeur', table: 'user', column: 'email', displayable: true, type: :text, scope: '', value_column: :value, filterable: true }, { label: 'Email instructeur', table: 'followers_instructeurs', column: 'email', displayable: true, type: :text, scope: '', value_column: :value, filterable: true }, { label: 'Groupe instructeur', table: 'groupe_instructeur', column: 'id', displayable: true, type: :enum, scope: '', value_column: :value, filterable: true }, { label: 'Avis oui/non', table: 'avis', column: 'question_answer', displayable: true, type: :text, scope: '', value_column: :value, filterable: false }, - { label: 'FranceConnect ?', table: 'self', column: 'user_from_france_connect?', displayable: false, type: :text, scope: '', value_column: :value, filterable: false }, + { label: 'France connecté ?', table: 'self', column: 'user_from_france_connect?', displayable: false, type: :text, scope: '', value_column: :value, filterable: false }, { label: 'SIREN', table: 'etablissement', column: 'entreprise_siren', displayable: true, type: :text, scope: '', value_column: :value, filterable: true }, { label: 'Forme juridique', table: 'etablissement', column: 'entreprise_forme_juridique', displayable: true, type: :text, scope: '', value_column: :value, filterable: true }, { label: 'Nom commercial', table: 'etablissement', column: 'entreprise_nom_commercial', displayable: true, type: :text, scope: '', value_column: :value, filterable: true }, @@ -154,7 +154,7 @@ describe ColumnsConcern do expected = [ procedure.find_column(label: "Nº dossier"), procedure.find_column(label: "Email"), - procedure.find_column(label: "FranceConnect ?"), + procedure.find_column(label: "France connecté ?"), procedure.find_column(label: "Civilité"), procedure.find_column(label: "Nom"), procedure.find_column(label: "Prénom"), @@ -176,7 +176,7 @@ describe ColumnsConcern do expected = [ procedure.find_column(label: "Nº dossier"), procedure.find_column(label: "Email"), - procedure.find_column(label: "FranceConnect ?"), + procedure.find_column(label: "France connecté ?"), procedure.find_column(label: "Établissement SIRET"), procedure.find_column(label: "Établissement siège social"), procedure.find_column(label: "Établissement NAF"), @@ -232,11 +232,11 @@ describe ColumnsConcern do expected = [ procedure.find_column(label: "Archivé"), procedure.find_column(label: "État du dossier"), - procedure.find_column(label: "Dernière mise à jour le"), - procedure.find_column(label: "Dernière mise à jour du dossier le"), - procedure.find_column(label: "Déposé le"), - procedure.find_column(label: "Passé en instruction le"), - procedure.find_column(label: "Traité le"), + procedure.find_column(label: "Date du dernier évènement"), + procedure.find_column(label: "Date de dernière modification (usager)"), + procedure.find_column(label: "Date de dépot"), + procedure.find_column(label: "Date de passage en instruction"), + procedure.find_column(label: "Date de traitement"), procedure.find_column(label: "Motivation de la décision"), procedure.find_column(label: "Instructeurs"), procedure.find_column(label: "Groupe instructeur") diff --git a/spec/models/export_spec.rb b/spec/models/export_spec.rb index 4d219553f..db075a1c4 100644 --- a/spec/models/export_spec.rb +++ b/spec/models/export_spec.rb @@ -81,7 +81,7 @@ RSpec.describe Export, type: :model do let(:instructeur) { create(:instructeur) } let!(:gi_1) { create(:groupe_instructeur, procedure: procedure, instructeurs: [instructeur]) } let!(:pp) { gi_1.instructeurs.first.procedure_presentation_and_errors_for_procedure_id(procedure.id).first } - let(:created_at_column) { FilteredColumn.new(column: procedure.find_column(label: 'Créé le'), filter: '10/12/2021') } + let(:created_at_column) { FilteredColumn.new(column: procedure.find_column(label: 'Date de création'), filter: '10/12/2021') } before { pp.update(tous_filters: [created_at_column]) } @@ -95,7 +95,7 @@ RSpec.describe Export, type: :model do expect { Export.find_or_create_fresh_export(:zip, [gi_1], instructeur, time_span_type: Export.time_span_types.fetch(:everything), statut: Export.statuts.fetch(:tous), procedure_presentation: pp) } .to change { Export.count }.by(1) - update_at_column = FilteredColumn.new(column: procedure.find_column(label: 'Dernière mise à jour le'), filter: '10/12/2021') + update_at_column = FilteredColumn.new(column: procedure.find_column(label: 'Date du dernier évènement'), filter: '10/12/2021') pp.update(tous_filters: [created_at_column, update_at_column]) expect { Export.find_or_create_fresh_export(:zip, [gi_1], instructeur, time_span_type: Export.time_span_types.fetch(:everything), statut: Export.statuts.fetch(:tous), procedure_presentation: pp) } @@ -181,7 +181,7 @@ RSpec.describe Export, type: :model do let(:statut) { 'tous' } let(:procedure_presentation) do - statut_column = procedure.find_column(label: 'État du dossier') + statut_column = procedure.dossier_state_column en_construction_filter = FilteredColumn.new(column: statut_column, filter: 'en_construction') create(:procedure_presentation, procedure:, diff --git a/spec/models/procedure_presentation_spec.rb b/spec/models/procedure_presentation_spec.rb index 0a74640ec..821204a3c 100644 --- a/spec/models/procedure_presentation_spec.rb +++ b/spec/models/procedure_presentation_spec.rb @@ -85,7 +85,7 @@ describe ProcedurePresentation do end context 'when filter is a date' do - let(:filtered_column) { to_filter(['Créé le', "15/06/2023"]) } + let(:filtered_column) { to_filter(['Date de création', "15/06/2023"]) } it 'should get formatted value' do expect(subject).to eq("15/06/2023") @@ -94,8 +94,8 @@ describe ProcedurePresentation do end describe '#update_displayed_fields' do - let(:en_construction_column) { procedure.find_column(label: 'Passé en construction le') } - let(:mise_a_jour_column) { procedure.find_column(label: 'Dernière mise à jour le') } + let(:en_construction_column) { procedure.find_column(label: 'Date de passage en construction') } + let(:mise_a_jour_column) { procedure.find_column(label: 'Date du dernier évènement') } let(:procedure_presentation) do create(:procedure_presentation, assign_to:).tap do |pp| diff --git a/spec/services/dossier_filter_service_spec.rb b/spec/services/dossier_filter_service_spec.rb index f883161cd..cb8e395bd 100644 --- a/spec/services/dossier_filter_service_spec.rb +++ b/spec/services/dossier_filter_service_spec.rb @@ -102,7 +102,7 @@ describe DossierFilterService do let(:order) { 'asc' } # Desc works the same, no extra test required context 'for created_at column' do - let!(:column) { procedure.find_column(label: 'Créé le') } + let!(:column) { procedure.find_column(label: 'Date de création') } let!(:recent_dossier) { Timecop.freeze(Time.zone.local(2018, 10, 17)) { create(:dossier, procedure:) } } let!(:older_dossier) { Timecop.freeze(Time.zone.local(2003, 11, 11)) { create(:dossier, procedure:) } } @@ -110,7 +110,7 @@ describe DossierFilterService do end context 'for en_construction_at column' do - let!(:column) { procedure.find_column(label: 'Passé en construction le') } + let!(:column) { procedure.find_column(label: 'Date de passage en construction') } let!(:recent_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 17)) } let!(:older_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2013, 1, 1)) } @@ -118,7 +118,7 @@ describe DossierFilterService do end context 'for updated_at column' do - let(:column) { procedure.find_column(label: 'Dernière mise à jour le') } + let(:column) { procedure.find_column(label: 'Date du dernier évènement') } let(:recent_dossier) { create(:dossier, procedure:) } let(:older_dossier) { create(:dossier, procedure:) } @@ -297,7 +297,7 @@ describe DossierFilterService do context 'for self table' do context 'for created_at column' do - let(:filter) { ['Créé le', '18/9/2018'] } + let(:filter) { ['Date de création', '18/9/2018'] } let!(:kept_dossier) { create(:dossier, procedure:, created_at: Time.zone.local(2018, 9, 18, 14, 28)) } let!(:discarded_dossier) { create(:dossier, procedure:, created_at: Time.zone.local(2018, 9, 17, 23, 59)) } @@ -306,7 +306,7 @@ describe DossierFilterService do end context 'for en_construction_at column' do - let(:filter) { ['Passé en construction le', '17/10/2018'] } + let(:filter) { ['Date de passage en construction', '17/10/2018'] } let!(:kept_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 17)) } let!(:discarded_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2013, 1, 1)) } @@ -315,7 +315,7 @@ describe DossierFilterService do end context 'for updated_at column' do - let(:filter) { ['Dernière mise à jour le', '18/9/2018'] } + let(:filter) { ['Date du dernier évènement', '18/9/2018'] } let(:kept_dossier) { create(:dossier, procedure:) } let(:discarded_dossier) { create(:dossier, procedure:) } @@ -329,7 +329,7 @@ describe DossierFilterService do end context 'for updated_since column' do - let(:filter) { ['Mis à jour depuis', '18/9/2018'] } + let(:filter) { ['Dernier évènement depuis', '18/9/2018'] } let(:kept_dossier) { create(:dossier, procedure:) } let(:later_dossier) { create(:dossier, procedure:) } @@ -362,7 +362,7 @@ describe DossierFilterService do end context 'ignore time of day' do - let(:filter) { ['Passé en construction le', '17/10/2018 19:30'] } + let(:filter) { ['Date de passage en construction', '17/10/2018 19:30'] } let!(:kept_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 17, 15, 56)) } let!(:discarded_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 18, 5, 42)) } @@ -372,20 +372,20 @@ describe DossierFilterService do context 'for a malformed date' do context 'when its a string' do - let(:filter) { ['Dernière mise à jour le', 'malformed date'] } + let(:filter) { ['Date du dernier évènement', 'malformed date'] } it { is_expected.to match([]) } end context 'when its a number' do - let(:filter) { ['Dernière mise à jour le', '177500'] } + let(:filter) { ['Date du dernier évènement', '177500'] } it { is_expected.to match([]) } end end context 'with multiple search values' do - let(:filters) { [['Passé en construction le', '17/10/2018'], ['Passé en construction le', '19/10/2018']] } + let(:filters) { [['Date de passage en construction', '17/10/2018'], ['Date de passage en construction', '19/10/2018']] } let!(:kept_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 17)) } let!(:other_kept_dossier) { create(:dossier, :en_construction, procedure:, en_construction_at: Time.zone.local(2018, 10, 19)) } diff --git a/spec/services/dossier_projection_service_spec.rb b/spec/services/dossier_projection_service_spec.rb index 9cdd52d16..af4969f8f 100644 --- a/spec/services/dossier_projection_service_spec.rb +++ b/spec/services/dossier_projection_service_spec.rb @@ -80,28 +80,28 @@ describe DossierProjectionService do context 'for self table' do context 'for created_at column' do - let(:label) { 'Créé le' } + let(:label) { 'Date de création' } let(:dossier) { Timecop.freeze(Time.zone.local(1992, 3, 22)) { create(:dossier, procedure:) } } it { is_expected.to eq('22/03/1992') } end context 'for en_construction_at column' do - let(:label) { 'Passé en construction le' } + let(:label) { 'Date de passage en construction' } let(:dossier) { create(:dossier, :en_construction, en_construction_at: Time.zone.local(2018, 10, 17), procedure:) } it { is_expected.to eq('17/10/2018') } end context 'for depose_at column' do - let(:label) { 'Déposé le' } + let(:label) { 'Date de dépot' } let(:dossier) { create(:dossier, :en_construction, depose_at: Time.zone.local(2018, 10, 17), procedure:) } it { is_expected.to eq('17/10/2018') } end context 'for updated_at column' do - let(:label) { 'Dernière mise à jour le' } + let(:label) { 'Date du dernier évènement' } let(:dossier) { create(:dossier, procedure:) } before { dossier.touch(time: Time.zone.local(2018, 9, 25)) } diff --git a/spec/system/instructeurs/procedure_filters_spec.rb b/spec/system/instructeurs/procedure_filters_spec.rb index 5814335a8..65440b22d 100644 --- a/spec/system/instructeurs/procedure_filters_spec.rb +++ b/spec/system/instructeurs/procedure_filters_spec.rb @@ -44,9 +44,9 @@ describe "procedure filters" do end scenario "should add be able to add created_at column", js: true do - add_column("Créé le") + add_column("Date de création") within ".dossiers-table" do - expect(page).to have_link("Créé le") + expect(page).to have_link("Date de création") expect(page).to have_link(new_unfollow_dossier.created_at.strftime('%d/%m/%Y')) end end @@ -99,7 +99,7 @@ describe "procedure filters" do scenario "should be able to user custom fiters", js: true do # use date filter - add_filter("Passé en construction le", "10/10/2010", type: :date) + add_filter("Date de passage en construction", "10/10/2010", type: :date) # use statut dropdown filter add_filter('État du dossier', 'En construction', type: :enum) From 656080538bee88b1a6746e989edcf5f88150b6e2 Mon Sep 17 00:00:00 2001 From: mfo Date: Tue, 29 Oct 2024 09:17:45 +0100 Subject: [PATCH 09/15] review(pull/10591#discussion_r1818942794): remove tested enum labels --- app/models/concerns/columns_concern.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/concerns/columns_concern.rb b/app/models/concerns/columns_concern.rb index bc963da8d..0b4fc61d4 100644 --- a/app/models/concerns/columns_concern.rb +++ b/app/models/concerns/columns_concern.rb @@ -71,7 +71,7 @@ module ColumnsConcern def dossier_id_column = Column.new(procedure_id: id, table: 'self', column: 'id', type: :number) - def dossier_state_column = Column.new(procedure_id: id, table: 'self', column: 'state', label: I18n.t('activerecord.attributes.procedure_presentation.fields.self.state'), type: :enum, scope: 'instructeurs.dossiers.filterable_state', displayable: false) + def dossier_state_column = Column.new(procedure_id: id, table: 'self', column: 'state', type: :enum, scope: 'instructeurs.dossiers.filterable_state', displayable: false) def notifications_column = Column.new(procedure_id: id, table: 'notifications', column: 'notifications', label: "notifications", filterable: false) From 2181a917a2ff922c223a0125f9fa2700e80bc19b Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 30 Oct 2024 15:58:08 +0100 Subject: [PATCH 10/15] move col def to private when possible --- app/models/concerns/columns_concern.rb | 76 +++++++++++++------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/app/models/concerns/columns_concern.rb b/app/models/concerns/columns_concern.rb index 0b4fc61d4..37c27a2ea 100644 --- a/app/models/concerns/columns_concern.rb +++ b/app/models/concerns/columns_concern.rb @@ -50,50 +50,12 @@ module ColumnsConcern columns.flatten.compact end - def dossier_columns - dossier_columns = [dossier_id_column, notifications_column] - dossier_columns.concat([dossier_state_column]) - dossier_columns.concat([dossier_archived_column]) - dossier_columns.concat(dossier_dates_columns) - dossier_columns.concat([dossier_motivation_column]) - dossier_columns.concat(sva_svr_columns(for_export: false)) if sva_svr_enabled? - dossier_columns.concat(dossier_non_displayable_dates_columns) - dossier_columns.flatten.compact - end - - def groupe_instructeurs_id_column = Column.new(procedure_id: id, table: 'groupe_instructeur', column: 'id', type: :enum) - - def followers_instructeurs_email_column = Column.new(procedure_id: id, table: 'followers_instructeurs', column: 'email') - - def dossier_archived_column = Column.new(procedure_id: id, table: 'self', column: 'archived', type: :text, displayable: false, filterable: false); - - def dossier_motivation_column = Column.new(procedure_id: id, table: 'self', column: 'motivation', type: :text, displayable: false, filterable: false); - def dossier_id_column = Column.new(procedure_id: id, table: 'self', column: 'id', type: :number) def dossier_state_column = Column.new(procedure_id: id, table: 'self', column: 'state', type: :enum, scope: 'instructeurs.dossiers.filterable_state', displayable: false) def notifications_column = Column.new(procedure_id: id, table: 'notifications', column: 'notifications', label: "notifications", filterable: false) - def user_email_for_display_column = Column.new(procedure_id: id, table: 'self', column: 'user_email_for_display', filterable: false, displayable: false) - - def user_france_connected_column = Column.new(procedure_id: id, table: 'self', column: 'user_from_france_connect?', filterable: false, displayable: false) - - def procedure_chorus_columns - ['domaine_fonctionnel', 'referentiel_prog', 'centre_de_cout'] - .map { |column| Column.new(procedure_id: id, table: 'procedure', column:, displayable: false, filterable: false) } - end - - def dossier_non_displayable_dates_columns - ['updated_since', 'depose_since', 'en_construction_since', 'en_instruction_since', 'processed_since'] - .map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :date, displayable: false) } - end - - def dossier_dates_columns - ['created_at', 'updated_at', 'last_champ_updated_at', 'depose_at', 'en_construction_at', 'en_instruction_at', 'processed_at'] - .map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :date) } - end - def sva_svr_columns(for_export: false) scope = [:activerecord, :attributes, :procedure_presentation, :fields, :self] @@ -116,10 +78,48 @@ module ColumnsConcern private + def groupe_instructeurs_id_column = Column.new(procedure_id: id, table: 'groupe_instructeur', column: 'id', type: :enum) + + def followers_instructeurs_email_column = Column.new(procedure_id: id, table: 'followers_instructeurs', column: 'email') + + def dossier_archived_column = Column.new(procedure_id: id, table: 'self', column: 'archived', type: :text, displayable: false, filterable: false); + + def dossier_motivation_column = Column.new(procedure_id: id, table: 'self', column: 'motivation', type: :text, displayable: false, filterable: false); + + def user_email_for_display_column = Column.new(procedure_id: id, table: 'self', column: 'user_email_for_display', filterable: false, displayable: false) + + def user_france_connected_column = Column.new(procedure_id: id, table: 'self', column: 'user_from_france_connect?', filterable: false, displayable: false) + + def procedure_chorus_columns + ['domaine_fonctionnel', 'referentiel_prog', 'centre_de_cout'] + .map { |column| Column.new(procedure_id: id, table: 'procedure', column:, displayable: false, filterable: false) } + end + + def dossier_non_displayable_dates_columns + ['updated_since', 'depose_since', 'en_construction_since', 'en_instruction_since', 'processed_since'] + .map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :date, displayable: false) } + end + + def dossier_dates_columns + ['created_at', 'updated_at', 'last_champ_updated_at', 'depose_at', 'en_construction_at', 'en_instruction_at', 'processed_at'] + .map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :date) } + end + def email_column Column.new(procedure_id: id, table: 'user', column: 'email') end + def dossier_columns + columns = [dossier_id_column, notifications_column] + columns.concat([dossier_state_column]) + columns.concat([dossier_archived_column]) + columns.concat(dossier_dates_columns) + columns.concat([dossier_motivation_column]) + columns.concat(sva_svr_columns(for_export: false)) if sva_svr_enabled? + columns.concat(dossier_non_displayable_dates_columns) + columns.flatten.compact + end + def standard_columns [ email_column, From 92a863d48c0c8139b22a6a681c9887cbd57683ee Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 30 Oct 2024 16:07:16 +0100 Subject: [PATCH 11/15] remove_all as there is no `some_usager_columns` --- app/models/concerns/columns_concern.rb | 4 ++-- spec/models/concerns/columns_concern_spec.rb | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/models/concerns/columns_concern.rb b/app/models/concerns/columns_concern.rb index 37c27a2ea..b827c3655 100644 --- a/app/models/concerns/columns_concern.rb +++ b/app/models/concerns/columns_concern.rb @@ -30,7 +30,7 @@ module ColumnsConcern end end - def all_usager_columns_for_export + def usager_columns_for_export columns = [dossier_id_column, user_email_for_display_column, user_france_connected_column] columns.concat(individual_columns) if for_individual columns.concat(moral_columns) if !for_individual @@ -39,7 +39,7 @@ module ColumnsConcern columns.flatten.compact end - def all_dossier_columns_for_export + def dossier_columns_for_export columns = [dossier_state_column] columns.concat([dossier_archived_column]) columns.concat(dossier_dates_columns) diff --git a/spec/models/concerns/columns_concern_spec.rb b/spec/models/concerns/columns_concern_spec.rb index d1386be36..44ca9f1d3 100644 --- a/spec/models/concerns/columns_concern_spec.rb +++ b/spec/models/concerns/columns_concern_spec.rb @@ -146,7 +146,7 @@ describe ColumnsConcern do ] end - describe '#all_usager_columns_for_export' do + describe '#usager_columns_for_export' do context 'for individual procedure' do let(:for_individual) { true } @@ -162,7 +162,7 @@ describe ColumnsConcern do procedure.find_column(label: "Nom du mandataire"), procedure.find_column(label: "Prénom du mandataire") ] - actuals = procedure.all_usager_columns_for_export.map(&:h_id) + actuals = procedure.usager_columns_for_export.map(&:h_id) expected.each do |expected_col| expect(actuals).to include(expected_col.h_id) end @@ -199,7 +199,7 @@ describe ColumnsConcern do procedure.find_column(label: "Entreprise SIRET siège social"), procedure.find_column(label: "Entreprise code effectif entreprise") ] - actuals = procedure.all_usager_columns_for_export + actuals = procedure.usager_columns_for_export expected.each do |expected_col| expect(actuals.map(&:h_id)).to include(expected_col.h_id) end @@ -217,7 +217,7 @@ describe ColumnsConcern do procedure.find_column(label: "Référentiel De Programmation"), procedure.find_column(label: "Centre De Coût") ] - actuals = procedure.all_usager_columns_for_export.map(&:h_id) + actuals = procedure.usager_columns_for_export.map(&:h_id) expected.each do |expected_col| expect(actuals).to include(expected_col.h_id) end @@ -225,7 +225,7 @@ describe ColumnsConcern do end end - describe '#all_dossier_columns_for_export' do + describe '#dossier_columns_for_export' do let(:procedure) { create(:procedure_with_dossiers, :routee, :published, types_de_champ_public:, for_individual:) } it "returns all dossier columns" do @@ -241,7 +241,7 @@ describe ColumnsConcern do procedure.find_column(label: "Instructeurs"), procedure.find_column(label: "Groupe instructeur") ] - actuals = procedure.all_dossier_columns_for_export.map(&:h_id) + actuals = procedure.dossier_columns_for_export.map(&:h_id) expected.each do |expected_col| expect(actuals).to include(expected_col.h_id) end From d618f7cc0f3afa6efcf5394a7b8a97e7609db113 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 30 Oct 2024 16:09:40 +0100 Subject: [PATCH 12/15] only expose chorus col when necessary --- app/models/concerns/columns_concern.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/concerns/columns_concern.rb b/app/models/concerns/columns_concern.rb index b827c3655..7590cf80e 100644 --- a/app/models/concerns/columns_concern.rb +++ b/app/models/concerns/columns_concern.rb @@ -25,7 +25,7 @@ module ColumnsConcern columns.concat(standard_columns) columns.concat(individual_columns) if for_individual columns.concat(moral_columns) if !for_individual - columns.concat(procedure_chorus_columns) + columns.concat(procedure_chorus_columns) if chorusable? && chorus_configuration.complete? columns.concat(types_de_champ_columns) end end From 96cd4fda72fafe0130a3ea5ebafb066a33a2c7c2 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 30 Oct 2024 16:38:43 +0100 Subject: [PATCH 13/15] ensure exported columns existed in main columns function --- app/models/concerns/columns_concern.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/models/concerns/columns_concern.rb b/app/models/concerns/columns_concern.rb index 7590cf80e..d360d3d1d 100644 --- a/app/models/concerns/columns_concern.rb +++ b/app/models/concerns/columns_concern.rb @@ -36,18 +36,19 @@ module ColumnsConcern columns.concat(moral_columns) if !for_individual columns.concat(procedure_chorus_columns) if chorusable? && chorus_configuration.complete? - columns.flatten.compact + # ensure the columns exist in main list + columns.filter { _1.id.in?(self.columns.map(&:id)) } end def dossier_columns_for_export - columns = [dossier_state_column] - columns.concat([dossier_archived_column]) + columns = [dossier_state_column, dossier_archived_column] columns.concat(dossier_dates_columns) columns.concat([dossier_motivation_column]) columns.concat(sva_svr_columns(for_export: true)) if sva_svr_enabled? - columns.concat([groupe_instructeurs_id_column]) - columns.concat([followers_instructeurs_email_column]) - columns.flatten.compact + columns.concat([groupe_instructeurs_id_column, followers_instructeurs_email_column]) + + # ensure the columns exist in main list + columns.filter { _1.id.in?(self.columns.map(&:id)) } end def dossier_id_column = Column.new(procedure_id: id, table: 'self', column: 'id', type: :number) From 5981de90a2266daddf6a358a8435b8e19e8aa6de Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 30 Oct 2024 18:30:38 +0100 Subject: [PATCH 14/15] use Columns::DossierColumn --- app/models/concerns/columns_concern.rb | 44 +++++++++++++------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/app/models/concerns/columns_concern.rb b/app/models/concerns/columns_concern.rb index d360d3d1d..da9c312a1 100644 --- a/app/models/concerns/columns_concern.rb +++ b/app/models/concerns/columns_concern.rb @@ -51,21 +51,21 @@ module ColumnsConcern columns.filter { _1.id.in?(self.columns.map(&:id)) } end - def dossier_id_column = Column.new(procedure_id: id, table: 'self', column: 'id', type: :number) + def dossier_id_column = Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'id', type: :number) - def dossier_state_column = Column.new(procedure_id: id, table: 'self', column: 'state', type: :enum, scope: 'instructeurs.dossiers.filterable_state', displayable: false) + def dossier_state_column = Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'state', type: :enum, scope: 'instructeurs.dossiers.filterable_state', displayable: false) - def notifications_column = Column.new(procedure_id: id, table: 'notifications', column: 'notifications', label: "notifications", filterable: false) + def notifications_column = Columns::DossierColumn.new(procedure_id: id, table: 'notifications', column: 'notifications', label: "notifications", filterable: false) def sva_svr_columns(for_export: false) scope = [:activerecord, :attributes, :procedure_presentation, :fields, :self] columns = [ - Column.new(procedure_id: id, table: 'self', column: 'sva_svr_decision_on', type: :date, + Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'sva_svr_decision_on', type: :date, label: I18n.t("#{sva_svr_decision}_decision_on", scope:, type: sva_svr_configuration.human_decision)) ] if !for_export - columns << Column.new(procedure_id: id, table: 'self', column: 'sva_svr_decision_before', type: :date, displayable: false, + columns << Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'sva_svr_decision_before', type: :date, displayable: false, label: I18n.t("#{sva_svr_decision}_decision_before", scope:)) end columns @@ -79,35 +79,35 @@ module ColumnsConcern private - def groupe_instructeurs_id_column = Column.new(procedure_id: id, table: 'groupe_instructeur', column: 'id', type: :enum) + def groupe_instructeurs_id_column = Columns::DossierColumn.new(procedure_id: id, table: 'groupe_instructeur', column: 'id', type: :enum) - def followers_instructeurs_email_column = Column.new(procedure_id: id, table: 'followers_instructeurs', column: 'email') + def followers_instructeurs_email_column = Columns::DossierColumn.new(procedure_id: id, table: 'followers_instructeurs', column: 'email') - def dossier_archived_column = Column.new(procedure_id: id, table: 'self', column: 'archived', type: :text, displayable: false, filterable: false); + def dossier_archived_column = Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'archived', type: :text, displayable: false, filterable: false); - def dossier_motivation_column = Column.new(procedure_id: id, table: 'self', column: 'motivation', type: :text, displayable: false, filterable: false); + def dossier_motivation_column = Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'motivation', type: :text, displayable: false, filterable: false); - def user_email_for_display_column = Column.new(procedure_id: id, table: 'self', column: 'user_email_for_display', filterable: false, displayable: false) + def user_email_for_display_column = Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'user_email_for_display', filterable: false, displayable: false) - def user_france_connected_column = Column.new(procedure_id: id, table: 'self', column: 'user_from_france_connect?', filterable: false, displayable: false) + def user_france_connected_column = Columns::DossierColumn.new(procedure_id: id, table: 'self', column: 'user_from_france_connect?', filterable: false, displayable: false) def procedure_chorus_columns ['domaine_fonctionnel', 'referentiel_prog', 'centre_de_cout'] - .map { |column| Column.new(procedure_id: id, table: 'procedure', column:, displayable: false, filterable: false) } + .map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'procedure', column:, displayable: false, filterable: false) } end def dossier_non_displayable_dates_columns ['updated_since', 'depose_since', 'en_construction_since', 'en_instruction_since', 'processed_since'] - .map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :date, displayable: false) } + .map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'self', column:, type: :date, displayable: false) } end def dossier_dates_columns ['created_at', 'updated_at', 'last_champ_updated_at', 'depose_at', 'en_construction_at', 'en_instruction_at', 'processed_at'] - .map { |column| Column.new(procedure_id: id, table: 'self', column:, type: :date) } + .map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'self', column:, type: :date) } end def email_column - Column.new(procedure_id: id, table: 'user', column: 'email') + Columns::DossierColumn.new(procedure_id: id, table: 'user', column: 'email') end def dossier_columns @@ -127,26 +127,26 @@ module ColumnsConcern user_email_for_display_column, followers_instructeurs_email_column, groupe_instructeurs_id_column, - Column.new(procedure_id: id, table: 'avis', column: 'question_answer', filterable: false), + Columns::DossierColumn.new(procedure_id: id, table: 'avis', column: 'question_answer', filterable: false), user_france_connected_column ] end def individual_columns - ['gender', 'nom', 'prenom'].map { |column| Column.new(procedure_id: id, table: 'individual', column:) } - .concat ['for_tiers', 'mandataire_last_name', 'mandataire_first_name'].map { |column| Column.new(procedure_id: id, table: 'self', column:) } + ['gender', 'nom', 'prenom'].map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'individual', column:) } + .concat ['for_tiers', 'mandataire_last_name', 'mandataire_first_name'].map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'self', column:) } end def moral_columns etablissements = ['entreprise_forme_juridique', 'entreprise_siren', 'entreprise_nom_commercial', 'entreprise_raison_sociale', 'entreprise_siret_siege_social'] - .map { |column| Column.new(procedure_id: id, table: 'etablissement', column:) } + .map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'etablissement', column:) } - etablissement_dates = ['entreprise_date_creation'].map { |column| Column.new(procedure_id: id, table: 'etablissement', column:, type: :date) } + etablissement_dates = ['entreprise_date_creation'].map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'etablissement', column:, type: :date) } for_export = ["siege_social", "naf", "adresse", "numero_voie", "type_voie", "nom_voie", "complement_adresse", "localite", "code_insee_localite", "entreprise_siren", "entreprise_capital_social", "entreprise_numero_tva_intracommunautaire", "entreprise_forme_juridique_code", "entreprise_code_effectif_entreprise", "entreprise_etat_administratif", "entreprise_nom", "entreprise_prenom", "association_rna", "association_titre", "association_objet", "association_date_creation", "association_date_declaration", "association_date_publication"] - .map { |column| Column.new(procedure_id: id, table: 'etablissement', column:, displayable: false, filterable: false) } + .map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'etablissement', column:, displayable: false, filterable: false) } - other = ['siret', 'libelle_naf', 'code_postal'].map { |column| Column.new(procedure_id: id, table: 'etablissement', column:) } + other = ['siret', 'libelle_naf', 'code_postal'].map { |column| Columns::DossierColumn.new(procedure_id: id, table: 'etablissement', column:) } [etablissements, etablissement_dates, other, for_export].flatten end From ab9a0fc34fd9d1744c4b7428fd55b1b53c268dc5 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 30 Oct 2024 18:34:11 +0100 Subject: [PATCH 15/15] remove extraneous flatten compact --- app/models/concerns/columns_concern.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/concerns/columns_concern.rb b/app/models/concerns/columns_concern.rb index da9c312a1..1a9ecab1a 100644 --- a/app/models/concerns/columns_concern.rb +++ b/app/models/concerns/columns_concern.rb @@ -118,7 +118,6 @@ module ColumnsConcern columns.concat([dossier_motivation_column]) columns.concat(sva_svr_columns(for_export: false)) if sva_svr_enabled? columns.concat(dossier_non_displayable_dates_columns) - columns.flatten.compact end def standard_columns