Merge pull request #7798 from E-L-T/7400-lisibilite-liste-de-champs-elt
7400 Améliore la lisibilité de la liste de types de champ
This commit is contained in:
commit
32cdff820f
7 changed files with 118 additions and 24 deletions
|
@ -56,13 +56,32 @@ class TypesDeChampEditor::ChampComponent < ApplicationComponent
|
||||||
end
|
end
|
||||||
|
|
||||||
def types_of_type_de_champ
|
def types_of_type_de_champ
|
||||||
TypeDeChamp.type_champs
|
if Flipper.enabled?(:categories_type_de_champ, controller.current_user)
|
||||||
.keys
|
cat_scope = "activerecord.attributes.type_de_champ.categorie"
|
||||||
.filter(&method(:filter_type_champ))
|
tdc_scope = "activerecord.attributes.type_de_champ.type_champs"
|
||||||
.filter(&method(:filter_featured_type_champ))
|
|
||||||
.filter(&method(:filter_block_type_champ))
|
TypeDeChamp.type_champs
|
||||||
.map { |type_champ| [t("activerecord.attributes.type_de_champ.type_champs.#{type_champ}"), type_champ] }
|
.keys
|
||||||
.sort_by(&:first)
|
.filter(&method(:filter_type_champ))
|
||||||
|
.filter(&method(:filter_featured_type_champ))
|
||||||
|
.filter(&method(:filter_block_type_champ))
|
||||||
|
.group_by { TypeDeChamp::TYPE_DE_CHAMP_TO_CATEGORIE.fetch(_1.to_sym) }
|
||||||
|
.sort_by { |k, _v| TypeDeChamp::CATEGORIES.find_index(k) }
|
||||||
|
.to_h do |cat, tdc|
|
||||||
|
[
|
||||||
|
t(cat, scope: cat_scope),
|
||||||
|
tdc.map { [t(_1, scope: tdc_scope), _1] }
|
||||||
|
]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
TypeDeChamp.type_champs
|
||||||
|
.keys
|
||||||
|
.filter(&method(:filter_type_champ))
|
||||||
|
.filter(&method(:filter_featured_type_champ))
|
||||||
|
.filter(&method(:filter_block_type_champ))
|
||||||
|
.map { |type_champ| [t("activerecord.attributes.type_de_champ.type_champs.#{type_champ}"), type_champ] }
|
||||||
|
.sort_by(&:first)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def piece_justificative_options(form)
|
def piece_justificative_options(form)
|
||||||
|
|
|
@ -19,7 +19,10 @@
|
||||||
%span.sr-only Déplacer le champ vers le bas
|
%span.sr-only Déplacer le champ vers le bas
|
||||||
.cell.flex.justify-start.column.flex-grow
|
.cell.flex.justify-start.column.flex-grow
|
||||||
= form.label :type_champ, "Type de champ", for: dom_id(type_de_champ, :type_champ)
|
= form.label :type_champ, "Type de champ", for: dom_id(type_de_champ, :type_champ)
|
||||||
= form.select :type_champ, types_of_type_de_champ, {}, class: 'small-margin small inline width-100', id: dom_id(type_de_champ, :type_champ)
|
- if Flipper.enabled?(:categories_type_de_champ, controller.current_user)
|
||||||
|
= form.select :type_champ, grouped_options_for_select(types_of_type_de_champ, type_de_champ.type_champ), {}, class: 'small-margin small inline width-100', id: dom_id(type_de_champ, :type_champ)
|
||||||
|
- else
|
||||||
|
= form.select :type_champ, types_of_type_de_champ, {}, class: 'small-margin small inline width-100', id: dom_id(type_de_champ, :type_champ)
|
||||||
.flex.column.justify-start.flex-grow
|
.flex.column.justify-start.flex-grow
|
||||||
.cell
|
.cell
|
||||||
.flex.align-center
|
.flex.align-center
|
||||||
|
|
|
@ -20,6 +20,53 @@ class TypeDeChamp < ApplicationRecord
|
||||||
FILE_MAX_SIZE = 200.megabytes
|
FILE_MAX_SIZE = 200.megabytes
|
||||||
FEATURE_FLAGS = {}
|
FEATURE_FLAGS = {}
|
||||||
|
|
||||||
|
CADRE = :cadre
|
||||||
|
STANDARD = :standard
|
||||||
|
CHOICE = :choice
|
||||||
|
ETAT_CIVIL = :etat_civil
|
||||||
|
PAIEMENT_IDENTIFICATION = :paiement_identification
|
||||||
|
REFERENTIEL_EXTERNE = :referentiel_externe
|
||||||
|
LOCALISATION = :localisation
|
||||||
|
|
||||||
|
CATEGORIES = [CADRE, ETAT_CIVIL, LOCALISATION, PAIEMENT_IDENTIFICATION, STANDARD, CHOICE, REFERENTIEL_EXTERNE]
|
||||||
|
|
||||||
|
TYPE_DE_CHAMP_TO_CATEGORIE = {
|
||||||
|
text: STANDARD,
|
||||||
|
textarea: STANDARD,
|
||||||
|
date: STANDARD,
|
||||||
|
datetime: STANDARD,
|
||||||
|
number: STANDARD,
|
||||||
|
decimal_number: STANDARD,
|
||||||
|
integer_number: STANDARD,
|
||||||
|
checkbox: CHOICE,
|
||||||
|
civilite: ETAT_CIVIL,
|
||||||
|
email: ETAT_CIVIL,
|
||||||
|
phone: ETAT_CIVIL,
|
||||||
|
address: LOCALISATION,
|
||||||
|
yes_no: CHOICE,
|
||||||
|
drop_down_list: CHOICE,
|
||||||
|
multiple_drop_down_list: CHOICE,
|
||||||
|
linked_drop_down_list: CHOICE,
|
||||||
|
pays: LOCALISATION,
|
||||||
|
regions: LOCALISATION,
|
||||||
|
departements: LOCALISATION,
|
||||||
|
communes: LOCALISATION,
|
||||||
|
header_section: CADRE,
|
||||||
|
explication: CADRE,
|
||||||
|
dossier_link: CADRE,
|
||||||
|
piece_justificative: STANDARD,
|
||||||
|
siret: PAIEMENT_IDENTIFICATION,
|
||||||
|
carte: REFERENTIEL_EXTERNE,
|
||||||
|
repetition: CADRE,
|
||||||
|
titre_identite: ETAT_CIVIL,
|
||||||
|
iban: PAIEMENT_IDENTIFICATION,
|
||||||
|
annuaire_education: REFERENTIEL_EXTERNE,
|
||||||
|
cnaf: REFERENTIEL_EXTERNE,
|
||||||
|
dgfip: REFERENTIEL_EXTERNE,
|
||||||
|
pole_emploi: REFERENTIEL_EXTERNE,
|
||||||
|
mesri: REFERENTIEL_EXTERNE
|
||||||
|
}
|
||||||
|
|
||||||
enum type_champs: {
|
enum type_champs: {
|
||||||
text: 'text',
|
text: 'text',
|
||||||
textarea: 'textarea',
|
textarea: 'textarea',
|
||||||
|
@ -37,19 +84,19 @@ class TypeDeChamp < ApplicationRecord
|
||||||
drop_down_list: 'drop_down_list',
|
drop_down_list: 'drop_down_list',
|
||||||
multiple_drop_down_list: 'multiple_drop_down_list',
|
multiple_drop_down_list: 'multiple_drop_down_list',
|
||||||
linked_drop_down_list: 'linked_drop_down_list',
|
linked_drop_down_list: 'linked_drop_down_list',
|
||||||
pays: 'pays',
|
|
||||||
regions: 'regions',
|
|
||||||
departements: 'departements',
|
|
||||||
communes: 'communes',
|
communes: 'communes',
|
||||||
|
departements: 'departements',
|
||||||
|
regions: 'regions',
|
||||||
|
pays: 'pays',
|
||||||
header_section: 'header_section',
|
header_section: 'header_section',
|
||||||
explication: 'explication',
|
explication: 'explication',
|
||||||
dossier_link: 'dossier_link',
|
dossier_link: 'dossier_link',
|
||||||
piece_justificative: 'piece_justificative',
|
piece_justificative: 'piece_justificative',
|
||||||
siret: 'siret',
|
|
||||||
carte: 'carte',
|
carte: 'carte',
|
||||||
repetition: 'repetition',
|
repetition: 'repetition',
|
||||||
titre_identite: 'titre_identite',
|
titre_identite: 'titre_identite',
|
||||||
iban: 'iban',
|
iban: 'iban',
|
||||||
|
siret: 'siret',
|
||||||
annuaire_education: 'annuaire_education',
|
annuaire_education: 'annuaire_education',
|
||||||
cnaf: 'cnaf',
|
cnaf: 'cnaf',
|
||||||
dgfip: 'dgfip',
|
dgfip: 'dgfip',
|
||||||
|
|
|
@ -21,6 +21,7 @@ end
|
||||||
features = [
|
features = [
|
||||||
:administrateur_web_hook,
|
:administrateur_web_hook,
|
||||||
:api_particulier,
|
:api_particulier,
|
||||||
|
:categories_type_de_champ,
|
||||||
:dossier_pdf_vide,
|
:dossier_pdf_vide,
|
||||||
:expert_not_allowed_to_invite,
|
:expert_not_allowed_to_invite,
|
||||||
:hide_instructeur_email,
|
:hide_instructeur_email,
|
||||||
|
|
|
@ -4,6 +4,15 @@ fr:
|
||||||
type_de_champ: 'Type de champ'
|
type_de_champ: 'Type de champ'
|
||||||
attributes:
|
attributes:
|
||||||
type_de_champ:
|
type_de_champ:
|
||||||
|
categorie:
|
||||||
|
standard: 'Standard'
|
||||||
|
choice: 'Choix'
|
||||||
|
etat_civil: 'État civil'
|
||||||
|
cadre: 'Cadre'
|
||||||
|
file: 'Fichier'
|
||||||
|
paiement_identification: 'Paiement - Identification'
|
||||||
|
referentiel_externe: 'Référentiel externe'
|
||||||
|
localisation: 'Localisation'
|
||||||
type_champs:
|
type_champs:
|
||||||
text: 'Texte'
|
text: 'Texte'
|
||||||
textarea: 'Zone de texte'
|
textarea: 'Zone de texte'
|
||||||
|
|
|
@ -64,18 +64,18 @@ describe ProcedureExportService do
|
||||||
"simple_drop_down_list",
|
"simple_drop_down_list",
|
||||||
"multiple_drop_down_list",
|
"multiple_drop_down_list",
|
||||||
"linked_drop_down_list",
|
"linked_drop_down_list",
|
||||||
"pays",
|
|
||||||
"regions",
|
|
||||||
"departements",
|
|
||||||
"communes",
|
"communes",
|
||||||
"communes (Code insee)",
|
"communes (Code insee)",
|
||||||
"communes (Département)",
|
"communes (Département)",
|
||||||
|
"departements",
|
||||||
|
"regions",
|
||||||
|
"pays",
|
||||||
"dossier_link",
|
"dossier_link",
|
||||||
"piece_justificative",
|
"piece_justificative",
|
||||||
"siret",
|
|
||||||
"carte",
|
"carte",
|
||||||
"titre_identite",
|
"titre_identite",
|
||||||
"iban",
|
"iban",
|
||||||
|
"siret",
|
||||||
"annuaire_education",
|
"annuaire_education",
|
||||||
"cnaf",
|
"cnaf",
|
||||||
"dgfip",
|
"dgfip",
|
||||||
|
@ -155,18 +155,18 @@ describe ProcedureExportService do
|
||||||
"simple_drop_down_list",
|
"simple_drop_down_list",
|
||||||
"multiple_drop_down_list",
|
"multiple_drop_down_list",
|
||||||
"linked_drop_down_list",
|
"linked_drop_down_list",
|
||||||
"pays",
|
|
||||||
"regions",
|
|
||||||
"departements",
|
|
||||||
"communes",
|
"communes",
|
||||||
"communes (Code insee)",
|
"communes (Code insee)",
|
||||||
"communes (Département)",
|
"communes (Département)",
|
||||||
|
"departements",
|
||||||
|
"regions",
|
||||||
|
"pays",
|
||||||
"dossier_link",
|
"dossier_link",
|
||||||
"piece_justificative",
|
"piece_justificative",
|
||||||
"siret",
|
|
||||||
"carte",
|
"carte",
|
||||||
"titre_identite",
|
"titre_identite",
|
||||||
"iban",
|
"iban",
|
||||||
|
"siret",
|
||||||
"annuaire_education",
|
"annuaire_education",
|
||||||
"cnaf",
|
"cnaf",
|
||||||
"dgfip",
|
"dgfip",
|
||||||
|
@ -241,18 +241,18 @@ describe ProcedureExportService do
|
||||||
"simple_drop_down_list",
|
"simple_drop_down_list",
|
||||||
"multiple_drop_down_list",
|
"multiple_drop_down_list",
|
||||||
"linked_drop_down_list",
|
"linked_drop_down_list",
|
||||||
"pays",
|
|
||||||
"regions",
|
|
||||||
"departements",
|
|
||||||
"communes",
|
"communes",
|
||||||
"communes (Code insee)",
|
"communes (Code insee)",
|
||||||
"communes (Département)",
|
"communes (Département)",
|
||||||
|
"departements",
|
||||||
|
"regions",
|
||||||
|
"pays",
|
||||||
"dossier_link",
|
"dossier_link",
|
||||||
"piece_justificative",
|
"piece_justificative",
|
||||||
"siret",
|
|
||||||
"carte",
|
"carte",
|
||||||
"titre_identite",
|
"titre_identite",
|
||||||
"iban",
|
"iban",
|
||||||
|
"siret",
|
||||||
"annuaire_education",
|
"annuaire_education",
|
||||||
"cnaf",
|
"cnaf",
|
||||||
"dgfip",
|
"dgfip",
|
||||||
|
|
|
@ -69,4 +69,19 @@ describe 'Creating a new procedure', js: true do
|
||||||
expect(champs_card).to have_content('À modifier')
|
expect(champs_card).to have_content('À modifier')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with feature activated' do
|
||||||
|
let(:procedure) { create(:procedure, :with_service, administrateur: administrateur) }
|
||||||
|
before { Flipper.enable(:categories_type_de_champ, administrateur.user) }
|
||||||
|
after { Flipper.disable(:categories_type_de_champ, administrateur.user) }
|
||||||
|
|
||||||
|
it 'types de champ are grouped by categories ' do
|
||||||
|
visit champs_admin_procedure_path(procedure)
|
||||||
|
|
||||||
|
add_champ(remove_flash_message: true)
|
||||||
|
select('Bloc répétable', from: 'Type de champ')
|
||||||
|
|
||||||
|
expect(page).to have_selector('select > optgroup', count: 7)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue