Commit f54ca15d by Félicie

radio button added

parent 2e87daab
Pipeline #2409 passed with stage
in 1 minute 24 seconds
...@@ -127,6 +127,7 @@ function create_new_coop() { ...@@ -127,6 +127,7 @@ function create_new_coop() {
$('.chosen_associate_area').hide(); $('.chosen_associate_area').hide();
$('.member_choice').removeClass('choice_active'); $('.member_choice').removeClass('choice_active');
$(".remove_binome_icon").on("click", hide_chosen_associate); $(".remove_binome_icon").on("click", hide_chosen_associate);
$('input[name="binome"]').prop('checked',false);
local_in_process = getLocalInProcess(); local_in_process = getLocalInProcess();
if (getLocalInProcess().length > 0) { if (getLocalInProcess().length > 0) {
empty_waiting_local_processes(); empty_waiting_local_processes();
...@@ -243,6 +244,7 @@ function store_new_coop(event) { ...@@ -243,6 +244,7 @@ function store_new_coop(event) {
var errors = [], var errors = [],
bc = '', // barcode may not be present bc = '', // barcode may not be present
msex = '', // sex may not be present msex = '', // sex may not be present
associated_area_actived = $('#associate_area'); // need to ckeck if type of association is choosen
active_asso_area = $('#associate_area .choice_active'); // need to ckeck if associated data are available active_asso_area = $('#associate_area .choice_active'); // need to ckeck if associated data are available
// 1- Un coop avec le meme mail ne doit pas exister dans odoo (dans base intermediaire, le cas est géré par l'erreur à l'enregistrement) // 1- Un coop avec le meme mail ne doit pas exister dans odoo (dans base intermediaire, le cas est géré par l'erreur à l'enregistrement)
let email = $('input[name="email"]').val() let email = $('input[name="email"]').val()
...@@ -268,6 +270,21 @@ function store_new_coop(event) { ...@@ -268,6 +270,21 @@ function store_new_coop(event) {
} }
} }
if (associated_area_actived.show()) {
// If user choose yes for binome, a type of association must be selected
let associated_data_selected = false;
if (
($(active_asso_area[0]).attr('id') === "new_member_choice")
||
($(active_asso_area[0]).attr('id') === "existing_member_choice")
) {
associated_data_selected = true;
}
if (associated_data_selected === false) errors.push("Un des deux choix doit être sélectionné");
}
if (active_asso_area.length > 0) { if (active_asso_area.length > 0) {
// If user click as if a "binôme" is beeing created, data about parent member must exist // If user click as if a "binôme" is beeing created, data about parent member must exist
let associated_data_ok = false; let associated_data_ok = false;
...@@ -279,10 +296,15 @@ function store_new_coop(event) { ...@@ -279,10 +296,15 @@ function store_new_coop(event) {
($(active_asso_area[0]).attr('id') === "existing_member_choice" && $('#existing_member_choice_action .chosen_associate div.member').length > 0) ($(active_asso_area[0]).attr('id') === "existing_member_choice" && $('#existing_member_choice_action .chosen_associate div.member').length > 0)
) { ) {
associated_data_ok = true; associated_data_ok = true;
} else if ($(active_asso_area[0]).attr('id') === "") {
associated_data_ok = false;
errors.push("Un des deux choix doit être sélectionné");
} }
if (associated_data_ok === false) errors.push("Le membre 'titulaire' du binôme n'est pas défini"); if (associated_data_ok === false) errors.push("Le membre 'titulaire' du binôme n'est pas défini");
} }
console.log($(active_asso_area[0]).attr('id'))
$.ajax({url : '/members/exists/' + email, $.ajax({url : '/members/exists/' + email,
dataType :'json' dataType :'json'
}) })
...@@ -611,27 +633,28 @@ $('#coop_create').submit(store_new_coop); ...@@ -611,27 +633,28 @@ $('#coop_create').submit(store_new_coop);
$('#generate_email').click(generate_email); $('#generate_email').click(generate_email);
$('#odoo_user_connect').click(); $('#odoo_user_connect').click();
$('#add_binome').click(function() { $('#no_binome').click(function() {
if ($('#associate_area').is(':visible')) { $('#associate_area').hide();
$('#associate_area').hide(); $('#new_member_input').val('');
$('#new_member_input').val(''); $('#associate_area .choice_active').removeClass("choice_active");
$('#associate_area .choice_active').removeClass("choice_active"); associated_old_choice = null;
associated_old_choice = null; if (current_coop !=null) {
if (current_coop !=null) { delete current_coop.parent_name;
delete current_coop.parent_name; delete current_coop.parent_id;
delete current_coop.parent_id; delete current_coop.is_associated_people;
delete current_coop.is_associated_people; delete current_coop.shift_template;
delete current_coop.shift_template;
}
} else {
$('#associate_area').show();
$('.member_choice').removeClass('choice_active');
$('#existing_member_choice_action').hide();
$('#new_member_choice_action').hide();
associated_old_choice = null;
} }
}); });
$('#add_binome').click(function() {
$('#associate_area').show();
$('.member_choice').removeClass('choice_active');
$('#existing_member_choice_action').hide();
$('#new_member_choice_action').hide();
associated_old_choice = null;
});
$('.member_choice').on('click', function() { $('.member_choice').on('click', function() {
if (associated_old_choice !=null && associated_old_choice!=$(this).attr('id')) { if (associated_old_choice !=null && associated_old_choice!=$(this).attr('id')) {
......
...@@ -80,15 +80,25 @@ ...@@ -80,15 +80,25 @@
{% endif %} {% endif %}
{% if can_create_binome %} {% if can_create_binome %}
<p id="add_binome" >+ Binomes (facultatif)</p> <div>Voulez-vous mettre la personne en binôme ?</div>
<label>
<input type="radio" name="binome" id="no_binome" required>
Non
</label><br>
<label>
<input type="radio" name="binome" id="add_binome" required>
Oui
</label><br>
<div id="associate_area" style="display:none;"> <div id="associate_area" style="display:none;">
<div class="choice_button_area d-flex" > <div class="choice_button_area d-flex" >
<div id="existing_member_choice" class="member_choice"> <div id="existing_member_choice" class="member_choice">
A mettre en binome avec un.e membre existant.e A mettre en binôme avec un.e membre existant.e
</div> </div>
{% if ASSOCIATE_MEMBER_SHIFT %} {% if ASSOCIATE_MEMBER_SHIFT %}
<div id="new_member_choice" class="member_choice"> <div id="new_member_choice" class="member_choice">
A mettre en binome avec un.e nouveau membre A mettre en binôme avec un nouveau membre
</div> </div>
{% endif %} {% endif %}
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment