Merge pull request #4068 from betagouv/better_default_value_for_linked_list

better default value for linked_drop_down_list
This commit is contained in:
LeSim 2019-07-10 10:33:12 +02:00 committed by GitHub
commit 7a53ca127c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -22,7 +22,6 @@ class TypesDeChampEditor extends Component {
type_champ: 'text',
types_de_champ: [],
private: props.isAnnotation,
drop_down_list_value: '--Premier élément du menu--\n',
libelle: `${
props.isAnnotation ? 'Nouvelle annotation' : 'Nouveau champ'
} ${props.typeDeChampsTypes[0][0]}`

View file

@ -115,6 +115,18 @@ function updateTypeDeChamp(
{ typeDeChamp, field, value },
done
) {
if (field == 'type_champ' && !typeDeChamp.drop_down_list_value) {
switch (value) {
case 'linked_drop_down_list':
typeDeChamp.drop_down_list_value =
'--Fromage--\nbleu de sassenage\npicodon\n--Dessert--\néclair\ntarte aux pommes\n';
break;
case 'drop_down_list':
case 'multiple_drop_down_list':
typeDeChamp.drop_down_list_value = '--Premier élément du menu--\n';
}
}
typeDeChamp[field] = value;
getUpdateHandler(typeDeChamp, state)(done);