Skip to content

Commit

Permalink
Only display field if kind=BUYER selected
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Nov 23, 2023
1 parent 5d13212 commit 6aa1762
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lemarche/templates/auth/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ <h1 class="s-title-01__title h1">Inscription</h1>
<hr>
<fieldset id="infoStructuresFieldset" class="d-none">
<legend>Informations structure</legend>
{% bootstrap_field form.buyer_kind_detail form_group_class="buyer-kind-detail-form-group form-group form-group-required d-none" %}
{% bootstrap_field form.partner_kind form_group_class="partner-kind-form-group form-group form-group-required d-none" %}
{% bootstrap_field form.company_name form_group_class="company-name-form-group form-group form-group-required d-none" %}
{% bootstrap_field form.position form_group_class="position-form-group form-group form-group-required d-none" %}
Expand Down Expand Up @@ -113,15 +114,17 @@ <h1 class="s-title-01__title h1">Inscription</h1>
* - add survey checkbox
* - if the user is BUYER:
* - make phone field required
* - add buyer_kind_detail field (and make it required)
* - add position field (and make it required)
* - add survey checkbox for newsletter
*/
document.addEventListener('DOMContentLoaded', function() {
let phoneInput = document.getElementById('id_phone');
let companyNameSiaeFormGroupDiv = document.getElementsByClassName('company-name-siae-form-group')[0];
let buyerKindDetailInput = document.getElementById('id_buyer_kind_detail');
let partnerKindInput = document.getElementById('id_partner_kind');
let companyNameInput = document.getElementById('id_company_name');
let companyNameSiaeFormGroupDiv = document.getElementsByClassName('company-name-siae-form-group')[0];
let positionInput = document.getElementById('id_position');
let partnerKindInput = document.getElementById('id_partner_kind');
let acceptSurveyInput = document.getElementById('id_accept_survey');
let acceptShareContactInput = document.getElementById('id_accept_share_contact_to_external_partners');
let statsSignupBuyerContent = document.getElementById('statsSignupBuyer');
Expand All @@ -143,11 +146,13 @@ <h1 class="s-title-01__title h1">Inscription</h1>
}

if (radio.value === 'BUYER') {
toggleInputElement(true, element=buyerKindDetailInput, required=true);
toggleInputElement(true, element=positionInput, required=true);
toggleInputElement(true, element=phoneInput, required=true);
statsSignupBuyerContent.classList.remove('d-none');
toggleInputElement(true, element=sectorsInput, required=false);
} else {
toggleInputElement(false, element=buyerKindDetailInput, required=false);
toggleInputElement(false, element=positionInput, required=false);
toggleInputElement(true, element=phoneInput, required=false);
statsSignupBuyerContent.classList.add('d-none');
Expand Down

0 comments on commit 6aa1762

Please sign in to comment.