diff --git a/app/views/admin/buy_lists/index.html.haml b/app/views/admin/buy_lists/index.html.haml index 1808240..862b4f4 100644 --- a/app/views/admin/buy_lists/index.html.haml +++ b/app/views/admin/buy_lists/index.html.haml @@ -204,7 +204,7 @@ %td.mask =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 = bpa_qte @@ -307,9 +307,11 @@ } :javascript + // TOOGLE ORDERS DETAILS - set to hidden $('.detail').hide() $('.col-detail').hide() let state = 0 + // TOGGLE ORDER LINE DETAILS $('.plus').click(function(event){ if( event.currentTarget.className == "plus") { $(event.currentTarget).removeClass('plus').addClass('minus') @@ -328,6 +330,7 @@ $('.col-detail').show() } }); + // TOOGLE ALL ORDERS DETAILS $('.plus-all').click(function(event){ if( event.currentTarget.className == "mask plus-all") { state += $('.plus').length @@ -351,6 +354,15 @@ $('.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) + } + })