From 34ffdb2b4b3e6f06c68463919691e097d370db65 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Tue, 8 Sep 2020 17:46:37 +0200 Subject: [PATCH] Adds a few small frontend fixes (#995) * Add a few instructions to the readme on how to get `grocy` running locally * Fix toggle for header-clock I'm not 100% sure why, but with this change, the listener which calls `CheckHeaderClockEnabled` will be invoked *before* the listener which persists the setting. If the setting is persisted before that, the clock doesn't show up when enabling it in the settings-menu and appears/disappears in the exact opposite way the setting is true/false. * Allow replacing a product picture when removing it at first Right now, a preview image of a product doesn't get updated when pressing the delete-button at first and adding a new image the upload-form which can be quite confusing for an end-user. This patch allows to delete an image and add a new one in one go. * Add `Save & return` button to product form Same concept as for recipes: when pressing this button, the user will stay at the form's site after saving. * Removed unneeded class * Revert "Add a few instructions to the readme on how to get `grocy` running locally" This reverts commit 6ffad1d3c729de9ce4bdd19aa87d7577dd2fcd36. Co-authored-by: Bernd Bestel --- public/js/grocy_clock.js | 2 +- public/viewjs/productform.js | 11 +++++++++++ views/productform.blade.php | 4 +++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/public/js/grocy_clock.js b/public/js/grocy_clock.js index efa13886..2299c5b0 100644 --- a/public/js/grocy_clock.js +++ b/public/js/grocy_clock.js @@ -1,4 +1,4 @@ -$("#show-clock-in-header").on("change", function() +$(document).on("change", "#show-clock-in-header", function() { CheckHeaderClockEnabled(); }); diff --git a/public/viewjs/productform.js b/public/viewjs/productform.js index 157ad8d3..a4e1a4d4 100644 --- a/public/viewjs/productform.js +++ b/public/viewjs/productform.js @@ -342,6 +342,12 @@ $("#allow_partial_units_in_stock").on("click", function() Grocy.FrontendHelpers.ValidateForm("product-form"); }); +$('#product-picture').change(function () { + if ($(this).val()) { + Grocy.DeleteProductPictureOnSave = false; + } +}); + Grocy.DeleteProductPictureOnSave = false; $('#delete-current-product-picture-button').on('click', function(e) { @@ -405,6 +411,11 @@ Grocy.FrontendHelpers.ValidateForm('product-form'); $("#allow_partial_units_in_stock").click(); $("#allow_partial_units_in_stock").click(); +$(document).on('click', '#save-product-button-continue', function () { + Grocy.ProductEditFormRedirectUri = "reload"; + $('#save-product-button').click(); +}); + $(document).on('click', '.qu-conversion-delete-button', function(e) { var objectId = $(e.currentTarget).attr('data-qu-conversion-id'); diff --git a/views/productform.blade.php b/views/productform.blade.php index 00a2ffcb..807e5d40 100644 --- a/views/productform.blade.php +++ b/views/productform.blade.php @@ -371,8 +371,10 @@ 'entity' => 'products' )) + + class="btn btn-info mb-2">{{ $__t('Save') }}