diff --git a/localization/strings.pot b/localization/strings.pot index 28568f86..bc7f7dd4 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -634,7 +634,7 @@ msgstr "" msgid "Quantity unit" msgstr "" -msgid "Only check if a single unit is in stock (a different quantity can then be used above)" +msgid "Only check if a single unit is in stock (a different quantity can then be used below)" msgstr "" msgid "Are you sure to consume all ingredients needed by recipe \"%s\" (ingredients marked with \"check only if a single unit is in stock\" will be ignored)?" @@ -1784,9 +1784,6 @@ msgstr "" msgid "Calories" msgstr "" -msgid "By default the amount to be added to the shopping list is `needed amount - stock amount - shopping list amount` - when this is enabled, it is only checked against the stock amount, not against what is already on the shopping list" -msgstr "" - msgid "means %1$s per %2$s" msgstr "" @@ -1933,3 +1930,15 @@ msgstr "" msgid "Edit shopping list" msgstr "" + +msgid "Save & continue to add quantity unit conversions & barcodes" +msgstr "" + +msgid "Save & return to products" +msgstr "" + +msgid "Save & continue to add conversions" +msgstr "" + +msgid "Save & return to quantity units" +msgstr "" diff --git a/public/viewjs/batteryform.js b/public/viewjs/batteryform.js index 3597f028..6f85cbd3 100644 --- a/public/viewjs/batteryform.js +++ b/public/viewjs/batteryform.js @@ -13,7 +13,14 @@ Grocy.EditObjectId = result.created_object_id; Grocy.Components.UserfieldsForm.Save(function() { - window.location.href = U('/batteries'); + if (GetUriParam("embedded") !== undefined) + { + window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl); + } + else + { + window.location.href = U('/batteries'); + } }); }, function(xhr) @@ -30,7 +37,14 @@ { Grocy.Components.UserfieldsForm.Save(function() { - window.location.href = U('/batteries'); + if (GetUriParam("embedded") !== undefined) + { + window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl); + } + else + { + window.location.href = U('/batteries'); + } }); }, function(xhr) diff --git a/public/viewjs/choreform.js b/public/viewjs/choreform.js index 4e839d14..9250c6c7 100644 --- a/public/viewjs/choreform.js +++ b/public/viewjs/choreform.js @@ -122,12 +122,12 @@ $('.input-group-chore-period-type').on('change', function(e) $(".period-type-input").addClass("d-none"); $(".period-type-" + periodType).removeClass("d-none"); - $('#chore-period-type-info').text(""); + $('#chore-period-type-info').attr("title", ""); $("#period_config").val(""); if (periodType === 'manually') { - $('#chore-period-type-info').text(__t('This means the next execution of this chore is not scheduled')); + $('#chore-period-type-info').attr("title", __t('This means the next execution of this chore is not scheduled')); } else if (periodType === 'dynamic-regular') { @@ -135,32 +135,32 @@ $('.input-group-chore-period-type').on('change', function(e) $("#period_days").attr("min", "0"); $("#period_days").attr("max", "9999"); $("#period_days").parent().find(".invalid-feedback").text(__t('This cannot be negative')); - $('#chore-period-type-info').text(__t('This means the next execution of this chore is scheduled %s days after the last execution', periodDays.toString())); + $('#chore-period-type-info').attr("title", __t('This means the next execution of this chore is scheduled %s days after the last execution', periodDays.toString())); } else if (periodType === 'daily') { - $('#chore-period-type-info').text(__t('This means the next execution of this chore is scheduled 1 day after the last execution')); - $('#chore-period-interval-info').text(__t('This means the next execution of this chore should only be scheduled every %s days', periodInterval.toString())); + $('#chore-period-type-info').attr("title", __t('This means the next execution of this chore is scheduled 1 day after the last execution')); + $('#chore-period-interval-info').attr("title", __t('This means the next execution of this chore should only be scheduled every %s days', periodInterval.toString())); } else if (periodType === 'weekly') { - $('#chore-period-type-info').text(__t('This means the next execution of this chore is scheduled 1 day after the last execution, but only for the weekdays selected below')); + $('#chore-period-type-info').attr("title", __t('This means the next execution of this chore is scheduled 1 day after the last execution, but only for the weekdays selected below')); $("#period_config").val($(".period-type-weekly input:checkbox:checked").map(function() { return this.value; }).get().join(",")); - $('#chore-period-interval-info').text(__t('This means the next execution of this chore should only be scheduled every %s weeks', periodInterval.toString())); + $('#chore-period-interval-info').attr("title", __t('This means the next execution of this chore should only be scheduled every %s weeks', periodInterval.toString())); } else if (periodType === 'monthly') { - $('#chore-period-type-info').text(__t('This means the next execution of this chore is scheduled on the below selected day of each month')); + $('#chore-period-type-info').attr("title", __t('This means the next execution of this chore is scheduled on the below selected day of each month')); $("label[for='period_days']").text(__t("Day of month")); $("#period_days").attr("min", "1"); $("#period_days").attr("max", "31"); $("#period_days").parent().find(".invalid-feedback").text(__t('The amount must be between %1$s and %2$s', "1", "31")); - $('#chore-period-interval-info').text(__t('This means the next execution of this chore should only be scheduled every %s months', periodInterval.toString())); + $('#chore-period-interval-info').attr("title", __t('This means the next execution of this chore should only be scheduled every %s months', periodInterval.toString())); } else if (periodType === 'yearly') { - $('#chore-period-type-info').text(__t('This means the next execution of this chore is scheduled 1 year after the last execution')); - $('#chore-period-interval-info').text(__t('This means the next execution of this chore should only be scheduled every %s years', periodInterval.toString())); + $('#chore-period-type-info').attr("title", __t('This means the next execution of this chore is scheduled 1 year after the last execution')); + $('#chore-period-interval-info').attr("title", __t('This means the next execution of this chore should only be scheduled every %s years', periodInterval.toString())); } Grocy.FrontendHelpers.ValidateForm('chore-form'); @@ -176,23 +176,23 @@ $('.input-group-chore-assignment-type').on('change', function(e) if (assignmentType === 'no-assignment') { - $('#chore-assignment-type-info').text(__t('This means the next execution of this chore will not be assigned to anyone')); + $('#chore-assignment-type-info').attr("title", __t('This means the next execution of this chore will not be assigned to anyone')); } else if (assignmentType === 'who-least-did-first') { - $('#chore-assignment-type-info').text(__t('This means the next execution of this chore will be assigned to the one who executed it least')); + $('#chore-assignment-type-info').attr("title", __t('This means the next execution of this chore will be assigned to the one who executed it least')); $("#assignment_config").attr("required", ""); $("#assignment_config").removeAttr("disabled"); } else if (assignmentType === 'random') { - $('#chore-assignment-type-info').text(__t('This means the next execution of this chore will be assigned randomly')); + $('#chore-assignment-type-info').attr("title", __t('This means the next execution of this chore will be assigned randomly')); $("#assignment_config").attr("required", ""); $("#assignment_config").removeAttr("disabled"); } else if (assignmentType === 'in-alphabetical-order') { - $('#chore-assignment-type-info').text(__t('This means the next execution of this chore will be assigned to the next one in alphabetical order')); + $('#chore-assignment-type-info').attr("title", __t('This means the next execution of this chore will be assigned to the next one in alphabetical order')); $("#assignment_config").attr("required", ""); $("#assignment_config").removeAttr("disabled"); } diff --git a/public/viewjs/locationform.js b/public/viewjs/locationform.js index 88547f80..fe8c789b 100644 --- a/public/viewjs/locationform.js +++ b/public/viewjs/locationform.js @@ -13,7 +13,14 @@ Grocy.EditObjectId = result.created_object_id; Grocy.Components.UserfieldsForm.Save(function() { - window.location.href = U('/locations'); + if (GetUriParam("embedded") !== undefined) + { + window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl); + } + else + { + window.location.href = U('/locations'); + } }); }, function(xhr) @@ -30,7 +37,14 @@ { Grocy.Components.UserfieldsForm.Save(function() { - window.location.href = U('/locations'); + if (GetUriParam("embedded") !== undefined) + { + window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl); + } + else + { + window.location.href = U('/locations'); + } }); }, function(xhr) diff --git a/public/viewjs/productform.js b/public/viewjs/productform.js index 0e9495e6..3075f25a 100644 --- a/public/viewjs/productform.js +++ b/public/viewjs/productform.js @@ -1,19 +1,58 @@ -$('#save-product-button').on('click', function(e) +function saveProductPicture(result, location, jsonData) +{ + var productId = Grocy.EditObjectId || result.created_object_id; + Grocy.Components.UserfieldsForm.Save(() => + { + if (jsonData.hasOwnProperty("picture_file_name") && !Grocy.DeleteProductPictureOnSave) + { + Grocy.Api.UploadFile($("#product-picture")[0].files[0], 'productpictures', jsonData.picture_file_name, + (result) => + { + var returnTo = GetUriParam('returnto'); + if (GetUriParam("closeAfterCreation") !== undefined) + { + window.close(); + } + else if (returnTo !== undefined) + { + window.location.href = U(returnTo) + '?createdproduct=' + encodeURIComponent($('#name').val()); + } + else + { + window.location.href = U(location + productId); + } + + }, + (xhr) => + { + Grocy.FrontendHelpers.EndUiBusy("product-form"); + Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) + } + ); + } + else + { + var returnTo = GetUriParam('returnto'); + if (GetUriParam("closeAfterCreation") !== undefined) + { + window.close(); + } + else if (returnTo !== undefined) + { + window.location.href = U(returnTo) + '?createdproduct=' + encodeURIComponent($('#name').val()); + } + else + { + window.location.href = U(location + productId); + } + } + }); +} + +$('.save-product-button').on('click', function(e) { e.preventDefault(); - var redirectDestination = U('/products'); - var returnTo = GetUriParam('returnto'); - if (returnTo !== undefined) - { - redirectDestination = U(returnTo) + '?createdproduct=' + encodeURIComponent($('#name').val()); - } - - if (Grocy.ProductEditFormRedirectUri !== undefined) - { - redirectDestination = Grocy.ProductEditFormRedirectUri; - } - var jsonData = $('#product-form').serializeJSON({ checkboxUncheckedValue: "0" }); var parentProductId = jsonData.product_id; delete jsonData.product_id; @@ -31,80 +70,23 @@ jsonData.picture_file_name = someRandomStuff + $("#product-picture")[0].files[0].name; } + const location = $(e.currentTarget).attr('data-location') == 'return' ? '/products?product=' : '/product/'; + + if (Grocy.EditMode == 'create') + { + Grocy.Api.Post('objects/products', jsonData, + (result) => saveProductPicture(result, location, jsonData)); + return; + } + if (Grocy.DeleteProductPictureOnSave) { jsonData.picture_file_name = null; - } - if (Grocy.EditMode === 'create') - { - Grocy.Api.Post('objects/products', jsonData, + Grocy.Api.DeleteFile(Grocy.ProductPictureFileName, 'productpictures', {}, function(result) { - Grocy.EditObjectId = result.created_object_id; - - if (prefillBarcode !== undefined) - { - var jsonDataBarcode = {}; - jsonDataBarcode.barcode = prefillBarcode; - jsonDataBarcode.product_id = result.created_object_id; - jsonDataBarcode.qu_factor_purchase_to_stock = jsonData.qu_factor_purchase_to_stock; - jsonDataBarcode.shopping_location_id = jsonData.shopping_location_id; - - Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode, - function(result) - { - }, - function(xhr) - { - Grocy.FrontendHelpers.EndUiBusy("barcode-form"); - Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response); - } - ); - } - Grocy.Components.UserfieldsForm.Save(function() - { - if (jsonData.hasOwnProperty("picture_file_name") && !Grocy.DeleteProductPictureOnSave) - { - Grocy.Api.UploadFile($("#product-picture")[0].files[0], 'productpictures', jsonData.picture_file_name, - function(result) - { - if (GetUriParam("closeAfterCreation") !== undefined) - { - window.close(); - } - else if (redirectDestination == "reload") - { - window.location.reload(); - } - else - { - window.location.href = redirectDestination.replace("editobjectid", Grocy.EditObjectId);; - } - }, - function(xhr) - { - Grocy.FrontendHelpers.EndUiBusy("product-form"); - Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) - } - ); - } - else - { - if (GetUriParam("closeAfterCreation") !== undefined) - { - window.close(); - } - else if (redirectDestination == "reload") - { - window.location.reload(); - } - else - { - window.location.href = redirectDestination.replace("editobjectid", Grocy.EditObjectId);; - } - } - }); + // Nothing to do }, function(xhr) { @@ -113,77 +95,15 @@ } ); } - else - { - if (Grocy.DeleteProductPictureOnSave) + + Grocy.Api.Put('objects/products/' + Grocy.EditObjectId, jsonData, + (result) => saveProductPicture(result, location, jsonData), + function(xhr) { - Grocy.Api.DeleteFile(Grocy.ProductPictureFileName, 'productpictures', {}, - function(result) - { - // Nothing to do - }, - function(xhr) - { - Grocy.FrontendHelpers.EndUiBusy("product-form"); - Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) - } - ); - }; - - Grocy.Api.Put('objects/products/' + Grocy.EditObjectId, jsonData, - function(result) - { - Grocy.Components.UserfieldsForm.Save(function() - { - if (jsonData.hasOwnProperty("picture_file_name") && !Grocy.DeleteProductPictureOnSave) - { - Grocy.Api.UploadFile($("#product-picture")[0].files[0], 'productpictures', jsonData.picture_file_name, - function(result) - { - if (GetUriParam("closeAfterCreation") !== undefined) - { - window.close(); - } - else if (redirectDestination == "reload") - { - window.location.reload(); - } - else - { - window.location.href = redirectDestination.replace("editobjectid", Grocy.EditObjectId);; - } - }, - function(xhr) - { - Grocy.FrontendHelpers.EndUiBusy("product-form"); - Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) - } - ); - } - else - { - if (GetUriParam("closeAfterCreation") !== undefined) - { - window.close(); - } - else if (redirectDestination == "reload") - { - window.location.reload(); - } - else - { - window.location.href = redirectDestination.replace("editobjectid", Grocy.EditObjectId);; - } - } - }); - }, - function(xhr) - { - Grocy.FrontendHelpers.EndUiBusy("product-form"); - Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) - } - ); - } + Grocy.FrontendHelpers.EndUiBusy("product-form"); + console.error(xhr); + } + ); }); Grocy.Api.Get('stock/products/' + Grocy.EditObjectId, @@ -342,21 +262,23 @@ $("#allow_partial_units_in_stock").on("click", function() Grocy.FrontendHelpers.ValidateForm("product-form"); }); -$('#product-picture').change(function() +$("#product-picture").on("change", function(e) { - if ($(this).val()) - { - Grocy.DeleteProductPictureOnSave = false; - } + $("#product-picture-label").removeClass("d-none"); + $("#product-picture-label-none").addClass("d-none"); + $("#delete-current-product-picture-on-save-hint").addClass("d-none"); + $("#current-product-picture").addClass("d-none"); + Grocy.DeleteProductPictureOnSave = false; }); Grocy.DeleteProductPictureOnSave = false; -$('#delete-current-product-picture-button').on('click', function(e) +$("#delete-current-product-picture-button").on("click", function(e) { Grocy.DeleteProductPictureOnSave = true; $("#current-product-picture").addClass("d-none"); $("#delete-current-product-picture-on-save-hint").removeClass("d-none"); - $("#delete-current-product-picture-button").addClass("disabled"); + $("#product-picture-label").addClass("d-none"); + $("#product-picture-label-none").removeClass("d-none"); }); if (Grocy.EditMode === 'create') diff --git a/public/viewjs/quantityunitconversionform.js b/public/viewjs/quantityunitconversionform.js index 3629db4e..5acd3cca 100644 --- a/public/viewjs/quantityunitconversionform.js +++ b/public/viewjs/quantityunitconversionform.js @@ -19,14 +19,62 @@ Grocy.EditObjectId = result.created_object_id; Grocy.Components.UserfieldsForm.Save(function() { - if (typeof GetUriParam("qu-unit") !== "undefined") + if ($("#create_inverse").is(":checked")) { - window.location.href = U("/quantityunit/" + GetUriParam("qu-unit")); + jsonData.to_qu_id = inverse_to_qu_id; + jsonData.from_qu_id = inverse_from_qu_id; + jsonData.factor = 1 / jsonData.factor; + + //Create Inverse + Grocy.Api.Post('objects/quantity_unit_conversions', jsonData, + function(result) + { + Grocy.EditObjectId = result.created_object_id; + Grocy.Components.UserfieldsForm.Save(function() + { + if (typeof GetUriParam("qu-unit") !== "undefined") + { + if (GetUriParam("embedded") !== undefined) + { + window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl); + } + else + { + window.location.href = U("/quantityunit/" + GetUriParam("qu-unit")); + } + } + else + { + window.parent.postMessage(WindowMessageBag("ProductQUConversionChanged"), U("/product/" + GetUriParam("product"))); + window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + GetUriParam("product"))); + } + }); + }, + function(xhr) + { + Grocy.FrontendHelpers.EndUiBusy("quconversion-form"); + Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) + } + ); } else { - window.parent.postMessage(WindowMessageBag("ProductQUConversionChanged"), U("/product/" + GetUriParam("product"))); - window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + GetUriParam("product"))); + if (typeof GetUriParam("qu-unit") !== "undefined") + { + if (GetUriParam("embedded") !== undefined) + { + window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl); + } + else + { + window.location.href = U("/quantityunit/" + GetUriParam("qu-unit")); + } + } + else + { + window.parent.postMessage(WindowMessageBag("ProductQUConversionChanged"), U("/product/" + GetUriParam("product"))); + window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + GetUriParam("product"))); + } } }); }, @@ -36,37 +84,6 @@ Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) } ); - if ($("#create_inverse").is(":checked")) - { - jsonData.to_qu_id = inverse_to_qu_id; - jsonData.from_qu_id = inverse_from_qu_id; - jsonData.factor = 1 / jsonData.factor; - - //Create Inverse - Grocy.Api.Post('objects/quantity_unit_conversions', jsonData, - function(result) - { - Grocy.EditObjectId = result.created_object_id; - Grocy.Components.UserfieldsForm.Save(function() - { - if (typeof GetUriParam("qu-unit") !== "undefined") - { - window.location.href = U("/quantityunit/" + GetUriParam("qu-unit")); - } - else - { - window.parent.postMessage(WindowMessageBag("ProductQUConversionChanged"), U("/product/" + GetUriParam("product"))); - window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + GetUriParam("product"))); - } - }); - }, - function(xhr) - { - Grocy.FrontendHelpers.EndUiBusy("quconversion-form"); - Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response) - } - ); - } } else { @@ -77,7 +94,14 @@ { if (typeof GetUriParam("qu-unit") !== "undefined") { - window.location.href = U("/quantityunit/" + GetUriParam("qu-unit")); + if (GetUriParam("embedded") !== undefined) + { + window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl); + } + else + { + window.location.href = U("/quantityunit/" + GetUriParam("qu-unit")); + } } else { @@ -124,7 +148,7 @@ $("#create_inverse").on("change", function() if (value) { - $('#qu-conversion-inverse-info').removeClass('d-none'); + $('#qu-conversion-inverse-info').removeClass('d-none'); } else { diff --git a/public/viewjs/quantityunitform.js b/public/viewjs/quantityunitform.js index ce52c788..ac64205f 100644 --- a/public/viewjs/quantityunitform.js +++ b/public/viewjs/quantityunitform.js @@ -1,4 +1,4 @@ -$('#save-quantityunit-button').on('click', function(e) +$('.save-quantityunit-button').on('click', function(e) { e.preventDefault(); @@ -14,6 +14,11 @@ redirectDestination = U('/quantityunits'); } + if ($(e.currentTarget).attr('data-location') == "continue") + { + redirectDestination = "reload"; + } + if (Grocy.EditMode === 'create') { Grocy.Api.Post('objects/quantity_units', jsonData, @@ -22,17 +27,25 @@ Grocy.EditObjectId = result.created_object_id; Grocy.Components.UserfieldsForm.Save(function() { - if (redirectDestination == "reload") + if (GetUriParam("embedded") !== undefined) { - window.location.reload(); - } - else if (redirectDestination == "stay") - { - // Do nothing + window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl); } else { - window.location.href = redirectDestination.replace("editobjectid", Grocy.EditObjectId); + + if (redirectDestination == "reload") + { + window.location.href = U("/quantityunit/" + result.created_object_id.toString()); + } + else if (redirectDestination == "stay") + { + // Do nothing + } + else + { + window.location.href = redirectDestination.replace("editobjectid", Grocy.EditObjectId); + } } }); }, @@ -50,17 +63,25 @@ { Grocy.Components.UserfieldsForm.Save(function() { - if (redirectDestination == "reload") + if (GetUriParam("embedded") !== undefined) { - window.location.reload(); - } - else if (redirectDestination == "stay") - { - // Do nothing + window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl); } else { - window.location.href = redirectDestination.replace("editobjectid", Grocy.EditObjectId); + + if (redirectDestination == "reload") + { + window.location.reload(); + } + else if (redirectDestination == "stay") + { + // Do nothing + } + else + { + window.location.href = redirectDestination.replace("editobjectid", Grocy.EditObjectId); + } } }); }, @@ -154,8 +175,7 @@ $(document).on('click', '.qu-conversion-delete-button', function(e) Grocy.Api.Delete('objects/quantity_unit_conversions/' + objectId, {}, function(result) { - Grocy.QuantityUnitEditFormRedirectUri = "reload"; - $('#save-quantityunit-button').click(); + window.location.reload(); }, function(xhr) { @@ -167,19 +187,6 @@ $(document).on('click', '.qu-conversion-delete-button', function(e) }); }); -$(document).on('click', '.qu-conversion-edit-button', function(e) -{ - var id = $(e.currentTarget).attr('data-qu-conversion-id'); - Grocy.QuantityUnitEditFormRedirectUri = U("/quantityunitconversion/" + id.toString() + "?qu-unit=editobjectid"); - $('#save-quantityunit-button').click(); -}); - -$("#qu-conversion-add-button").on("click", function(e) -{ - Grocy.QuantityUnitEditFormRedirectUri = U("/quantityunitconversion/new?qu-unit=editobjectid"); - $('#save-quantityunit-button').click(); -}); - $("#test-quantityunit-plural-forms-button").on("click", function(e) { e.preventDefault(); diff --git a/public/viewjs/recipeform.js b/public/viewjs/recipeform.js index 16eedc45..65aeee3c 100644 --- a/public/viewjs/recipeform.js +++ b/public/viewjs/recipeform.js @@ -1,6 +1,6 @@ function saveRecipePicture(result, location, jsonData) { - $recipeId = Grocy.EditObjectId || result.created_object_id; + var recipeId = Grocy.EditObjectId || result.created_object_id; Grocy.Components.UserfieldsForm.Save(() => { if (jsonData.hasOwnProperty("picture_file_name") && !Grocy.DeleteRecipePictureOnSave) @@ -8,7 +8,7 @@ Grocy.Api.UploadFile($("#recipe-picture")[0].files[0], 'recipepictures', jsonData.picture_file_name, (result) => { - window.location.href = U(location + $recipeId); + window.location.href = U(location + recipeId); }, (xhr) => { @@ -19,7 +19,7 @@ } else { - window.location.href = U(location + $recipeId); + window.location.href = U(location + recipeId); } }); } diff --git a/public/viewjs/recipes.js b/public/viewjs/recipes.js index 6167773d..14568977 100644 --- a/public/viewjs/recipes.js +++ b/public/viewjs/recipes.js @@ -63,7 +63,6 @@ $("#search").on("keyup", Delay(function() recipesTables.search(value).draw(); $(".recipe-gallery-item").removeClass("d-none"); - console.log($(".recipe-gallery-item .card-title:not(:contains_case_insensitive(" + value + "))")); $(".recipe-gallery-item .card-title:not(:contains_case_insensitive(" + value + "))").parent().parent().parent().addClass("d-none"); }, 200)); diff --git a/public/viewjs/shoppinglocationform.js b/public/viewjs/shoppinglocationform.js index 42cbda51..0213decc 100644 --- a/public/viewjs/shoppinglocationform.js +++ b/public/viewjs/shoppinglocationform.js @@ -13,7 +13,14 @@ Grocy.EditObjectId = result.created_object_id; Grocy.Components.UserfieldsForm.Save(function() { - window.location.href = U('/shoppinglocations'); + if (GetUriParam("embedded") !== undefined) + { + window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl); + } + else + { + window.location.href = U('/shoppinglocations'); + } }); }, function(xhr) @@ -30,7 +37,14 @@ { Grocy.Components.UserfieldsForm.Save(function() { - window.location.href = U('/shoppinglocations'); + if (GetUriParam("embedded") !== undefined) + { + window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl); + } + else + { + window.location.href = U('/shoppinglocations'); + } }); }, function(xhr) diff --git a/public/viewjs/taskcategoryform.js b/public/viewjs/taskcategoryform.js index 3a2bbb0d..e1c85689 100644 --- a/public/viewjs/taskcategoryform.js +++ b/public/viewjs/taskcategoryform.js @@ -13,7 +13,14 @@ Grocy.EditObjectId = result.created_object_id; Grocy.Components.UserfieldsForm.Save(function() { - window.location.href = U('/taskcategories'); + if (GetUriParam("embedded") !== undefined) + { + window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl); + } + else + { + window.location.href = U('/taskcategories'); + } }); }, function(xhr) @@ -30,7 +37,14 @@ { Grocy.Components.UserfieldsForm.Save(function() { - window.location.href = U('/taskcategories'); + if (GetUriParam("embedded") !== undefined) + { + window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl); + } + else + { + window.location.href = U('/taskcategories'); + } }); }, function(xhr) diff --git a/public/viewjs/userentityform.js b/public/viewjs/userentityform.js index 8f6af6ed..d8c7bc0c 100644 --- a/public/viewjs/userentityform.js +++ b/public/viewjs/userentityform.js @@ -12,7 +12,14 @@ Grocy.Api.Post('objects/userentities', jsonData, function(result) { - window.location.href = redirectUrl; + if (GetUriParam("embedded") !== undefined) + { + window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl); + } + else + { + window.location.href = redirectUrl; + } }, function(xhr) { @@ -26,7 +33,14 @@ Grocy.Api.Put('objects/userentities/' + Grocy.EditObjectId, jsonData, function(result) { - window.location.href = redirectUrl; + if (GetUriParam("embedded") !== undefined) + { + window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl); + } + else + { + window.location.href = redirectUrl; + } }, function(xhr) { diff --git a/public/viewjs/userfieldform.js b/public/viewjs/userfieldform.js index 45022968..f22b2241 100644 --- a/public/viewjs/userfieldform.js +++ b/public/viewjs/userfieldform.js @@ -16,7 +16,14 @@ Grocy.Api.Post('objects/userfields', jsonData, function(result) { - window.location.href = redirectUrl; + if (GetUriParam("embedded") !== undefined) + { + window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl); + } + else + { + window.location.href = redirectUrl; + } }, function(xhr) { @@ -30,7 +37,14 @@ Grocy.Api.Put('objects/userfields/' + Grocy.EditObjectId, jsonData, function(result) { - window.location.href = redirectUrl; + if (GetUriParam("embedded") !== undefined) + { + window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl); + } + else + { + window.location.href = redirectUrl; + } }, function(xhr) { diff --git a/views/batteries.blade.php b/views/batteries.blade.php index 7aefc2e4..bdbad775 100644 --- a/views/batteries.blade.php +++ b/views/batteries.blade.php @@ -25,8 +25,8 @@ @@ -156,8 +158,10 @@ @if(GROCY_FEATURE_FLAG_CHORES_ASSIGNMENTS)
- + track_date_only == 1) checked @endif class="form-check-input" type="checkbox" id="track_date_only" name="track_date_only" value="1"> -
-
+
rollover == 1) checked @endif class="form-check-input" type="checkbox" id="rollover" name="rollover" value="1"> -
@if(GROCY_FEATURE_FLAG_STOCK)
-
+
consume_product_on_execution == 1) checked @endif class="form-check-input" type="checkbox" id="consume_product_on_execution" name="consume_product_on_execution" value="1"> -
diff --git a/views/components/userfieldsform.blade.php b/views/components/userfieldsform.blade.php index 7334da73..8385bb21 100644 --- a/views/components/userfieldsform.blade.php +++ b/views/components/userfieldsform.blade.php @@ -76,12 +76,12 @@ )) @elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_CHECKBOX)
-
- + -
diff --git a/views/locationform.blade.php b/views/locationform.blade.php index 4ae8dcb3..b74fc71a 100644 --- a/views/locationform.blade.php +++ b/views/locationform.blade.php @@ -53,16 +53,18 @@ @if(GROCY_FEATURE_FLAG_STOCK_PRODUCT_FREEZING)
-
+
is_freezer == 1) checked @endif class="form-check-input" type="checkbox" id="is_freezer" name="is_freezer" value="1"> -
diff --git a/views/locations.blade.php b/views/locations.blade.php index 094ed792..0bf016b9 100644 --- a/views/locations.blade.php +++ b/views/locations.blade.php @@ -25,8 +25,8 @@
@@ -20,8 +25,6 @@
-

{{ $__t('Barcode for product') }} {{ $product->name }}

- diff --git a/views/productform.blade.php b/views/productform.blade.php index 7f3561e3..15d7ae4e 100644 --- a/views/productform.blade.php +++ b/views/productform.blade.php @@ -63,7 +63,7 @@
-
+
@@ -72,8 +72,8 @@ checked @elseif($mode=='edit' && - $product->active == 1) checked @endif class="form-check-input" type="checkbox" id="active" name="active" value="1"> -
@@ -152,16 +152,18 @@ ))
-
+
cumulate_min_stock_amount_of_sub_products == 1) checked @endif class="form-check-input" type="checkbox" id="cumulate_min_stock_amount_of_sub_products" name="cumulate_min_stock_amount_of_sub_products" value="1"> -
@@ -257,29 +259,31 @@ ))
-
+
allow_partial_units_in_stock == 1) checked @endif class="form-check-input" type="checkbox" id="allow_partial_units_in_stock" name="allow_partial_units_in_stock" value="1"> -
-
+
enable_tare_weight_handling == 1) checked @endif class="form-check-input" type="checkbox" id="enable_tare_weight_handling" name="enable_tare_weight_handling" value="1"> -
@@ -300,16 +304,18 @@ @if(GROCY_FEATURE_FLAG_RECIPES)
-
+
not_check_stock_fulfillment_for_recipes == 1) checked @endif class="form-check-input" type="checkbox" id="not_check_stock_fulfillment_for_recipes" name="not_check_stock_fulfillment_for_recipes" value="1"> -
@@ -356,167 +362,217 @@ value="0"> @endif -
- -
- - -
-
- @include('components.userfieldsform', array( 'userfields' => $userfields, 'entity' => 'products' )) - + {{ $__t('Save & continue to add quantity unit conversions & barcodes') }} + + +
-
-

- {{ $__t('QU conversions') }} - - {{ $__t('Add') }} - -

-
- - - - - - - - - - - - @if($mode == "edit") - @foreach($quConversions as $quConversion) - @if($quConversion->product_id == $product->id || $quConversion->product_id == null) - - - - - - - - @endif - @endforeach - @endif - -
{{ $__t('Factor') }}{{ $__t('Unit') }}Hidden groupHidden from_qu_id
- - + - {{ $quConversion->factor }} - - {{ FindObjectInArrayByPropertyValue($quantityunits, 'id', $quConversion->to_qu_id)->name }} - - @if($quConversion->product_id != null) - {{ $__t('Product overrides') }} - @else - {{ $__t('Default conversions') }} - @endif - - from_qu_id xx{{ $quConversion->from_qu_id }}xx -
+
+
-

- {{ $__t('Barcodes') }} - - {{ $__t('Add') }} - -

-
- - - - - - - @if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) - - @endif - - - - @if($mode == "edit") - @foreach($barcodes as $barcode) - @if($barcode->product_id == $product->id || $barcode->product_id == null) - - - - - @if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) - - @endif - - @endif - @endforeach - @endif - -
{{ $__t('Barcode') }}{{ $__t('Factor purchase to stock quantity unit') }}{{ $__t('Store') }}
- - - - - - - - {{ $barcode->barcode }} - - {{ $barcode->qu_factor_purchase_to_stock }} - - @if (FindObjectInArrayByPropertyValue($shoppinglocations, 'id', $barcode->shopping_location_id) !== null) - {{ FindObjectInArrayByPropertyValue($shoppinglocations, 'id', $barcode->shopping_location_id)->name }} - @endif -
+
-
- - - @if(!empty($product->picture_file_name)) -

+ + + + {{ $__t('Factor') }} + {{ $__t('Unit') }} + Hidden group + Hidden from_qu_id + + + + @if($mode == "edit") + @foreach($quConversions as $quConversion) + @if($quConversion->product_id == $product->id || $quConversion->product_id == null) + + + + + + + + + + + {{ $quConversion->factor }} + + + {{ FindObjectInArrayByPropertyValue($quantityunits, 'id', $quConversion->to_qu_id)->name }} + + + @if($quConversion->product_id != null) + {{ $__t('Product overrides') }} + @else + {{ $__t('Default conversions') }} + @endif + + + from_qu_id xx{{ $quConversion->from_qu_id }}xx + + + @endif + @endforeach + @endif + + +

+
+ +
+
+ + +
+ + + + + + + + @if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) + + @endif + + + + @if($mode == "edit") + @foreach($barcodes as $barcode) + @if($barcode->product_id == $product->id || $barcode->product_id == null) + + + + + @if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) + + @endif + + @endif + @endforeach + @endif + +
{{ $__t('Barcode') }}{{ $__t('Factor purchase to stock quantity unit') }}{{ $__t('Store') }}
+ + + + + + + + {{ $barcode->barcode }} + + {{ $barcode->qu_factor_purchase_to_stock }} + + @if (FindObjectInArrayByPropertyValue($shoppinglocations, 'id', $barcode->shopping_location_id) !== null) + {{ FindObjectInArrayByPropertyValue($shoppinglocations, 'id', $barcode->shopping_location_id)->name }} + @endif +
+
+
+ +
+
+ + @if(!empty($product->picture_file_name)) +

-

{{ $__t('The current picture will be deleted when you save the product') }}

- @else -

{{ $__t('No picture available') }}

- @endif + class="img-fluid img-thumbnail mt-2 lazy mb-5"> +

{{ $__t('The current picture will be deleted when you save the product') }}

+ @else +

{{ $__t('No picture available') }}

+ @endif +
diff --git a/views/quantityunitconversionform.blade.php b/views/quantityunitconversionform.blade.php index 9fac9707..3c2f52b3 100644 --- a/views/quantityunitconversionform.blade.php +++ b/views/quantityunitconversionform.blade.php @@ -11,7 +11,16 @@ @section('content')
-

@yield('title')

+
@@ -20,12 +29,6 @@
- @if($product != null) -

{{ $__t('Override for product') }} {{ $product->name }}

- @else -

{{ $__t('Default for QU') }} {{ $defaultQuUnit->name }}

- @endif - @@ -92,15 +95,19 @@ 'additionalCssClasses' => 'input-group-qu' )) -
-
@include('components.userfieldsform', array( diff --git a/views/quantityunitform.blade.php b/views/quantityunitform.blade.php index a79b367b..a7730acc 100644 --- a/views/quantityunitform.blade.php +++ b/views/quantityunitform.blade.php @@ -82,8 +82,12 @@ 'entity' => 'quantity_units' )) - + {{ $__t('Save & continue to add conversions') }} + + + @if(intval($pluralCount) > 2)
-
-

- {{ $__t('Default conversions') }} - - {{ $__t('Add') }} - -

-
- - - - - - - - - - @if($mode == "edit") - @foreach($defaultQuConversions as $defaultQuConversion) - - - - - - @endforeach - @endif - -
{{ $__t('Factor') }}{{ $__t('Unit') }}
- - + - {{ $defaultQuConversion->factor }} - - {{ FindObjectInArrayByPropertyValue($quantityUnits, 'id', $defaultQuConversion->to_qu_id)->name }} -
+
+
+ +
+ + + + + + + + + + + @if($mode == "edit") + @foreach($defaultQuConversions as $defaultQuConversion) + + + + + + @endforeach + @endif + +
{{ $__t('Factor') }}{{ $__t('Unit') }}
+ + + + + + + + {{ $defaultQuConversion->factor }} + + {{ FindObjectInArrayByPropertyValue($quantityUnits, 'id', $defaultQuConversion->to_qu_id)->name }} +
+
+
@stop diff --git a/views/recipeform.blade.php b/views/recipeform.blade.php index 671277ed..fdf157a1 100644 --- a/views/recipeform.blade.php +++ b/views/recipeform.blade.php @@ -61,34 +61,6 @@
{{ $__t('A name is required') }}
-
- -
-
- - - -
-
- -
-
-
- @php if($mode == 'edit') { $value = $recipe->base_servings; } else { $value = 1; } @endphp @include('components.numberpicker', array( 'id' => 'base_servings', @@ -113,7 +85,7 @@ {{ $__t('Do not check against the shopping list when adding missing items to it') }}  + title="{{ $__t('By default the amount to be added to the shopping list is "needed amount - stock amount - shopping list amount" - when this is enabled, it is only checked against the stock amount, not against what is already on the shopping list') }}"> @@ -149,21 +121,6 @@
-
-
- @if(!empty($recipe->picture_file_name)) - -

{{ $__t('The current picture will be deleted when you save the recipe') }}

- @else -

{{ $__t('No picture available') }}

- @endif -
-
-
+ +
+
+ + @if(!empty($recipe->picture_file_name)) + +

{{ $__t('The current picture will be deleted when you save the recipe') }}

+ @else +

{{ $__t('No picture available') }}

+ @endif +
+
diff --git a/views/recipeposform.blade.php b/views/recipeposform.blade.php index df3b3501..c61f2af6 100644 --- a/views/recipeposform.blade.php +++ b/views/recipeposform.blade.php @@ -11,7 +11,12 @@ @section('content')
-

@yield('title')

+
@@ -19,8 +24,6 @@
-

{{ $__t('Recipe') }} {{ $recipe->name }}

-