diff --git a/src/Bundle/ChillPersonBundle/Form/PersonType.php b/src/Bundle/ChillPersonBundle/Form/PersonType.php index d576822a9..0e3bedce5 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonType.php @@ -127,7 +127,7 @@ class PersonType extends AbstractType ->add('mobilenumber', TelType::class, array('required' => false)) ->add('acceptSMS', CheckboxType::class, array( 'value' => false, - 'required' => true //TODO required only if mobilenumber is filled + 'required' => true )); } @@ -149,7 +149,7 @@ class PersonType extends AbstractType if ($this->config['email'] === 'visible') { $builder ->add('email', EmailType::class, array('required' => false)) - ->add('acceptEmail', CheckboxType::class, array('required' => false));//TODO visible only if email is filled + ->add('acceptEmail', CheckboxType::class, array('required' => false)); } if ($this->config['country_of_birth'] === 'visible') { diff --git a/src/Bundle/ChillPersonBundle/Form/Type/GenderType.php b/src/Bundle/ChillPersonBundle/Form/Type/GenderType.php index 232c838bb..bdd31e899 100644 --- a/src/Bundle/ChillPersonBundle/Form/Type/GenderType.php +++ b/src/Bundle/ChillPersonBundle/Form/Type/GenderType.php @@ -24,8 +24,7 @@ class GenderType extends AbstractType { $a = array( Person::MALE_GENDER => Person::MALE_GENDER, Person::FEMALE_GENDER => Person::FEMALE_GENDER, - Person::BOTH_GENDER => Person::BOTH_GENDER, - Person::NO_INFORMATION => Person::NO_INFORMATION + Person::BOTH_GENDER => Person::BOTH_GENDER ); $resolver->setDefaults(array( diff --git a/src/Bundle/ChillPersonBundle/Resources/public/js/person.js b/src/Bundle/ChillPersonBundle/Resources/public/js/person.js new file mode 100644 index 000000000..6ebd8d7cc --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/public/js/person.js @@ -0,0 +1,38 @@ +import { ShowHide } from 'ShowHide/show_hide.js'; + +const personEmail = document.getElementById("personEmail"); +const personAcceptEmail = document.getElementById("personAcceptEmail"); +const personPhoneNumber = document.getElementById("personPhoneNumber"); +const personAcceptSMS = document.getElementById("personAcceptSMS"); + +new ShowHide({ + froms: [personEmail], + container: [personAcceptEmail], + test: function(froms) { + for (let f of froms.values()) { + for (let input of f.querySelectorAll('input').values()) { + if (input.value) { + return true + } + } + } + return false; + }, + event_name: 'input' +}); + +new ShowHide({ + froms: [personPhoneNumber], + container: [personAcceptSMS], + test: function(froms) { + for (let f of froms.values()) { + for (let input of f.querySelectorAll('input').values()) { + if (input.value) { + return true + } + } + } + return false; + }, + event_name: 'input' +}); diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/edit.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/edit.html.twig index 66e1cb6e6..95b4e6f62 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/edit.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/edit.html.twig @@ -82,15 +82,24 @@

{{ 'Contact information'|trans }}

{%- if form.email is defined -%} - {{ form_row(form.email, {'label': 'Email'}) }} - {{ form_row(form.acceptEmail, {'label' : 'Accept emails ?'}) }} +
+ {{ form_row(form.email, {'label': 'Email'}) }} +
+
+ {{ form_row(form.acceptEmail, {'label' : 'Accept emails ?'}) }} +
{%- endif -%} + {%- if form.phonenumber is defined -%} {{ form_row(form.phonenumber, {'label': 'Phonenumber'}) }} {%- endif -%} {%- if form.mobilenumber is defined -%} - {{ form_row(form.mobilenumber, {'label': 'Mobilenumber'}) }} - {{ form_row(form.acceptSMS, {'label' : 'Accept short text message ?'}) }} +
+ {{ form_row(form.mobilenumber, {'label': 'Mobilenumber'}) }} +
+
+ {{ form_row(form.acceptSMS, {'label' : 'Accept short text message ?'}) }} +
{%- endif -%} {%- if form.otherPhoneNumbers is defined -%} {{ form_widget(form.otherPhoneNumbers) }} @@ -123,3 +132,8 @@ {% endblock personcontent %} + + +{% block js %} + +{% endblock js %} diff --git a/src/Bundle/ChillPersonBundle/chill.webpack.config.js b/src/Bundle/ChillPersonBundle/chill.webpack.config.js index f68481083..99028ecd8 100644 --- a/src/Bundle/ChillPersonBundle/chill.webpack.config.js +++ b/src/Bundle/ChillPersonBundle/chill.webpack.config.js @@ -7,8 +7,9 @@ module.exports = function(encore, entries) encore.addAliases({ ChillPersonAssets: __dirname + '/Resources/public' }); - + encore.addEntry('accompanying_course', __dirname + '/Resources/public/vuejs/AccompanyingCourse/index.js'); encore.addEntry('household_members_editor', __dirname + '/Resources/public/vuejs/HouseholdMembersEditor/index.js'); encore.addEntry('vue_accourse', __dirname + '/Resources/public/vuejs/AccompanyingCourse/index.js'); + encore.addEntry('person', __dirname + '/Resources/public/js/person.js'); }; diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index e6f33355c..ee5812571 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -62,8 +62,6 @@ Man: Homme Woman: Femme both: Indéterminé Both: Indéterminé -unknown: Aucune information -Unknown: Aucune information Divorced: Divorcé(e) Separated: Séparé(e) Widow: Veuf(ve)