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 @@