From 222d08987298a153ffe2b5e1cbb819e1ba4bef8d Mon Sep 17 00:00:00 2001 From: Kurt Riddlesperger Date: Fri, 24 Jan 2020 00:57:45 -0600 Subject: [PATCH] Attempt to clear pickers to only allow either product or recipe selection --- public/viewjs/mealplan.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/public/viewjs/mealplan.js b/public/viewjs/mealplan.js index fc73eadd..1e29dabb 100644 --- a/public/viewjs/mealplan.js +++ b/public/viewjs/mealplan.js @@ -215,6 +215,7 @@ $(document).on("click", ".add-recipe-button", function(e) $("#add-recipe-modal-title").text(__t("Add recipe to %s", day.toString())); $("#day").val(day.toString()); Grocy.Components.RecipePicker.Clear(); + Grocy.Components.ProductPicker.Clear(); $("#add-recipe-modal").modal("show"); Grocy.FrontendHelpers.ValidateForm("add-recipe-form"); }); @@ -538,6 +539,27 @@ $(window).on("resize", function() calendar.fullCalendar("changeView", "basicWeek"); } }); + +Grocy.Components.ProductPicker.GetPicker().on('change', function(e) +{ + var productId = $(e.target).val(); + + if (productId) + { + Grocy.Components.RecipePicker.SetValue(''); + } +}); + +Grocy.Components.RecipePicker.GetPicker().on('change', function(e) +{ + var recipeId = $(e.target).val(); + + if (recipeId) + { + Grocy.Components.ProductPicker.SetValue(''); + } +}); + function UndoStockTransaction(transactionId) { Grocy.Api.Post('stock/transactions/' + transactionId.toString() + '/undo', { },