mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 12:20:22 +00:00
Use absolute URLs everywhere, this should fix #3
This commit is contained in:
@@ -14,6 +14,11 @@
|
||||
return localizedText;
|
||||
}
|
||||
|
||||
U = function(relativePath)
|
||||
{
|
||||
return Grocy.BaseUrl.replace(/\/$/, '') + relativePath;
|
||||
}
|
||||
|
||||
if (!Grocy.ActiveNav.isEmpty())
|
||||
{
|
||||
var menuItem = $('.nav').find("[data-nav-for-page='" + Grocy.ActiveNav + "']");
|
||||
@@ -23,9 +28,11 @@ if (!Grocy.ActiveNav.isEmpty())
|
||||
$.timeago.settings.allowFuture = true;
|
||||
$('time.timeago').timeago();
|
||||
|
||||
Grocy.FetchJson = function(url, success, error)
|
||||
Grocy.Api = { };
|
||||
Grocy.Api.Get = function(apiFunction, success, error)
|
||||
{
|
||||
var xhr = new XMLHttpRequest();
|
||||
var url = U('/api/' + apiFunction);
|
||||
|
||||
xhr.onreadystatechange = function()
|
||||
{
|
||||
@@ -52,9 +59,10 @@ Grocy.FetchJson = function(url, success, error)
|
||||
xhr.send();
|
||||
};
|
||||
|
||||
Grocy.PostJson = function(url, jsonData, success, error)
|
||||
Grocy.Api.Post = function(apiFunction, jsonData, success, error)
|
||||
{
|
||||
var xhr = new XMLHttpRequest();
|
||||
var url = U('/api/' + apiFunction);
|
||||
|
||||
xhr.onreadystatechange = function()
|
||||
{
|
||||
|
@@ -1,7 +1,7 @@
|
||||
$(document).on('click', '.battery-delete-button', function(e)
|
||||
{
|
||||
bootbox.confirm({
|
||||
message: 'Delete battery <strong>' + $(e.target).attr('data-battery-name') + '</strong>?',
|
||||
message: 'Delete battery <strong>' + $(e.currentTarget).attr('data-battery-name') + '</strong>?',
|
||||
buttons: {
|
||||
confirm: {
|
||||
label: 'Yes',
|
||||
@@ -16,10 +16,10 @@
|
||||
{
|
||||
if (result === true)
|
||||
{
|
||||
Grocy.FetchJson('/api/delete-object/batteries/' + $(e.target).attr('data-battery-id'),
|
||||
Grocy.Api.Get('delete-object/batteries/' + $(e.currentTarget).attr('data-battery-id'),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = '/batteries';
|
||||
window.location.href = U('/batteries');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
@@ -4,10 +4,10 @@
|
||||
|
||||
if (Grocy.EditMode === 'create')
|
||||
{
|
||||
Grocy.PostJson('/api/add-object/batteries', $('#battery-form').serializeJSON(),
|
||||
Grocy.Api.Post('add-object/batteries', $('#battery-form').serializeJSON(),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = '/batteries';
|
||||
window.location.href = U('/batteries');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
@@ -17,10 +17,10 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
Grocy.PostJson('/api/edit-object/batteries/' + Grocy.EditObjectId, $('#battery-form').serializeJSON(),
|
||||
Grocy.Api.Post('edit-object/batteries/' + Grocy.EditObjectId, $('#battery-form').serializeJSON(),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = '/batteries';
|
||||
window.location.href = U('/batteries');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
@@ -4,10 +4,10 @@
|
||||
|
||||
var jsonForm = $('#batterytracking-form').serializeJSON();
|
||||
|
||||
Grocy.FetchJson('/api/batteries/get-battery-details/' + jsonForm.battery_id,
|
||||
Grocy.Api.Get('batteries/get-battery-details/' + jsonForm.battery_id,
|
||||
function (batteryDetails)
|
||||
{
|
||||
Grocy.FetchJson('/api/batteries/track-charge-cycle/' + jsonForm.battery_id + '?tracked_time=' + $('#tracked_time').val(),
|
||||
Grocy.Api.Get('batteries/track-charge-cycle/' + jsonForm.battery_id + '?tracked_time=' + $('#tracked_time').val(),
|
||||
function(result)
|
||||
{
|
||||
toastr.success('Tracked charge cylce of battery ' + batteryDetails.battery.name + ' on ' + $('#tracked_time').val());
|
||||
|
@@ -2,7 +2,7 @@ Grocy.Components.BatteryCard = { };
|
||||
|
||||
Grocy.Components.BatteryCard.Refresh = function(batteryId)
|
||||
{
|
||||
Grocy.FetchJson('/api/batteries/get-battery-details/' + batteryId,
|
||||
Grocy.Api.Get('batteries/get-battery-details/' + batteryId,
|
||||
function(batteryDetails)
|
||||
{
|
||||
$('#batterycard-battery-name').text(batteryDetails.battery.name);
|
||||
|
@@ -2,7 +2,7 @@ Grocy.Components.HabitCard = { };
|
||||
|
||||
Grocy.Components.HabitCard.Refresh = function (habitId)
|
||||
{
|
||||
Grocy.FetchJson('/api/habits/get-habit-details/' + habitId,
|
||||
Grocy.Api.Get('habits/get-habit-details/' + habitId,
|
||||
function(habitDetails)
|
||||
{
|
||||
$('#habitcard-habit-name').text(habitDetails.habit.name);
|
||||
|
@@ -2,7 +2,7 @@ Grocy.Components.ProductCard = { };
|
||||
|
||||
Grocy.Components.ProductCard.Refresh = function(productId)
|
||||
{
|
||||
Grocy.FetchJson('/api/stock/get-product-details/' + productId,
|
||||
Grocy.Api.Get('stock/get-product-details/' + productId,
|
||||
function(productDetails)
|
||||
{
|
||||
$('#productcard-product-name').text(productDetails.product.name);
|
||||
|
@@ -10,10 +10,10 @@
|
||||
spoiled = 1;
|
||||
}
|
||||
|
||||
Grocy.FetchJson('/api/stock/get-product-details/' + jsonForm.product_id,
|
||||
Grocy.Api.Get('stock/get-product-details/' + jsonForm.product_id,
|
||||
function (productDetails)
|
||||
{
|
||||
Grocy.FetchJson('/api/stock/consume-product/' + jsonForm.product_id + '/' + jsonForm.amount + '?spoiled=' + spoiled,
|
||||
Grocy.Api.Get('stock/consume-product/' + jsonForm.product_id + '/' + jsonForm.amount + '?spoiled=' + spoiled,
|
||||
function(result)
|
||||
{
|
||||
toastr.success('Removed ' + jsonForm.amount + ' ' + productDetails.quantity_unit_stock.name + ' of ' + productDetails.product.name + ' from stock');
|
||||
@@ -46,7 +46,7 @@ $('#product_id').on('change', function(e)
|
||||
{
|
||||
Grocy.Components.ProductCard.Refresh(productId);
|
||||
|
||||
Grocy.FetchJson('/api/stock/get-product-details/' + productId,
|
||||
Grocy.Api.Get('stock/get-product-details/' + productId,
|
||||
function (productDetails)
|
||||
{
|
||||
$('#amount').attr('max', productDetails.stock_amount);
|
||||
|
@@ -4,10 +4,10 @@
|
||||
|
||||
if (Grocy.EditMode === 'create')
|
||||
{
|
||||
Grocy.PostJson('/api/add-object/habits', $('#habit-form').serializeJSON(),
|
||||
Grocy.Api.Post('add-object/habits', $('#habit-form').serializeJSON(),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = '/habits';
|
||||
window.location.href = U('/habits');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
@@ -17,10 +17,10 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
Grocy.PostJson('/api/edit-object/habits/' + Grocy.EditObjectId, $('#habit-form').serializeJSON(),
|
||||
Grocy.Api.Post('edit-object/habits/' + Grocy.EditObjectId, $('#habit-form').serializeJSON(),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = '/habits';
|
||||
window.location.href = U('/habits');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
@@ -1,7 +1,7 @@
|
||||
$(document).on('click', '.habit-delete-button', function(e)
|
||||
{
|
||||
bootbox.confirm({
|
||||
message: 'Delete habit <strong>' + $(e.target).attr('data-habit-name') + '</strong>?',
|
||||
message: 'Delete habit <strong>' + $(e.currentTarget).attr('data-habit-name') + '</strong>?',
|
||||
buttons: {
|
||||
confirm: {
|
||||
label: 'Yes',
|
||||
@@ -16,10 +16,10 @@
|
||||
{
|
||||
if (result === true)
|
||||
{
|
||||
Grocy.FetchJson('/api/delete-object/habits/' + $(e.target).attr('data-habit-id'),
|
||||
Grocy.Api.Get('delete-object/habits/' + $(e.currentTarget).attr('data-habit-id'),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = '/habits';
|
||||
window.location.href = U('/habits');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
@@ -4,10 +4,10 @@
|
||||
|
||||
var jsonForm = $('#habittracking-form').serializeJSON();
|
||||
|
||||
Grocy.FetchJson('/api/habits/get-habit-details/' + jsonForm.habit_id,
|
||||
Grocy.Api.Get('habits/get-habit-details/' + jsonForm.habit_id,
|
||||
function (habitDetails)
|
||||
{
|
||||
Grocy.FetchJson('/api/habits/track-habit-execution/' + jsonForm.habit_id + '?tracked_time=' + $('#tracked_time').val(),
|
||||
Grocy.Api.Get('habits/track-habit-execution/' + jsonForm.habit_id + '?tracked_time=' + $('#tracked_time').val(),
|
||||
function(result)
|
||||
{
|
||||
toastr.success('Tracked execution of habit ' + habitDetails.habit.name + ' on ' + $('#tracked_time').val());
|
||||
|
@@ -4,10 +4,10 @@
|
||||
|
||||
var jsonForm = $('#inventory-form').serializeJSON();
|
||||
|
||||
Grocy.FetchJson('/api/stock/get-product-details/' + jsonForm.product_id,
|
||||
Grocy.Api.Get('stock/get-product-details/' + jsonForm.product_id,
|
||||
function (productDetails)
|
||||
{
|
||||
Grocy.FetchJson('/api/stock/inventory-product/' + jsonForm.product_id + '/' + jsonForm.new_amount + '?bestbeforedate=' + $('#best_before_date').val(),
|
||||
Grocy.Api.Get('stock/inventory-product/' + jsonForm.product_id + '/' + jsonForm.new_amount + '?bestbeforedate=' + $('#best_before_date').val(),
|
||||
function(result)
|
||||
{
|
||||
var addBarcode = GetUriParam('addbarcodetoselection');
|
||||
@@ -23,7 +23,7 @@
|
||||
productDetails.product.barcode += ',' + addBarcode;
|
||||
}
|
||||
|
||||
Grocy.PostJson('/api/edit-object/products/' + productDetails.product.id, productDetails.product,
|
||||
Grocy.Api.Get('edit-object/products/' + productDetails.product.id, productDetails.product,
|
||||
function (result) { },
|
||||
function(xhr)
|
||||
{
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
if (addBarcode !== undefined)
|
||||
{
|
||||
window.location.href = '/inventory';
|
||||
window.location.href = U('/inventory');
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -71,7 +71,7 @@ $('#product_id').on('change', function(e)
|
||||
{
|
||||
Grocy.Components.ProductCard.Refresh(productId);
|
||||
|
||||
Grocy.FetchJson('/api/stock/get-product-details/' + productId,
|
||||
Grocy.Api.Get('stock/get-product-details/' + productId,
|
||||
function(productDetails)
|
||||
{
|
||||
$('#new_amount').attr('not-equal', productDetails.stock_amount);
|
||||
@@ -124,7 +124,7 @@ $('#product_id_text_input').on('change', function(e)
|
||||
className: 'btn-success add-new-product-dialog-button',
|
||||
callback: function()
|
||||
{
|
||||
window.location.href = '/product/new?prefillname=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(window.location.pathname);
|
||||
window.location.href = U('/product/new?prefillname=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(window.location.pathname));
|
||||
}
|
||||
},
|
||||
addbarcode: {
|
||||
@@ -132,7 +132,7 @@ $('#product_id_text_input').on('change', function(e)
|
||||
className: 'btn-info add-new-barcode-dialog-button',
|
||||
callback: function()
|
||||
{
|
||||
window.location.href = '/inventory?addbarcodetoselection=' + encodeURIComponent(input);
|
||||
window.location.href = U('/inventory?addbarcodetoselection=' + encodeURIComponent(input));
|
||||
}
|
||||
},
|
||||
addnewproductwithbarcode: {
|
||||
@@ -140,7 +140,7 @@ $('#product_id_text_input').on('change', function(e)
|
||||
className: 'btn-warning add-new-product-with-barcode-dialog-button',
|
||||
callback: function()
|
||||
{
|
||||
window.location.href = '/product/new?prefillbarcode=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(window.location.pathname);
|
||||
window.location.href = U('/product/new?prefillbarcode=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(window.location.pathname));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -283,7 +283,7 @@ $('#new_amount').on('change', function(e)
|
||||
|
||||
if (productId)
|
||||
{
|
||||
Grocy.FetchJson('/api/stock/get-product-details/' + productId,
|
||||
Grocy.Api.Get('stock/get-product-details/' + productId,
|
||||
function(productDetails)
|
||||
{
|
||||
var productStockAmount = productDetails.stock_amount || '0';
|
||||
|
@@ -4,10 +4,10 @@
|
||||
|
||||
if (Grocy.EditMode === 'create')
|
||||
{
|
||||
Grocy.PostJson('/api/add-object/locations', $('#location-form').serializeJSON(),
|
||||
Grocy.Api.Post('add-object/locations', $('#location-form').serializeJSON(),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = '/locations';
|
||||
window.location.href = U('/locations');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
@@ -17,10 +17,10 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
Grocy.PostJson('/api/edit-object/locations/' + Grocy.EditObjectId, $('#location-form').serializeJSON(),
|
||||
Grocy.Api.Post('edit-object/locations/' + Grocy.EditObjectId, $('#location-form').serializeJSON(),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = '/locations';
|
||||
window.location.href = U('/locations');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
@@ -1,7 +1,7 @@
|
||||
$(document).on('click', '.location-delete-button', function(e)
|
||||
{
|
||||
bootbox.confirm({
|
||||
message: 'Delete location <strong>' + $(e.target).attr('data-location-name') + '</strong>?',
|
||||
message: 'Delete location <strong>' + $(e.currentTarget).attr('data-location-name') + '</strong>?',
|
||||
buttons: {
|
||||
confirm: {
|
||||
label: 'Yes',
|
||||
@@ -16,10 +16,10 @@
|
||||
{
|
||||
if (result === true)
|
||||
{
|
||||
Grocy.FetchJson('/api/delete-object/locations/' + $(e.target).attr('data-location-id'),
|
||||
Grocy.Api.Get('delete-object/locations/' + $(e.currentTarget).attr('data-location-id'),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = '/locations';
|
||||
window.location.href = U('/locations');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
@@ -2,7 +2,7 @@
|
||||
{
|
||||
e.preventDefault();
|
||||
|
||||
var redirectDestination = '/products';
|
||||
var redirectDestination = U('/products');
|
||||
var returnTo = GetUriParam('returnto');
|
||||
if (returnTo !== undefined)
|
||||
{
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
if (Grocy.EditMode === 'create')
|
||||
{
|
||||
Grocy.PostJson('/api/add-object/products', $('#product-form').serializeJSON(),
|
||||
Grocy.Api.Post('add-object/products', $('#product-form').serializeJSON(),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = redirectDestination;
|
||||
@@ -24,7 +24,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
Grocy.PostJson('/api/edit-object/products/' + Grocy.EditObjectId, $('#product-form').serializeJSON(),
|
||||
Grocy.Api.Post('edit-object/products/' + Grocy.EditObjectId, $('#product-form').serializeJSON(),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = redirectDestination;
|
||||
@@ -44,7 +44,7 @@ $('#barcode-taginput').tagsManager({
|
||||
|
||||
if (Grocy.EditMode === 'edit')
|
||||
{
|
||||
Grocy.FetchJson('/api/get-object/products/' + Grocy.EditObjectId,
|
||||
Grocy.Api.Get('get-object/products/' + Grocy.EditObjectId,
|
||||
function (product)
|
||||
{
|
||||
if (product.barcode !== null && product.barcode.length > 0)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
$(document).on('click', '.product-delete-button', function(e)
|
||||
{
|
||||
bootbox.confirm({
|
||||
message: 'Delete product <strong>' + $(e.target).attr('data-product-name') + '</strong>?',
|
||||
message: 'Delete product <strong>' + $(e.currentTarget).attr('data-product-name') + '</strong>?',
|
||||
buttons: {
|
||||
confirm: {
|
||||
label: 'Yes',
|
||||
@@ -16,10 +16,10 @@
|
||||
{
|
||||
if (result === true)
|
||||
{
|
||||
Grocy.FetchJson('/api/delete-object/products/' + $(e.target).attr('data-product-id'),
|
||||
Grocy.Api.Get('delete-object/products/' + $(e.currentTarget).attr('data-product-id'),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = '/products';
|
||||
window.location.href = U('/products');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
@@ -4,12 +4,12 @@
|
||||
|
||||
var jsonForm = $('#purchase-form').serializeJSON();
|
||||
|
||||
Grocy.FetchJson('/api/stock/get-product-details/' + jsonForm.product_id,
|
||||
Grocy.Api.Get('stock/get-product-details/' + jsonForm.product_id,
|
||||
function (productDetails)
|
||||
{
|
||||
var amount = jsonForm.amount * productDetails.product.qu_factor_purchase_to_stock;
|
||||
|
||||
Grocy.FetchJson('/api/stock/add-product/' + jsonForm.product_id + '/' + amount + '?bestbeforedate=' + $('#best_before_date').val(),
|
||||
Grocy.Api.Get('stock/add-product/' + jsonForm.product_id + '/' + amount + '?bestbeforedate=' + $('#best_before_date').val(),
|
||||
function(result)
|
||||
{
|
||||
var addBarcode = GetUriParam('addbarcodetoselection');
|
||||
@@ -25,7 +25,7 @@
|
||||
productDetails.product.barcode += ',' + addBarcode;
|
||||
}
|
||||
|
||||
Grocy.PostJson('/api/edit-object/products/' + productDetails.product.id, productDetails.product,
|
||||
Grocy.Api.Post('edit-object/products/' + productDetails.product.id, productDetails.product,
|
||||
function (result) { },
|
||||
function(xhr)
|
||||
{
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
if (addBarcode !== undefined)
|
||||
{
|
||||
window.location.href = '/purchase';
|
||||
window.location.href = U('/purchase');
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -72,7 +72,7 @@ $('#product_id').on('change', function(e)
|
||||
{
|
||||
Grocy.Components.ProductCard.Refresh(productId);
|
||||
|
||||
Grocy.FetchJson('/api/stock/get-product-details/' + productId,
|
||||
Grocy.Api.Get('stock/get-product-details/' + productId,
|
||||
function(productDetails)
|
||||
{
|
||||
$('#amount_qu_unit').text(productDetails.quantity_unit_purchase.name);
|
||||
@@ -133,7 +133,7 @@ $('#product_id_text_input').on('change', function(e)
|
||||
className: 'btn-success add-new-product-dialog-button',
|
||||
callback: function()
|
||||
{
|
||||
window.location.href = '/product/new?prefillname=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(window.location.pathname);
|
||||
window.location.href = U('/product/new?prefillname=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(window.location.pathname));
|
||||
}
|
||||
},
|
||||
addbarcode: {
|
||||
@@ -141,7 +141,7 @@ $('#product_id_text_input').on('change', function(e)
|
||||
className: 'btn-info add-new-barcode-dialog-button',
|
||||
callback: function()
|
||||
{
|
||||
window.location.href = '/purchase?addbarcodetoselection=' + encodeURIComponent(input);
|
||||
window.location.href = U('/purchase?addbarcodetoselection=' + encodeURIComponent(input));
|
||||
}
|
||||
},
|
||||
addnewproductwithbarcode: {
|
||||
@@ -149,7 +149,7 @@ $('#product_id_text_input').on('change', function(e)
|
||||
className: 'btn-warning add-new-product-with-barcode-dialog-button',
|
||||
callback: function()
|
||||
{
|
||||
window.location.href = '/product/new?prefillbarcode=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(window.location.pathname);
|
||||
window.location.href = U('/product/new?prefillbarcode=' + encodeURIComponent(input) + '&returnto=' + encodeURIComponent(window.location.pathname));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -4,10 +4,10 @@
|
||||
|
||||
if (Grocy.EditMode === 'create')
|
||||
{
|
||||
Grocy.PostJson('/api/add-object/quantity_units', $('#quantityunit-form').serializeJSON(),
|
||||
Grocy.Api.Post('add-object/quantity_units', $('#quantityunit-form').serializeJSON(),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = '/quantityunits';
|
||||
window.location.href = U('/quantityunits');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
@@ -17,10 +17,10 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
Grocy.PostJson('/api/edit-object/quantity_units/' + Grocy.EditObjectId, $('#quantityunit-form').serializeJSON(),
|
||||
Grocy.Api.Post('edit-object/quantity_units/' + Grocy.EditObjectId, $('#quantityunit-form').serializeJSON(),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = '/quantityunits';
|
||||
window.location.href = U('/quantityunits');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
@@ -1,7 +1,7 @@
|
||||
$(document).on('click', '.quantityunit-delete-button', function(e)
|
||||
{
|
||||
bootbox.confirm({
|
||||
message: 'Delete quantity unit <strong>' + $(e.target).attr('data-quantityunit-name') + '</strong>?',
|
||||
message: 'Delete quantity unit <strong>' + $(e.currentTarget).attr('data-quantityunit-name') + '</strong>?',
|
||||
buttons: {
|
||||
confirm: {
|
||||
label: 'Yes',
|
||||
@@ -16,10 +16,10 @@
|
||||
{
|
||||
if (result === true)
|
||||
{
|
||||
Grocy.FetchJson('/api/delete-object/quantity_units/' + $(e.target).attr('data-quantityunit-id'),
|
||||
Grocy.Api.Get('delete-object/quantity_units/' + $(e.currentTarget).attr('data-quantityunit-id'),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = '/quantityunits';
|
||||
window.location.href = U('/quantityunits');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
@@ -1,9 +1,9 @@
|
||||
$(document).on('click', '.shoppinglist-delete-button', function(e)
|
||||
{
|
||||
Grocy.FetchJson('/api/delete-object/shopping_list/' + $(e.target).attr('data-shoppinglist-id'),
|
||||
Grocy.Api.Get('delete-object/shopping_list/' + $(e.currentTarget).attr('data-shoppinglist-id'),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = '/shoppinglist';
|
||||
window.location.href = U('/shoppinglist');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
@@ -14,10 +14,10 @@
|
||||
|
||||
$(document).on('click', '#add-products-below-min-stock-amount', function(e)
|
||||
{
|
||||
Grocy.FetchJson('/api/stock/add-missing-products-to-shoppinglist',
|
||||
Grocy.Api.Get('stock/add-missing-products-to-shoppinglist',
|
||||
function(result)
|
||||
{
|
||||
window.location.href = '/shoppinglist';
|
||||
window.location.href = U('/shoppinglist');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
|
@@ -4,10 +4,10 @@
|
||||
|
||||
if (Grocy.EditMode === 'create')
|
||||
{
|
||||
Grocy.PostJson('/api/add-object/shopping_list', $('#shoppinglist-form').serializeJSON(),
|
||||
Grocy.Api.Post('add-object/shopping_list', $('#shoppinglist-form').serializeJSON(),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = '/shoppinglist';
|
||||
window.location.href = U('/shoppinglist');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
@@ -17,10 +17,10 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
Grocy.PostJson('/api/edit-object/shopping_list/' + Grocy.EditObjectId, $('#shoppinglist-form').serializeJSON(),
|
||||
Grocy.Api.Post('edit-object/shopping_list/' + Grocy.EditObjectId, $('#shoppinglist-form').serializeJSON(),
|
||||
function(result)
|
||||
{
|
||||
window.location.href = '/shoppinglist';
|
||||
window.location.href = U('/shoppinglist');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
@@ -38,7 +38,7 @@ $('#product_id').on('change', function(e)
|
||||
{
|
||||
Grocy.Components.ProductCard.Refresh(productId);
|
||||
|
||||
Grocy.FetchJson('/api/stock/get-product-details/' + productId,
|
||||
Grocy.Api.Get('stock/get-product-details/' + productId,
|
||||
function (productDetails)
|
||||
{
|
||||
$('#amount_qu_unit').text(productDetails.quantity_unit_purchase.name);
|
||||
@@ -49,7 +49,7 @@ $('#product_id').on('change', function(e)
|
||||
}
|
||||
else
|
||||
{
|
||||
Grocy.FetchJson('/api/get-objects/shopping_list',
|
||||
Grocy.Api.Get('get-objects/shopping_list',
|
||||
function (currentShoppingListItems)
|
||||
{
|
||||
if (currentShoppingListItems.filter(function (e) { return e.product_id === productId; }).length > 0)
|
||||
|
Reference in New Issue
Block a user