Commit 71e4b8bb by Damien Moulard

Merge branch '3867-ratio-button-binome-option' into 'dev_cooperatic'

3867-ratio-button-binome-option

See merge request !201
parents 39cc880f 862824e7
Pipeline #2418 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();
...@@ -268,6 +269,21 @@ function store_new_coop(event) { ...@@ -268,6 +269,21 @@ function store_new_coop(event) {
} }
} }
if ($('#associate_area').is(':visible')) {
// 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 concernant la mise en binôme 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,6 +295,9 @@ function store_new_coop(event) { ...@@ -279,6 +295,9 @@ 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");
} }
...@@ -611,8 +630,7 @@ $('#coop_create').submit(store_new_coop); ...@@ -611,8 +630,7 @@ $('#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");
...@@ -623,13 +641,15 @@ $('#add_binome').click(function() { ...@@ -623,13 +641,15 @@ $('#add_binome').click(function() {
delete current_coop.is_associated_people; delete current_coop.is_associated_people;
delete current_coop.shift_template; delete current_coop.shift_template;
} }
} else { });
$('#add_binome').click(function() {
$('#associate_area').show(); $('#associate_area').show();
$('.member_choice').removeClass('choice_active'); $('.member_choice').removeClass('choice_active');
$('#existing_member_choice_action').hide(); $('#existing_member_choice_action').hide();
$('#new_member_choice_action').hide(); $('#new_member_choice_action').hide();
associated_old_choice = null; associated_old_choice = null;
}
}); });
$('.member_choice').on('click', function() { $('.member_choice').on('click', function() {
......
...@@ -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