Check if qte change + min qte = 0

This commit is contained in:
Barnabé 2021-09-17 17:50:40 +02:00
parent a96ab1e4b6
commit c42a3909ee

View File

@ -204,7 +204,7 @@
%td.mask %td.mask
=check_box_tag :"p_product_ref_ids[]", plr.p_product_ref.id =check_box_tag :"p_product_ref_ids[]", plr.p_product_ref.id
=number_field_tag "qte[#{plr.p_product_ref.id}]", '', class: "small-input", value: ([bpa_qte - qte_available, 0].max) =number_field_tag "qte[#{plr.p_product_ref.id}]", '', class: "small-input", value: ([bpa_qte - qte_available, 0].max), min: 0
%td.mask %td.mask
= bpa_qte = bpa_qte
@ -307,9 +307,11 @@
} }
:javascript :javascript
// TOOGLE ORDERS DETAILS - set to hidden
$('.detail').hide() $('.detail').hide()
$('.col-detail').hide() $('.col-detail').hide()
let state = 0 let state = 0
// TOGGLE ORDER LINE DETAILS
$('.plus').click(function(event){ $('.plus').click(function(event){
if( event.currentTarget.className == "plus") { if( event.currentTarget.className == "plus") {
$(event.currentTarget).removeClass('plus').addClass('minus') $(event.currentTarget).removeClass('plus').addClass('minus')
@ -328,6 +330,7 @@
$('.col-detail').show() $('.col-detail').show()
} }
}); });
// TOOGLE ALL ORDERS DETAILS
$('.plus-all').click(function(event){ $('.plus-all').click(function(event){
if( event.currentTarget.className == "mask plus-all") { if( event.currentTarget.className == "mask plus-all") {
state += $('.plus').length state += $('.plus').length
@ -351,6 +354,15 @@
$('.col-detail').show() $('.col-detail').show()
} }
}); });
// CHECK QTE IF QTE CHANGE
$('.small-input').change(function(){
let checkbox = $(this).closest('td').find("input[type=checkbox]")
if (this.value > 0) {
checkbox.prop("checked", true)
} else {
checkbox.prop("checked", false)
}
})