From 2451e7dda88e870a428d88cb38a827c749de3464 Mon Sep 17 00:00:00 2001 From: Rosemary Orchard <16113535+RosemaryOrchard@users.noreply.github.com> Date: Mon, 18 Apr 2022 09:11:34 +0100 Subject: [PATCH] Remove console, update move on open when either the default or the consume location change --- public/viewjs/productform.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/public/viewjs/productform.js b/public/viewjs/productform.js index cb063524..9582b93d 100644 --- a/public/viewjs/productform.js +++ b/public/viewjs/productform.js @@ -239,18 +239,24 @@ $('#product-form input').keyup(function(event) $('#location_id').change(function(event) { Grocy.FrontendHelpers.ValidateForm('product-form'); + updateMoveOnOpen(); }); $('#default_consume_location_id').change(function(event) { + updateMoveOnOpen(); +}); + +function updateMoveOnOpen() { var defaultLocation = $("#location_id :selected").val(); var consumeLocationLocation = document.getElementById('default_consume_location_id'); - console.log('defaultLocation', defaultLocation); - console.log('consumeLocationLocation', consumeLocationLocation); + var moveOnOpen = document.getElementById('move_on_open'); if (consumeLocationLocation && defaultLocation !== consumeLocationLocation) { + moveOnOpen.removeAttribute('checked'); moveOnOpen.setAttribute('disabled', ""); } else { moveOnOpen.removeAttribute('disabled'); } +} }); $('#product-form input').keydown(function(event)