mirror of
https://github.com/grocy/grocy.git
synced 2025-08-15 02:04:38 +00:00
Applied VSCode JS formatting settings
This commit is contained in:
@@ -41,7 +41,7 @@ UpdateUriParam = function(key, value)
|
|||||||
{
|
{
|
||||||
var queryParameters = new URLSearchParams(location.search);
|
var queryParameters = new URLSearchParams(location.search);
|
||||||
queryParameters.set(key, value);
|
queryParameters.set(key, value);
|
||||||
window.history.replaceState({ }, "", decodeURIComponent(`${location.pathname}?${queryParameters}`));
|
window.history.replaceState({}, "", decodeURIComponent(`${location.pathname}?${queryParameters}`));
|
||||||
};
|
};
|
||||||
|
|
||||||
IsTouchInputDevice = function()
|
IsTouchInputDevice = function()
|
||||||
@@ -78,12 +78,12 @@ GetFileExtension = function(pathOrFileName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$.extend($.expr[":"],
|
$.extend($.expr[":"],
|
||||||
{
|
|
||||||
"contains_case_insensitive": function(elem, i, match, array)
|
|
||||||
{
|
{
|
||||||
return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
|
"contains_case_insensitive": function(elem, i, match, array)
|
||||||
}
|
{
|
||||||
});
|
return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
FindObjectInArrayByPropertyValue = function(array, propertyName, propertyValue)
|
FindObjectInArrayByPropertyValue = function(array, propertyName, propertyValue)
|
||||||
{
|
{
|
||||||
@@ -123,7 +123,7 @@ function IsJsonString(text)
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
JSON.parse(text);
|
JSON.parse(text);
|
||||||
} catch(e)
|
} catch (e)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
Grocy.Api = { };
|
Grocy.Api = {};
|
||||||
Grocy.Api.Get = function(apiFunction, success, error)
|
Grocy.Api.Get = function(apiFunction, success, error)
|
||||||
{
|
{
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
@@ -18,7 +18,7 @@ Grocy.Api.Get = function(apiFunction, success, error)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
success({ });
|
success({});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,7 @@ Grocy.Api.Post = function(apiFunction, jsonData, success, error)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
success({ });
|
success({});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ Grocy.Api.Put = function(apiFunction, jsonData, success, error)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
success({ });
|
success({});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,7 +131,7 @@ Grocy.Api.Delete = function(apiFunction, jsonData, success, error)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
success({ });
|
success({});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -169,7 +169,7 @@ Grocy.Api.UploadFile = function(file, group, fileName, success, error)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
success({ });
|
success({});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -207,7 +207,7 @@ Grocy.Api.DeleteFile = function(fileName, group, success, error)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
success({ });
|
success({});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -266,7 +266,7 @@ if (!Grocy.ActiveNav.isEmpty())
|
|||||||
$(parentMenuSelector).collapse("show");
|
$(parentMenuSelector).collapse("show");
|
||||||
$(parentMenuSelector).prev(".nav-link-collapse").addClass("active-page");
|
$(parentMenuSelector).prev(".nav-link-collapse").addClass("active-page");
|
||||||
|
|
||||||
$(parentMenuSelector).on("shown.bs.collapse", function (e)
|
$(parentMenuSelector).on("shown.bs.collapse", function(e)
|
||||||
{
|
{
|
||||||
if (!menuItem.isVisibleInViewport(75))
|
if (!menuItem.isVisibleInViewport(75))
|
||||||
{
|
{
|
||||||
@@ -376,7 +376,7 @@ if (IsTouchInputDevice())
|
|||||||
document.body.appendChild(css);
|
document.body.appendChild(css);
|
||||||
}
|
}
|
||||||
|
|
||||||
Grocy.FrontendHelpers = { };
|
Grocy.FrontendHelpers = {};
|
||||||
Grocy.FrontendHelpers.ValidateForm = function(formId)
|
Grocy.FrontendHelpers.ValidateForm = function(formId)
|
||||||
{
|
{
|
||||||
var form = document.getElementById(formId);
|
var form = document.getElementById(formId);
|
||||||
@@ -465,7 +465,7 @@ $(document).on("change", ".user-setting-control", function()
|
|||||||
|
|
||||||
Grocy.UserSettings[settingKey] = value;
|
Grocy.UserSettings[settingKey] = value;
|
||||||
|
|
||||||
jsonData = { };
|
jsonData = {};
|
||||||
jsonData.value = value;
|
jsonData.value = value;
|
||||||
Grocy.Api.Put('user/settings/' + settingKey, jsonData,
|
Grocy.Api.Put('user/settings/' + settingKey, jsonData,
|
||||||
function(result)
|
function(result)
|
||||||
@@ -523,7 +523,7 @@ $("iframe").on("load", function()
|
|||||||
|
|
||||||
function WindowMessageBag(message, payload = null)
|
function WindowMessageBag(message, payload = null)
|
||||||
{
|
{
|
||||||
var obj = { };
|
var obj = {};
|
||||||
obj.Message = message;
|
obj.Message = message;
|
||||||
obj.Payload = payload;
|
obj.Payload = payload;
|
||||||
return obj;
|
return obj;
|
||||||
@@ -566,7 +566,7 @@ function RefreshLocaleNumberDisplay(rootSelector = "#page-content")
|
|||||||
$(this).text(parseFloat($(this).text()).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 3 }));
|
$(this).text(parseFloat($(this).text()).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 3 }));
|
||||||
});
|
});
|
||||||
|
|
||||||
$(rootSelector + " .locale-number.locale-number-generic").each(function ()
|
$(rootSelector + " .locale-number.locale-number-generic").each(function()
|
||||||
{
|
{
|
||||||
if (isNaN(parseFloat($(this).text())))
|
if (isNaN(parseFloat($(this).text())))
|
||||||
{
|
{
|
||||||
@@ -635,7 +635,7 @@ $(document).on("click", ".show-as-dialog-link", function(e)
|
|||||||
cancel: {
|
cancel: {
|
||||||
label: __t('Cancel'),
|
label: __t('Cancel'),
|
||||||
className: 'btn-secondary responsive-button',
|
className: 'btn-secondary responsive-button',
|
||||||
callback: function ()
|
callback: function()
|
||||||
{
|
{
|
||||||
bootbox.hideAll();
|
bootbox.hideAll();
|
||||||
}
|
}
|
||||||
@@ -648,11 +648,11 @@ $(document).on("click", ".show-as-dialog-link", function(e)
|
|||||||
$.extend(true, $.fn.dataTable.defaults, {
|
$.extend(true, $.fn.dataTable.defaults, {
|
||||||
'paginate': false,
|
'paginate': false,
|
||||||
'deferRender': true,
|
'deferRender': true,
|
||||||
'language': IsJsonString(__t('datatables_localization')) ? JSON.parse(__t('datatables_localization')) : { },
|
'language': IsJsonString(__t('datatables_localization')) ? JSON.parse(__t('datatables_localization')) : {},
|
||||||
'scrollY': false,
|
'scrollY': false,
|
||||||
'colReorder': true,
|
'colReorder': true,
|
||||||
'stateSave': true,
|
'stateSave': true,
|
||||||
'stateSaveParams': function (settings, data)
|
'stateSaveParams': function(settings, data)
|
||||||
{
|
{
|
||||||
data.search.search = "";
|
data.search.search = "";
|
||||||
|
|
||||||
@@ -663,10 +663,10 @@ $.extend(true, $.fn.dataTable.defaults, {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(Grocy.UserPermissions).each(function (index, item)
|
$(Grocy.UserPermissions).each(function(index, item)
|
||||||
{
|
{
|
||||||
if(item.has_permission == 0)
|
if (item.has_permission == 0)
|
||||||
{
|
{
|
||||||
$('.permission-'+item.permission_name).addClass('disabled').addClass('not-allowed');
|
$('.permission-' + item.permission_name).addClass('disabled').addClass('not-allowed');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
$("#show-clock-in-header").on("change", function ()
|
$("#show-clock-in-header").on("change", function()
|
||||||
{
|
{
|
||||||
CheckHeaderClockEnabled();
|
CheckHeaderClockEnabled();
|
||||||
});
|
});
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
Grocy.UISound = { };
|
Grocy.UISound = {};
|
||||||
|
|
||||||
Grocy.UISound.Play = function(url)
|
Grocy.UISound.Play = function(url)
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
Grocy.WakeLock = { };
|
Grocy.WakeLock = {};
|
||||||
Grocy.WakeLock.NoSleepJsIntance = null;
|
Grocy.WakeLock.NoSleepJsIntance = null;
|
||||||
Grocy.WakeLock.InitDone = false;
|
Grocy.WakeLock.InitDone = false;
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
Grocy.BarCodeScannerTestingHitCount = 0;
|
Grocy.BarCodeScannerTestingHitCount = 0;
|
||||||
Grocy.BarCodeScannerTestingMissCount = 0;
|
Grocy.BarCodeScannerTestingMissCount = 0;
|
||||||
|
|
||||||
$("#scanned_barcode").on("blur", function (e)
|
$("#scanned_barcode").on("blur", function(e)
|
||||||
{
|
{
|
||||||
OnBarcodeScanned($("#scanned_barcode").val());
|
OnBarcodeScanned($("#scanned_barcode").val());
|
||||||
});
|
});
|
||||||
@@ -41,7 +41,7 @@ setTimeout(function()
|
|||||||
if (GetUriParam("barcode") !== undefined)
|
if (GetUriParam("barcode") !== undefined)
|
||||||
{
|
{
|
||||||
$("#expected_barcode").val(GetUriParam("barcode"));
|
$("#expected_barcode").val(GetUriParam("barcode"));
|
||||||
setTimeout(function ()
|
setTimeout(function()
|
||||||
{
|
{
|
||||||
$("#expected_barcode").keyup();
|
$("#expected_barcode").keyup();
|
||||||
$("#scanned_barcode").focus();
|
$("#scanned_barcode").focus();
|
||||||
|
@@ -19,7 +19,7 @@ $("#search").on("keyup", Delay(function()
|
|||||||
batteriesTable.search(value).draw();
|
batteriesTable.search(value).draw();
|
||||||
}, 200));
|
}, 200));
|
||||||
|
|
||||||
$(document).on('click', '.battery-delete-button', function (e)
|
$(document).on('click', '.battery-delete-button', function(e)
|
||||||
{
|
{
|
||||||
var objectName = $(e.currentTarget).attr('data-battery-name');
|
var objectName = $(e.currentTarget).attr('data-battery-name');
|
||||||
var objectId = $(e.currentTarget).attr('data-battery-id');
|
var objectId = $(e.currentTarget).attr('data-battery-id');
|
||||||
@@ -41,7 +41,7 @@ $(document).on('click', '.battery-delete-button', function (e)
|
|||||||
{
|
{
|
||||||
if (result === true)
|
if (result === true)
|
||||||
{
|
{
|
||||||
Grocy.Api.Delete('objects/batteries/' + objectId, { },
|
Grocy.Api.Delete('objects/batteries/' + objectId, {},
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
window.location.href = U('/batteries');
|
window.location.href = U('/batteries');
|
||||||
|
@@ -45,7 +45,7 @@ $(document).on('click', '.undo-battery-execution-button', function(e)
|
|||||||
var element = $(e.currentTarget);
|
var element = $(e.currentTarget);
|
||||||
var chargeCycleId = $(e.currentTarget).attr('data-charge-cycle-id');
|
var chargeCycleId = $(e.currentTarget).attr('data-charge-cycle-id');
|
||||||
|
|
||||||
Grocy.Api.Post('batteries/charge-cycles/' + chargeCycleId.toString() + '/undo', { },
|
Grocy.Api.Post('batteries/charge-cycles/' + chargeCycleId.toString() + '/undo', {},
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
element.closest("tr").addClass("text-muted");
|
element.closest("tr").addClass("text-muted");
|
||||||
|
@@ -122,7 +122,8 @@ function RefreshStatistics()
|
|||||||
var overdueCount = 0;
|
var overdueCount = 0;
|
||||||
var now = moment();
|
var now = moment();
|
||||||
var nextXDaysThreshold = moment().add(nextXDays, "days");
|
var nextXDaysThreshold = moment().add(nextXDays, "days");
|
||||||
result.forEach(element => {
|
result.forEach(element =>
|
||||||
|
{
|
||||||
var date = moment(element.next_estimated_charge_time);
|
var date = moment(element.next_estimated_charge_time);
|
||||||
if (date.isBefore(now))
|
if (date.isBefore(now))
|
||||||
{
|
{
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
Grocy.FrontendHelpers.BeginUiBusy("batterytracking-form");
|
Grocy.FrontendHelpers.BeginUiBusy("batterytracking-form");
|
||||||
|
|
||||||
Grocy.Api.Get('batteries/' + jsonForm.battery_id,
|
Grocy.Api.Get('batteries/' + jsonForm.battery_id,
|
||||||
function (batteryDetails)
|
function(batteryDetails)
|
||||||
{
|
{
|
||||||
Grocy.Api.Post('batteries/' + jsonForm.battery_id + '/charge', { 'tracked_time': $('#tracked_time').find('input').val() },
|
Grocy.Api.Post('batteries/' + jsonForm.battery_id + '/charge', { 'tracked_time': $('#tracked_time').find('input').val() },
|
||||||
function(result)
|
function(result)
|
||||||
@@ -64,7 +64,7 @@ $('#battery_id_text_input').trigger('change');
|
|||||||
Grocy.Components.DateTimePicker.GetInputElement().trigger('input');
|
Grocy.Components.DateTimePicker.GetInputElement().trigger('input');
|
||||||
Grocy.FrontendHelpers.ValidateForm('batterytracking-form');
|
Grocy.FrontendHelpers.ValidateForm('batterytracking-form');
|
||||||
|
|
||||||
$('#batterytracking-form input').keyup(function (event)
|
$('#batterytracking-form input').keyup(function(event)
|
||||||
{
|
{
|
||||||
Grocy.FrontendHelpers.ValidateForm('batterytracking-form');
|
Grocy.FrontendHelpers.ValidateForm('batterytracking-form');
|
||||||
});
|
});
|
||||||
@@ -86,14 +86,14 @@ $('#batterytracking-form input').keydown(function(event)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#tracked_time').find('input').on('keypress', function (e)
|
$('#tracked_time').find('input').on('keypress', function(e)
|
||||||
{
|
{
|
||||||
Grocy.FrontendHelpers.ValidateForm('batterytracking-form');
|
Grocy.FrontendHelpers.ValidateForm('batterytracking-form');
|
||||||
});
|
});
|
||||||
|
|
||||||
function UndoChargeCycle(chargeCycleId)
|
function UndoChargeCycle(chargeCycleId)
|
||||||
{
|
{
|
||||||
Grocy.Api.Post('batteries/charge-cycles/' + chargeCycleId.toString() + '/undo', { },
|
Grocy.Api.Post('batteries/charge-cycles/' + chargeCycleId.toString() + '/undo', {},
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
toastr.success(__t("Charge cycle successfully undone"));
|
toastr.success(__t("Charge cycle successfully undone"));
|
||||||
|
@@ -17,9 +17,10 @@ var calendar = $("#calendar").fullCalendar({
|
|||||||
"eventLimit": false,
|
"eventLimit": false,
|
||||||
"height": "auto",
|
"height": "auto",
|
||||||
"eventSources": fullcalendarEventSources,
|
"eventSources": fullcalendarEventSources,
|
||||||
eventClick: function(info) {
|
eventClick: function(info)
|
||||||
|
{
|
||||||
location.href = info.link;
|
location.href = info.link;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#ical-button").on("click", function(e)
|
$("#ical-button").on("click", function(e)
|
||||||
|
@@ -19,11 +19,11 @@
|
|||||||
Grocy.Components.UserfieldsForm.Save(function()
|
Grocy.Components.UserfieldsForm.Save(function()
|
||||||
{
|
{
|
||||||
Grocy.Api.Post('chores/executions/calculate-next-assignments', { "chore_id": Grocy.EditObjectId },
|
Grocy.Api.Post('chores/executions/calculate-next-assignments', { "chore_id": Grocy.EditObjectId },
|
||||||
function (result)
|
function(result)
|
||||||
{
|
{
|
||||||
window.location.href = U('/chores');
|
window.location.href = U('/chores');
|
||||||
},
|
},
|
||||||
function (xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
Grocy.FrontendHelpers.EndUiBusy();
|
Grocy.FrontendHelpers.EndUiBusy();
|
||||||
console.error(xhr);
|
console.error(xhr);
|
||||||
@@ -46,11 +46,11 @@
|
|||||||
Grocy.Components.UserfieldsForm.Save(function()
|
Grocy.Components.UserfieldsForm.Save(function()
|
||||||
{
|
{
|
||||||
Grocy.Api.Post('chores/executions/calculate-next-assignments', { "chore_id": Grocy.EditObjectId },
|
Grocy.Api.Post('chores/executions/calculate-next-assignments', { "chore_id": Grocy.EditObjectId },
|
||||||
function (result)
|
function(result)
|
||||||
{
|
{
|
||||||
window.location.href = U('/chores');
|
window.location.href = U('/chores');
|
||||||
},
|
},
|
||||||
function (xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
Grocy.FrontendHelpers.EndUiBusy();
|
Grocy.FrontendHelpers.EndUiBusy();
|
||||||
console.error(xhr);
|
console.error(xhr);
|
||||||
@@ -145,7 +145,7 @@ $('.input-group-chore-period-type').on('change', function(e)
|
|||||||
else if (periodType === 'weekly')
|
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').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'));
|
||||||
$("#period_config").val($(".period-type-weekly input:checkbox:checked").map(function () { return this.value; }).get().join(","));
|
$("#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').text(__t('This means the next execution of this chore should only be scheduled every %s weeks', periodInterval.toString()));
|
||||||
}
|
}
|
||||||
else if (periodType === 'monthly')
|
else if (periodType === 'monthly')
|
||||||
|
@@ -19,7 +19,7 @@ $("#search").on("keyup", Delay(function()
|
|||||||
choresTable.search(value).draw();
|
choresTable.search(value).draw();
|
||||||
}, 200));
|
}, 200));
|
||||||
|
|
||||||
$(document).on('click', '.chore-delete-button', function (e)
|
$(document).on('click', '.chore-delete-button', function(e)
|
||||||
{
|
{
|
||||||
var objectName = $(e.currentTarget).attr('data-chore-name');
|
var objectName = $(e.currentTarget).attr('data-chore-name');
|
||||||
var objectId = $(e.currentTarget).attr('data-chore-id');
|
var objectId = $(e.currentTarget).attr('data-chore-id');
|
||||||
|
@@ -45,7 +45,7 @@ $(document).on('click', '.undo-chore-execution-button', function(e)
|
|||||||
var element = $(e.currentTarget);
|
var element = $(e.currentTarget);
|
||||||
var executionId = $(e.currentTarget).attr('data-execution-id');
|
var executionId = $(e.currentTarget).attr('data-execution-id');
|
||||||
|
|
||||||
Grocy.Api.Post('chores/executions/' + executionId.toString() + '/undo', { },
|
Grocy.Api.Post('chores/executions/' + executionId.toString() + '/undo', {},
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
element.closest("tr").addClass("text-muted");
|
element.closest("tr").addClass("text-muted");
|
||||||
|
@@ -182,7 +182,8 @@ function RefreshStatistics()
|
|||||||
var assignedToMeCount = 0;
|
var assignedToMeCount = 0;
|
||||||
var now = moment();
|
var now = moment();
|
||||||
var nextXDaysThreshold = moment().add(nextXDays, "days");
|
var nextXDaysThreshold = moment().add(nextXDays, "days");
|
||||||
result.forEach(element => {
|
result.forEach(element =>
|
||||||
|
{
|
||||||
var date = moment(element.next_estimated_execution_time);
|
var date = moment(element.next_estimated_execution_time);
|
||||||
if (date.isBefore(now))
|
if (date.isBefore(now))
|
||||||
{
|
{
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
Grocy.FrontendHelpers.BeginUiBusy("choretracking-form");
|
Grocy.FrontendHelpers.BeginUiBusy("choretracking-form");
|
||||||
|
|
||||||
Grocy.Api.Get('chores/' + jsonForm.chore_id,
|
Grocy.Api.Get('chores/' + jsonForm.chore_id,
|
||||||
function (choreDetails)
|
function(choreDetails)
|
||||||
{
|
{
|
||||||
Grocy.Api.Post('chores/' + jsonForm.chore_id + '/execute', { 'tracked_time': Grocy.Components.DateTimePicker.GetValue(), 'done_by': $("#user_id").val() },
|
Grocy.Api.Post('chores/' + jsonForm.chore_id + '/execute', { 'tracked_time': Grocy.Components.DateTimePicker.GetValue(), 'done_by': $("#user_id").val() },
|
||||||
function(result)
|
function(result)
|
||||||
@@ -110,7 +110,7 @@ Grocy.Components.DateTimePicker.GetInputElement().on('keypress', function(e)
|
|||||||
|
|
||||||
function UndoChoreExecution(executionId)
|
function UndoChoreExecution(executionId)
|
||||||
{
|
{
|
||||||
Grocy.Api.Post('chores/executions/' + executionId.toString() + '/undo', { },
|
Grocy.Api.Post('chores/executions/' + executionId.toString() + '/undo', {},
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
toastr.success(__t("Chore execution successfully undone"));
|
toastr.success(__t("Chore execution successfully undone"));
|
||||||
|
@@ -1,18 +1,20 @@
|
|||||||
Grocy.Components.BarcodeScanner = { };
|
Grocy.Components.BarcodeScanner = {};
|
||||||
|
|
||||||
Grocy.Components.BarcodeScanner.LiveVideoSizeAdjusted = false;
|
Grocy.Components.BarcodeScanner.LiveVideoSizeAdjusted = false;
|
||||||
Grocy.Components.BarcodeScanner.CheckCapabilities = async function()
|
Grocy.Components.BarcodeScanner.CheckCapabilities = async function()
|
||||||
{
|
{
|
||||||
var track = Quagga.CameraAccess.getActiveTrack();
|
var track = Quagga.CameraAccess.getActiveTrack();
|
||||||
var capabilities = {};
|
var capabilities = {};
|
||||||
if (typeof track.getCapabilities === 'function') {
|
if (typeof track.getCapabilities === 'function')
|
||||||
|
{
|
||||||
capabilities = track.getCapabilities();
|
capabilities = track.getCapabilities();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is more than 1 camera, show the camera selection
|
// If there is more than 1 camera, show the camera selection
|
||||||
var cameras = await Quagga.CameraAccess.enumerateVideoDevices();
|
var cameras = await Quagga.CameraAccess.enumerateVideoDevices();
|
||||||
var cameraSelect = document.querySelector('.cameraSelect-wrapper');
|
var cameraSelect = document.querySelector('.cameraSelect-wrapper');
|
||||||
if (cameraSelect) {
|
if (cameraSelect)
|
||||||
|
{
|
||||||
cameraSelect.style.display = cameras.length > 1 ? 'inline-block' : 'none';
|
cameraSelect.style.display = cameras.length > 1 ? 'inline-block' : 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,11 +22,13 @@ Grocy.Components.BarcodeScanner.CheckCapabilities = async function()
|
|||||||
var canTorch = typeof capabilities.torch === 'boolean' && capabilities.torch
|
var canTorch = typeof capabilities.torch === 'boolean' && capabilities.torch
|
||||||
// Remove the torch button, if either the device can not torch or AutoTorchOn is set.
|
// Remove the torch button, if either the device can not torch or AutoTorchOn is set.
|
||||||
var node = document.querySelector('.torch');
|
var node = document.querySelector('.torch');
|
||||||
if (node) {
|
if (node)
|
||||||
|
{
|
||||||
node.style.display = canTorch && !Grocy.FeatureFlags.GROCY_FEATURE_FLAG_AUTO_TORCH_ON_WITH_CAMERA ? 'inline-block' : 'none';
|
node.style.display = canTorch && !Grocy.FeatureFlags.GROCY_FEATURE_FLAG_AUTO_TORCH_ON_WITH_CAMERA ? 'inline-block' : 'none';
|
||||||
}
|
}
|
||||||
// If AutoTorchOn is set, turn on the torch.
|
// If AutoTorchOn is set, turn on the torch.
|
||||||
if (canTorch && Grocy.FeatureFlags.GROCY_FEATURE_FLAG_AUTO_TORCH_ON_WITH_CAMERA) {
|
if (canTorch && Grocy.FeatureFlags.GROCY_FEATURE_FLAG_AUTO_TORCH_ON_WITH_CAMERA)
|
||||||
|
{
|
||||||
Grocy.Components.BarcodeScanner.TorchOn(track);
|
Grocy.Components.BarcodeScanner.TorchOn(track);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +69,7 @@ Grocy.Components.BarcodeScanner.StartScanning = function()
|
|||||||
target: document.querySelector("#barcodescanner-livestream"),
|
target: document.querySelector("#barcodescanner-livestream"),
|
||||||
constraints: {
|
constraints: {
|
||||||
facingMode: "environment",
|
facingMode: "environment",
|
||||||
...(window.localStorage.getItem('cameraId') && {deviceId : window.localStorage.getItem('cameraId')}) // If preferred cameraId is set, request to use that specific camera
|
...(window.localStorage.getItem('cameraId') && { deviceId: window.localStorage.getItem('cameraId') }) // If preferred cameraId is set, request to use that specific camera
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
locator: {
|
locator: {
|
||||||
@@ -142,7 +146,8 @@ Grocy.Components.BarcodeScanner.StopScanning = function()
|
|||||||
|
|
||||||
Grocy.Components.BarcodeScanner.TorchOn = function(track)
|
Grocy.Components.BarcodeScanner.TorchOn = function(track)
|
||||||
{
|
{
|
||||||
if (track) {
|
if (track)
|
||||||
|
{
|
||||||
track.applyConstraints({
|
track.applyConstraints({
|
||||||
advanced: [
|
advanced: [
|
||||||
{
|
{
|
||||||
@@ -233,7 +238,7 @@ $(document).on("click", "#barcodescanner-start-button", async function(e)
|
|||||||
{
|
{
|
||||||
Grocy.Components.BarcodeScanner.TorchOn(Quagga.CameraAccess.getActiveTrack());
|
Grocy.Components.BarcodeScanner.TorchOn(Quagga.CameraAccess.getActiveTrack());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
cancel: {
|
cancel: {
|
||||||
label: __t('Cancel'),
|
label: __t('Cancel'),
|
||||||
@@ -251,7 +256,8 @@ $(document).on("click", "#barcodescanner-start-button", async function(e)
|
|||||||
var cameraSelect = document.querySelector('.cameraSelect');
|
var cameraSelect = document.querySelector('.cameraSelect');
|
||||||
|
|
||||||
var cameras = await Quagga.CameraAccess.enumerateVideoDevices();
|
var cameras = await Quagga.CameraAccess.enumerateVideoDevices();
|
||||||
cameras.forEach(camera => {
|
cameras.forEach(camera =>
|
||||||
|
{
|
||||||
var option = document.createElement("option");
|
var option = document.createElement("option");
|
||||||
option.text = camera.label ? camera.label : camera.deviceId; // Use camera label if it exists, else show device id
|
option.text = camera.label ? camera.label : camera.deviceId; // Use camera label if it exists, else show device id
|
||||||
option.value = camera.deviceId;
|
option.value = camera.deviceId;
|
||||||
@@ -261,7 +267,8 @@ $(document).on("click", "#barcodescanner-start-button", async function(e)
|
|||||||
// Set initial value to preferred camera if one exists - and if not, start out empty
|
// Set initial value to preferred camera if one exists - and if not, start out empty
|
||||||
cameraSelect.value = window.localStorage.getItem('cameraId');
|
cameraSelect.value = window.localStorage.getItem('cameraId');
|
||||||
|
|
||||||
cameraSelect.onchange = function(){
|
cameraSelect.onchange = function()
|
||||||
|
{
|
||||||
window.localStorage.setItem('cameraId', cameraSelect.value);
|
window.localStorage.setItem('cameraId', cameraSelect.value);
|
||||||
Quagga.stop();
|
Quagga.stop();
|
||||||
Grocy.Components.BarcodeScanner.StartScanning();
|
Grocy.Components.BarcodeScanner.StartScanning();
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
Grocy.Components.BatteryCard = { };
|
Grocy.Components.BatteryCard = {};
|
||||||
|
|
||||||
Grocy.Components.BatteryCard.Refresh = function(batteryId)
|
Grocy.Components.BatteryCard.Refresh = function(batteryId)
|
||||||
{
|
{
|
||||||
|
@@ -1,40 +1,40 @@
|
|||||||
$('#calendar').datetimepicker(
|
$('#calendar').datetimepicker(
|
||||||
{
|
{
|
||||||
format: 'L',
|
format: 'L',
|
||||||
buttons: {
|
buttons: {
|
||||||
showToday: true,
|
showToday: true,
|
||||||
showClose: false
|
showClose: false
|
||||||
},
|
},
|
||||||
calendarWeeks: true,
|
calendarWeeks: true,
|
||||||
locale: moment.locale(),
|
locale: moment.locale(),
|
||||||
icons: {
|
icons: {
|
||||||
time: 'far fa-clock',
|
time: 'far fa-clock',
|
||||||
date: 'far fa-calendar',
|
date: 'far fa-calendar',
|
||||||
up: 'fas fa-arrow-up',
|
up: 'fas fa-arrow-up',
|
||||||
down: 'fas fa-arrow-down',
|
down: 'fas fa-arrow-down',
|
||||||
previous: 'fas fa-chevron-left',
|
previous: 'fas fa-chevron-left',
|
||||||
next: 'fas fa-chevron-right',
|
next: 'fas fa-chevron-right',
|
||||||
today: 'fas fa-calendar-check',
|
today: 'fas fa-calendar-check',
|
||||||
clear: 'far fa-trash-alt',
|
clear: 'far fa-trash-alt',
|
||||||
close: 'far fa-times-circle'
|
close: 'far fa-times-circle'
|
||||||
},
|
},
|
||||||
keepOpen: true,
|
keepOpen: true,
|
||||||
inline: true,
|
inline: true,
|
||||||
keyBinds: {
|
keyBinds: {
|
||||||
up: function(widget) { },
|
up: function(widget) { },
|
||||||
down: function(widget) { },
|
down: function(widget) { },
|
||||||
'control up': function(widget) { },
|
'control up': function(widget) { },
|
||||||
'control down': function(widget) { },
|
'control down': function(widget) { },
|
||||||
left: function(widget) { },
|
left: function(widget) { },
|
||||||
right: function(widget) { },
|
right: function(widget) { },
|
||||||
pageUp: function(widget) { },
|
pageUp: function(widget) { },
|
||||||
pageDown: function(widget) { },
|
pageDown: function(widget) { },
|
||||||
enter: function(widget) { },
|
enter: function(widget) { },
|
||||||
escape: function(widget) { },
|
escape: function(widget) { },
|
||||||
'control space': function(widget) { },
|
'control space': function(widget) { },
|
||||||
t: function(widget) { },
|
t: function(widget) { },
|
||||||
'delete': function(widget) { }
|
'delete': function(widget) { }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#calendar').datetimepicker('show');
|
$('#calendar').datetimepicker('show');
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
Grocy.Components.ChoreCard = { };
|
Grocy.Components.ChoreCard = {};
|
||||||
|
|
||||||
Grocy.Components.ChoreCard.Refresh = function(choreId)
|
Grocy.Components.ChoreCard.Refresh = function(choreId)
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
Grocy.Components.DateTimePicker = { };
|
Grocy.Components.DateTimePicker = {};
|
||||||
|
|
||||||
Grocy.Components.DateTimePicker.GetInputElement = function()
|
Grocy.Components.DateTimePicker.GetInputElement = function()
|
||||||
{
|
{
|
||||||
@@ -80,45 +80,45 @@ if (Grocy.Components.DateTimePicker.GetInputElement().data('limit-end-to-now') =
|
|||||||
Grocy.Components.DateTimePicker.Init = function()
|
Grocy.Components.DateTimePicker.Init = function()
|
||||||
{
|
{
|
||||||
$('.datetimepicker').datetimepicker(
|
$('.datetimepicker').datetimepicker(
|
||||||
{
|
{
|
||||||
format: Grocy.Components.DateTimePicker.GetInputElement().data('format'),
|
format: Grocy.Components.DateTimePicker.GetInputElement().data('format'),
|
||||||
buttons: {
|
buttons: {
|
||||||
showToday: true,
|
showToday: true,
|
||||||
showClose: true
|
showClose: true
|
||||||
},
|
},
|
||||||
calendarWeeks: Grocy.CalendarShowWeekNumbers,
|
calendarWeeks: Grocy.CalendarShowWeekNumbers,
|
||||||
maxDate: limitDate,
|
maxDate: limitDate,
|
||||||
locale: moment.locale(),
|
locale: moment.locale(),
|
||||||
defaultDate: startDate,
|
defaultDate: startDate,
|
||||||
useCurrent: false,
|
useCurrent: false,
|
||||||
icons: {
|
icons: {
|
||||||
time: 'far fa-clock',
|
time: 'far fa-clock',
|
||||||
date: 'far fa-calendar',
|
date: 'far fa-calendar',
|
||||||
up: 'fas fa-arrow-up',
|
up: 'fas fa-arrow-up',
|
||||||
down: 'fas fa-arrow-down',
|
down: 'fas fa-arrow-down',
|
||||||
previous: 'fas fa-chevron-left',
|
previous: 'fas fa-chevron-left',
|
||||||
next: 'fas fa-chevron-right',
|
next: 'fas fa-chevron-right',
|
||||||
today: 'fas fa-calendar-check',
|
today: 'fas fa-calendar-check',
|
||||||
clear: 'far fa-trash-alt',
|
clear: 'far fa-trash-alt',
|
||||||
close: 'far fa-times-circle'
|
close: 'far fa-times-circle'
|
||||||
},
|
},
|
||||||
sideBySide: true,
|
sideBySide: true,
|
||||||
keyBinds: {
|
keyBinds: {
|
||||||
up: function(widget) { },
|
up: function(widget) { },
|
||||||
down: function(widget) { },
|
down: function(widget) { },
|
||||||
'control up': function(widget) { },
|
'control up': function(widget) { },
|
||||||
'control down': function(widget) { },
|
'control down': function(widget) { },
|
||||||
left: function(widget) { },
|
left: function(widget) { },
|
||||||
right: function(widget) { },
|
right: function(widget) { },
|
||||||
pageUp: function(widget) { },
|
pageUp: function(widget) { },
|
||||||
pageDown: function(widget) { },
|
pageDown: function(widget) { },
|
||||||
enter: function(widget) { },
|
enter: function(widget) { },
|
||||||
escape: function(widget) { },
|
escape: function(widget) { },
|
||||||
'control space': function(widget) { },
|
'control space': function(widget) { },
|
||||||
t: function(widget) { },
|
t: function(widget) { },
|
||||||
'delete': function(widget) { }
|
'delete': function(widget) { }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Grocy.Components.DateTimePicker.Init();
|
Grocy.Components.DateTimePicker.Init();
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
Grocy.Components.DateTimePicker2 = { };
|
Grocy.Components.DateTimePicker2 = {};
|
||||||
|
|
||||||
Grocy.Components.DateTimePicker2.GetInputElement = function()
|
Grocy.Components.DateTimePicker2.GetInputElement = function()
|
||||||
{
|
{
|
||||||
@@ -80,45 +80,45 @@ if (Grocy.Components.DateTimePicker2.GetInputElement().data('limit-end-to-now')
|
|||||||
Grocy.Components.DateTimePicker2.Init = function()
|
Grocy.Components.DateTimePicker2.Init = function()
|
||||||
{
|
{
|
||||||
$('.datetimepicker2').datetimepicker(
|
$('.datetimepicker2').datetimepicker(
|
||||||
{
|
{
|
||||||
format: Grocy.Components.DateTimePicker2.GetInputElement().data('format'),
|
format: Grocy.Components.DateTimePicker2.GetInputElement().data('format'),
|
||||||
buttons: {
|
buttons: {
|
||||||
showToday: true,
|
showToday: true,
|
||||||
showClose: true
|
showClose: true
|
||||||
},
|
},
|
||||||
calendarWeeks: Grocy.CalendarShowWeekNumbers,
|
calendarWeeks: Grocy.CalendarShowWeekNumbers,
|
||||||
maxDate: limitDate,
|
maxDate: limitDate,
|
||||||
locale: moment.locale(),
|
locale: moment.locale(),
|
||||||
defaultDate: startDate,
|
defaultDate: startDate,
|
||||||
useCurrent: false,
|
useCurrent: false,
|
||||||
icons: {
|
icons: {
|
||||||
time: 'far fa-clock',
|
time: 'far fa-clock',
|
||||||
date: 'far fa-calendar',
|
date: 'far fa-calendar',
|
||||||
up: 'fas fa-arrow-up',
|
up: 'fas fa-arrow-up',
|
||||||
down: 'fas fa-arrow-down',
|
down: 'fas fa-arrow-down',
|
||||||
previous: 'fas fa-chevron-left',
|
previous: 'fas fa-chevron-left',
|
||||||
next: 'fas fa-chevron-right',
|
next: 'fas fa-chevron-right',
|
||||||
today: 'fas fa-calendar-check',
|
today: 'fas fa-calendar-check',
|
||||||
clear: 'far fa-trash-alt',
|
clear: 'far fa-trash-alt',
|
||||||
close: 'far fa-times-circle'
|
close: 'far fa-times-circle'
|
||||||
},
|
},
|
||||||
sideBySide: true,
|
sideBySide: true,
|
||||||
keyBinds: {
|
keyBinds: {
|
||||||
up: function(widget) { },
|
up: function(widget) { },
|
||||||
down: function(widget) { },
|
down: function(widget) { },
|
||||||
'control up': function(widget) { },
|
'control up': function(widget) { },
|
||||||
'control down': function(widget) { },
|
'control down': function(widget) { },
|
||||||
left: function(widget) { },
|
left: function(widget) { },
|
||||||
right: function(widget) { },
|
right: function(widget) { },
|
||||||
pageUp: function(widget) { },
|
pageUp: function(widget) { },
|
||||||
pageDown: function(widget) { },
|
pageDown: function(widget) { },
|
||||||
enter: function(widget) { },
|
enter: function(widget) { },
|
||||||
escape: function(widget) { },
|
escape: function(widget) { },
|
||||||
'control space': function(widget) { },
|
'control space': function(widget) { },
|
||||||
t: function(widget) { },
|
t: function(widget) { },
|
||||||
'delete': function(widget) { }
|
'delete': function(widget) { }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Grocy.Components.DateTimePicker2.Init();
|
Grocy.Components.DateTimePicker2.Init();
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
Grocy.Components.LocationPicker = { };
|
Grocy.Components.LocationPicker = {};
|
||||||
|
|
||||||
Grocy.Components.LocationPicker.GetPicker = function()
|
Grocy.Components.LocationPicker.GetPicker = function()
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
$(".numberpicker-down-button").unbind('click').on("click", function ()
|
$(".numberpicker-down-button").unbind('click').on("click", function()
|
||||||
{
|
{
|
||||||
var inputElement = $(this).parent().parent().find('input[type="number"]')[0];
|
var inputElement = $(this).parent().parent().find('input[type="number"]')[0];
|
||||||
inputElement.stepDown();
|
inputElement.stepDown();
|
||||||
|
@@ -83,7 +83,7 @@ $(".input-group-productamountpicker").on("change", function()
|
|||||||
$("#qu-conversion-info").text(__t("This equals %1$s %2$s in stock", destinationAmount.toLocaleString(), destinationQuName));
|
$("#qu-conversion-info").text(__t("This equals %1$s %2$s in stock", destinationAmount.toLocaleString(), destinationQuName));
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#amount").val(destinationAmount.toFixed(4).replace(/0*$/g,''));
|
$("#amount").val(destinationAmount.toFixed(4).replace(/0*$/g, ''));
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#display_amount").on("keyup", function()
|
$("#display_amount").on("keyup", function()
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
Grocy.Components.ProductCard = { };
|
Grocy.Components.ProductCard = {};
|
||||||
|
|
||||||
Grocy.Components.ProductCard.Refresh = function(productId)
|
Grocy.Components.ProductCard.Refresh = function(productId)
|
||||||
{
|
{
|
||||||
@@ -95,7 +95,7 @@ Grocy.Components.ProductCard.Refresh = function(productId)
|
|||||||
{
|
{
|
||||||
if (productDetails.last_qu_factor_purchase_to_stock > 1)
|
if (productDetails.last_qu_factor_purchase_to_stock > 1)
|
||||||
{
|
{
|
||||||
$('#productcard-product-last-price').text(Number.parseFloat(productDetails.last_price).toLocaleString() + ' ' + Grocy.Currency + ' per 1 ' + productDetails.quantity_unit_purchase.name + ' of ' + productDetails.last_qu_factor_purchase_to_stock + ' ' + productDetails.quantity_unit_stock.name_plural);
|
$('#productcard-product-last-price').text(Number.parseFloat(productDetails.last_price).toLocaleString() + ' ' + Grocy.Currency + ' per 1 ' + productDetails.quantity_unit_purchase.name + ' of ' + productDetails.last_qu_factor_purchase_to_stock + ' ' + productDetails.quantity_unit_stock.name_plural);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -157,14 +157,16 @@ Grocy.Components.ProductCard.Refresh = function(productId)
|
|||||||
key = dataPoint.shopping_location.name
|
key = dataPoint.shopping_location.name
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!datasets[key]) {
|
if (!datasets[key])
|
||||||
|
{
|
||||||
datasets[key] = []
|
datasets[key] = []
|
||||||
}
|
}
|
||||||
chart.labels.push(moment(dataPoint.date).toDate());
|
chart.labels.push(moment(dataPoint.date).toDate());
|
||||||
datasets[key].push(dataPoint.price);
|
datasets[key].push(dataPoint.price);
|
||||||
|
|
||||||
});
|
});
|
||||||
Object.keys(datasets).forEach((key) => {
|
Object.keys(datasets).forEach((key) =>
|
||||||
|
{
|
||||||
chart.datasets.push({
|
chart.datasets.push({
|
||||||
data: datasets[key],
|
data: datasets[key],
|
||||||
fill: false,
|
fill: false,
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
Grocy.Components.ProductPicker = { };
|
Grocy.Components.ProductPicker = {};
|
||||||
|
|
||||||
Grocy.Components.ProductPicker.GetPicker = function()
|
Grocy.Components.ProductPicker.GetPicker = function()
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
Grocy.Components.RecipePicker = { };
|
Grocy.Components.RecipePicker = {};
|
||||||
|
|
||||||
Grocy.Components.RecipePicker.GetPicker = function()
|
Grocy.Components.RecipePicker.GetPicker = function()
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
Grocy.Components.ShoppingLocationPicker = { };
|
Grocy.Components.ShoppingLocationPicker = {};
|
||||||
|
|
||||||
Grocy.Components.ShoppingLocationPicker.GetPicker = function()
|
Grocy.Components.ShoppingLocationPicker.GetPicker = function()
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
Grocy.Components.UserfieldsForm = { };
|
Grocy.Components.UserfieldsForm = {};
|
||||||
|
|
||||||
Grocy.Components.UserfieldsForm.Save = function(success, error)
|
Grocy.Components.UserfieldsForm.Save = function(success, error)
|
||||||
{
|
{
|
||||||
@@ -12,7 +12,7 @@ Grocy.Components.UserfieldsForm.Save = function(success, error)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var jsonData = { };
|
var jsonData = {};
|
||||||
|
|
||||||
$("#userfields-form .userfield-input").not("div").each(function()
|
$("#userfields-form .userfield-input").not("div").each(function()
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
Grocy.Components.UserPicker = { };
|
Grocy.Components.UserPicker = {};
|
||||||
|
|
||||||
Grocy.Components.UserPicker.GetPicker = function()
|
Grocy.Components.UserPicker.GetPicker = function()
|
||||||
{
|
{
|
||||||
|
@@ -47,14 +47,14 @@
|
|||||||
var jsonDataBarcode = {};
|
var jsonDataBarcode = {};
|
||||||
jsonDataBarcode.barcode = addBarcode;
|
jsonDataBarcode.barcode = addBarcode;
|
||||||
jsonDataBarcode.product_id = jsonForm.product_id;
|
jsonDataBarcode.product_id = jsonForm.product_id;
|
||||||
jsonDataBarcode.qu_factor_purchase_to_stock = productDetails.product.qu_factor_purchase_to_stock;
|
jsonDataBarcode.qu_factor_purchase_to_stock = productDetails.product.qu_factor_purchase_to_stock;
|
||||||
|
|
||||||
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
|
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
$("#flow-info-addbarcodetoselection").addClass("d-none");
|
$("#flow-info-addbarcodetoselection").addClass("d-none");
|
||||||
$('#barcode-lookup-disabled-hint').addClass('d-none');
|
$('#barcode-lookup-disabled-hint').addClass('d-none');
|
||||||
window.history.replaceState({ }, document.title, U("/consume"));
|
window.history.replaceState({}, document.title, U("/consume"));
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
@@ -135,7 +135,7 @@ $('#save-mark-as-open-button').on('click', function(e)
|
|||||||
|
|
||||||
var apiUrl = 'stock/products/' + jsonForm.product_id + '/open';
|
var apiUrl = 'stock/products/' + jsonForm.product_id + '/open';
|
||||||
|
|
||||||
jsonData = { };
|
jsonData = {};
|
||||||
jsonData.amount = jsonForm.amount;
|
jsonData.amount = jsonForm.amount;
|
||||||
|
|
||||||
if ($("#use_specific_stock_entry").is(":checked"))
|
if ($("#use_specific_stock_entry").is(":checked"))
|
||||||
@@ -187,12 +187,12 @@ $("#location_id").on('change', function(e)
|
|||||||
$("#specific_stock_entry").find("option").remove().end().append("<option></option>");
|
$("#specific_stock_entry").find("option").remove().end().append("<option></option>");
|
||||||
if ($("#use_specific_stock_entry").is(":checked"))
|
if ($("#use_specific_stock_entry").is(":checked"))
|
||||||
{
|
{
|
||||||
$("#use_specific_stock_entry").click();
|
$("#use_specific_stock_entry").click();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
stockId = GetUriParam('stockId');
|
stockId = GetUriParam('stockId');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (locationId)
|
if (locationId)
|
||||||
@@ -260,7 +260,7 @@ $("#location_id").on('change', function(e)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
function (xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
console.error(xhr);
|
console.error(xhr);
|
||||||
}
|
}
|
||||||
@@ -268,7 +268,7 @@ $("#location_id").on('change', function(e)
|
|||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
console.error(xhr);
|
console.error(xhr);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -447,7 +447,7 @@ $("#specific_stock_entry").on("change", function(e)
|
|||||||
{
|
{
|
||||||
if ($(e.target).val() == "")
|
if ($(e.target).val() == "")
|
||||||
{
|
{
|
||||||
var sumValue = 0;
|
var sumValue = 0;
|
||||||
Grocy.Api.Get("stock/products/" + Grocy.Components.ProductPicker.GetValue() + '/entries',
|
Grocy.Api.Get("stock/products/" + Grocy.Components.ProductPicker.GetValue() + '/entries',
|
||||||
function(stockEntries)
|
function(stockEntries)
|
||||||
{
|
{
|
||||||
@@ -503,7 +503,7 @@ $("#use_specific_stock_entry").on("change", function()
|
|||||||
|
|
||||||
function UndoStockBooking(bookingId)
|
function UndoStockBooking(bookingId)
|
||||||
{
|
{
|
||||||
Grocy.Api.Post('stock/bookings/' + bookingId.toString() + '/undo', { },
|
Grocy.Api.Post('stock/bookings/' + bookingId.toString() + '/undo', {},
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
toastr.success(__t("Booking successfully undone"));
|
toastr.success(__t("Booking successfully undone"));
|
||||||
@@ -517,12 +517,12 @@ function UndoStockBooking(bookingId)
|
|||||||
|
|
||||||
function UndoStockTransaction(transactionId)
|
function UndoStockTransaction(transactionId)
|
||||||
{
|
{
|
||||||
Grocy.Api.Post('stock/transactions/' + transactionId.toString() + '/undo', { },
|
Grocy.Api.Post('stock/transactions/' + transactionId.toString() + '/undo', {},
|
||||||
function (result)
|
function(result)
|
||||||
{
|
{
|
||||||
toastr.success(__t("Transaction successfully undone"));
|
toastr.success(__t("Transaction successfully undone"));
|
||||||
},
|
},
|
||||||
function (xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
console.error(xhr);
|
console.error(xhr);
|
||||||
}
|
}
|
||||||
|
@@ -66,7 +66,7 @@ $("#search").on("keyup", Delay(function()
|
|||||||
equipmentTable.search(value).draw();
|
equipmentTable.search(value).draw();
|
||||||
}, 200));
|
}, 200));
|
||||||
|
|
||||||
$(document).on('click', '.equipment-delete-button', function (e)
|
$(document).on('click', '.equipment-delete-button', function(e)
|
||||||
{
|
{
|
||||||
var objectName = $(e.currentTarget).attr('data-equipment-name');
|
var objectName = $(e.currentTarget).attr('data-equipment-name');
|
||||||
var objectId = $(e.currentTarget).attr('data-equipment-id');
|
var objectId = $(e.currentTarget).attr('data-equipment-id');
|
||||||
|
@@ -27,11 +27,11 @@
|
|||||||
if (jsonData.hasOwnProperty("instruction_manual_file_name") && !Grocy.DeleteInstructionManualOnSave)
|
if (jsonData.hasOwnProperty("instruction_manual_file_name") && !Grocy.DeleteInstructionManualOnSave)
|
||||||
{
|
{
|
||||||
Grocy.Api.UploadFile($("#instruction-manual")[0].files[0], 'equipmentmanuals', jsonData.instruction_manual_file_name,
|
Grocy.Api.UploadFile($("#instruction-manual")[0].files[0], 'equipmentmanuals', jsonData.instruction_manual_file_name,
|
||||||
function (result)
|
function(result)
|
||||||
{
|
{
|
||||||
window.location.href = U('/equipment');
|
window.location.href = U('/equipment');
|
||||||
},
|
},
|
||||||
function (xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
Grocy.FrontendHelpers.EndUiBusy("equipment-form");
|
Grocy.FrontendHelpers.EndUiBusy("equipment-form");
|
||||||
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
||||||
@@ -125,7 +125,7 @@ $('#equipment-form input').keydown(function(event)
|
|||||||
});
|
});
|
||||||
|
|
||||||
Grocy.DeleteInstructionManualOnSave = false;
|
Grocy.DeleteInstructionManualOnSave = false;
|
||||||
$('#delete-current-instruction-manual-button').on('click', function (e)
|
$('#delete-current-instruction-manual-button').on('click', function(e)
|
||||||
{
|
{
|
||||||
Grocy.DeleteInstructionManualOnSave = true;
|
Grocy.DeleteInstructionManualOnSave = true;
|
||||||
$("#current-equipment-instruction-manual").addClass("d-none");
|
$("#current-equipment-instruction-manual").addClass("d-none");
|
||||||
|
@@ -14,10 +14,11 @@
|
|||||||
price = parseFloat(jsonForm.price).toFixed(2);
|
price = parseFloat(jsonForm.price).toFixed(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
var jsonData = { };
|
var jsonData = {};
|
||||||
jsonData.new_amount = jsonForm.new_amount;
|
jsonData.new_amount = jsonForm.new_amount;
|
||||||
jsonData.best_before_date = Grocy.Components.DateTimePicker.GetValue();
|
jsonData.best_before_date = Grocy.Components.DateTimePicker.GetValue();
|
||||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) {
|
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
|
||||||
|
{
|
||||||
jsonData.shopping_location_id = Grocy.Components.ShoppingLocationPicker.GetValue();
|
jsonData.shopping_location_id = Grocy.Components.ShoppingLocationPicker.GetValue();
|
||||||
}
|
}
|
||||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)
|
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)
|
||||||
@@ -40,7 +41,7 @@
|
|||||||
var jsonDataBarcode = {};
|
var jsonDataBarcode = {};
|
||||||
jsonDataBarcode.barcode = addBarcode;
|
jsonDataBarcode.barcode = addBarcode;
|
||||||
jsonDataBarcode.product_id = jsonForm.product_id;
|
jsonDataBarcode.product_id = jsonForm.product_id;
|
||||||
jsonDataBarcode.qu_factor_purchase_to_stock = productDetails.product.qu_factor_purchase_to_stock;
|
jsonDataBarcode.qu_factor_purchase_to_stock = productDetails.product.qu_factor_purchase_to_stock;
|
||||||
jsonDataBarcode.shopping_location_id = jsonForm.shopping_location_id;
|
jsonDataBarcode.shopping_location_id = jsonForm.shopping_location_id;
|
||||||
|
|
||||||
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
|
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
|
||||||
@@ -48,7 +49,7 @@
|
|||||||
{
|
{
|
||||||
$("#flow-info-addbarcodetoselection").addClass("d-none");
|
$("#flow-info-addbarcodetoselection").addClass("d-none");
|
||||||
$('#barcode-lookup-disabled-hint').addClass('d-none');
|
$('#barcode-lookup-disabled-hint').addClass('d-none');
|
||||||
window.history.replaceState({ }, document.title, U("/inventory"));
|
window.history.replaceState({}, document.title, U("/inventory"));
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
@@ -84,7 +85,8 @@
|
|||||||
$('#price').val('');
|
$('#price').val('');
|
||||||
Grocy.Components.DateTimePicker.Clear();
|
Grocy.Components.DateTimePicker.Clear();
|
||||||
Grocy.Components.ProductPicker.SetValue('');
|
Grocy.Components.ProductPicker.SetValue('');
|
||||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) {
|
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
|
||||||
|
{
|
||||||
Grocy.Components.ShoppingLocationPicker.SetValue('');
|
Grocy.Components.ShoppingLocationPicker.SetValue('');
|
||||||
}
|
}
|
||||||
Grocy.Components.ProductPicker.GetInputElement().focus();
|
Grocy.Components.ProductPicker.GetInputElement().focus();
|
||||||
@@ -153,7 +155,8 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$('#price').val(parseFloat(productDetails.last_price).toLocaleString({ minimumFractionDigits: 2, maximumFractionDigits: 2 }));
|
$('#price').val(parseFloat(productDetails.last_price).toLocaleString({ minimumFractionDigits: 2, maximumFractionDigits: 2 }));
|
||||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) {
|
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
|
||||||
|
{
|
||||||
Grocy.Components.ShoppingLocationPicker.SetId(productDetails.last_shopping_location_id);
|
Grocy.Components.ShoppingLocationPicker.SetId(productDetails.last_shopping_location_id);
|
||||||
}
|
}
|
||||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)
|
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)
|
||||||
@@ -197,7 +200,7 @@ $('#new_amount').on('focus', function(e)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#inventory-form input').keyup(function (event)
|
$('#inventory-form input').keyup(function(event)
|
||||||
{
|
{
|
||||||
Grocy.FrontendHelpers.ValidateForm('inventory-form');
|
Grocy.FrontendHelpers.ValidateForm('inventory-form');
|
||||||
});
|
});
|
||||||
@@ -295,7 +298,7 @@ $('#new_amount').on('keyup', function(e)
|
|||||||
|
|
||||||
function UndoStockBooking(bookingId)
|
function UndoStockBooking(bookingId)
|
||||||
{
|
{
|
||||||
Grocy.Api.Post('stock/bookings/' + bookingId.toString() + '/undo', { },
|
Grocy.Api.Post('stock/bookings/' + bookingId.toString() + '/undo', {},
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
toastr.success(__t("Booking successfully undone"));
|
toastr.success(__t("Booking successfully undone"));
|
||||||
@@ -309,12 +312,12 @@ function UndoStockBooking(bookingId)
|
|||||||
|
|
||||||
function UndoStockTransaction(transactionId)
|
function UndoStockTransaction(transactionId)
|
||||||
{
|
{
|
||||||
Grocy.Api.Post('stock/transactions/' + transactionId.toString() + '/undo', { },
|
Grocy.Api.Post('stock/transactions/' + transactionId.toString() + '/undo', {},
|
||||||
function (result)
|
function(result)
|
||||||
{
|
{
|
||||||
toastr.success(__t("Transaction successfully undone"));
|
toastr.success(__t("Transaction successfully undone"));
|
||||||
},
|
},
|
||||||
function (xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
console.error(xhr);
|
console.error(xhr);
|
||||||
}
|
}
|
||||||
|
@@ -42,12 +42,12 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#location-form input').keyup(function (event)
|
$('#location-form input').keyup(function(event)
|
||||||
{
|
{
|
||||||
Grocy.FrontendHelpers.ValidateForm('location-form');
|
Grocy.FrontendHelpers.ValidateForm('location-form');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#location-form input').keydown(function (event)
|
$('#location-form input').keydown(function(event)
|
||||||
{
|
{
|
||||||
if (event.keyCode === 13) //Enter
|
if (event.keyCode === 13) //Enter
|
||||||
{
|
{
|
||||||
|
@@ -19,7 +19,7 @@ $("#search").on("keyup", Delay(function()
|
|||||||
locationsTable.search(value).draw();
|
locationsTable.search(value).draw();
|
||||||
}, 200));
|
}, 200));
|
||||||
|
|
||||||
$(document).on('click', '.location-delete-button', function (e)
|
$(document).on('click', '.location-delete-button', function(e)
|
||||||
{
|
{
|
||||||
var objectName = $(e.currentTarget).attr('data-location-name');
|
var objectName = $(e.currentTarget).attr('data-location-name');
|
||||||
var objectId = $(e.currentTarget).attr('data-location-id');
|
var objectId = $(e.currentTarget).attr('data-location-id');
|
||||||
|
@@ -25,7 +25,7 @@ $("#search").on("keyup", Delay(function()
|
|||||||
apiKeysTable.search(value).draw();
|
apiKeysTable.search(value).draw();
|
||||||
}, 200));
|
}, 200));
|
||||||
|
|
||||||
$(document).on('click', '.apikey-delete-button', function (e)
|
$(document).on('click', '.apikey-delete-button', function(e)
|
||||||
{
|
{
|
||||||
var objectName = $(e.currentTarget).attr('data-apikey-apikey');
|
var objectName = $(e.currentTarget).attr('data-apikey-apikey');
|
||||||
var objectId = $(e.currentTarget).attr('data-apikey-id');
|
var objectId = $(e.currentTarget).attr('data-apikey-id');
|
||||||
|
@@ -318,7 +318,7 @@ $(document).on("click", ".add-product-button", function(e)
|
|||||||
Grocy.IsMealPlanEntryEditAction = false;
|
Grocy.IsMealPlanEntryEditAction = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("click", ".edit-meal-plan-entry-button", function (e)
|
$(document).on("click", ".edit-meal-plan-entry-button", function(e)
|
||||||
{
|
{
|
||||||
var mealPlanEntry = JSON.parse($(this).parents(".fc-h-event:first").attr("data-meal-plan-entry"));
|
var mealPlanEntry = JSON.parse($(this).parents(".fc-h-event:first").attr("data-meal-plan-entry"));
|
||||||
|
|
||||||
@@ -357,12 +357,12 @@ $("#add-recipe-modal").on("shown.bs.modal", function(e)
|
|||||||
Grocy.Components.RecipePicker.GetInputElement().focus();
|
Grocy.Components.RecipePicker.GetInputElement().focus();
|
||||||
})
|
})
|
||||||
|
|
||||||
$("#add-note-modal").on("shown.bs.modal", function (e)
|
$("#add-note-modal").on("shown.bs.modal", function(e)
|
||||||
{
|
{
|
||||||
$("#note").focus();
|
$("#note").focus();
|
||||||
})
|
})
|
||||||
|
|
||||||
$("#add-product-modal").on("shown.bs.modal", function (e)
|
$("#add-product-modal").on("shown.bs.modal", function(e)
|
||||||
{
|
{
|
||||||
Grocy.Components.ProductPicker.GetInputElement().focus();
|
Grocy.Components.ProductPicker.GetInputElement().focus();
|
||||||
})
|
})
|
||||||
@@ -371,7 +371,7 @@ $(document).on("click", ".remove-recipe-button, .remove-note-button, .remove-pro
|
|||||||
{
|
{
|
||||||
var mealPlanEntry = JSON.parse($(this).parents(".fc-h-event:first").attr("data-meal-plan-entry"));
|
var mealPlanEntry = JSON.parse($(this).parents(".fc-h-event:first").attr("data-meal-plan-entry"));
|
||||||
|
|
||||||
Grocy.Api.Delete('objects/meal_plan/' + mealPlanEntry.id.toString(), { },
|
Grocy.Api.Delete('objects/meal_plan/' + mealPlanEntry.id.toString(), {},
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
@@ -481,11 +481,11 @@ $('#save-add-product-button').on('click', function(e)
|
|||||||
if (Grocy.IsMealPlanEntryEditAction)
|
if (Grocy.IsMealPlanEntryEditAction)
|
||||||
{
|
{
|
||||||
Grocy.Api.Put('objects/meal_plan/' + Grocy.MealPlanEntryEditObjectId.toString(), jsonData,
|
Grocy.Api.Put('objects/meal_plan/' + Grocy.MealPlanEntryEditObjectId.toString(), jsonData,
|
||||||
function (result)
|
function(result)
|
||||||
{
|
{
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
},
|
},
|
||||||
function (xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
||||||
}
|
}
|
||||||
@@ -506,7 +506,7 @@ $('#save-add-product-button').on('click', function(e)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#add-recipe-form input').keydown(function (event)
|
$('#add-recipe-form input').keydown(function(event)
|
||||||
{
|
{
|
||||||
if (event.keyCode === 13) //Enter
|
if (event.keyCode === 13) //Enter
|
||||||
{
|
{
|
||||||
@@ -523,7 +523,7 @@ $('#add-recipe-form input').keydown(function (event)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#add-product-form input').keydown(function (event)
|
$('#add-product-form input').keydown(function(event)
|
||||||
{
|
{
|
||||||
if (event.keyCode === 13) //Enter
|
if (event.keyCode === 13) //Enter
|
||||||
{
|
{
|
||||||
@@ -588,10 +588,10 @@ $(document).on('click', '.recipe-order-missing-button', function(e)
|
|||||||
Grocy.FrontendHelpers.BeginUiBusy();
|
Grocy.FrontendHelpers.BeginUiBusy();
|
||||||
|
|
||||||
// Set the recipes desired_servings so that the "recipes resolved"-views resolve correctly based on the meal plan entry servings
|
// Set the recipes desired_servings so that the "recipes resolved"-views resolve correctly based on the meal plan entry servings
|
||||||
Grocy.Api.Put('objects/recipes/' + objectId, { "desired_servings" : servings},
|
Grocy.Api.Put('objects/recipes/' + objectId, { "desired_servings": servings },
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
Grocy.Api.Post('recipes/' + objectId + '/add-not-fulfilled-products-to-shoppinglist', { },
|
Grocy.Api.Post('recipes/' + objectId + '/add-not-fulfilled-products-to-shoppinglist', {},
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
if (button.attr("data-recipe-type") == "normal")
|
if (button.attr("data-recipe-type") == "normal")
|
||||||
@@ -634,11 +634,11 @@ $(document).on('click', '.product-consume-button', function(e)
|
|||||||
var productId = $(e.currentTarget).attr('data-product-id');
|
var productId = $(e.currentTarget).attr('data-product-id');
|
||||||
var consumeAmount = parseFloat($(e.currentTarget).attr('data-product-amount'));
|
var consumeAmount = parseFloat($(e.currentTarget).attr('data-product-amount'));
|
||||||
|
|
||||||
Grocy.Api.Post('stock/products/' + productId + '/consume', { 'amount': consumeAmount, 'spoiled': false },
|
Grocy.Api.Post('stock/products/' + productId + '/consume', { 'amount': consumeAmount, 'spoiled': false },
|
||||||
function(bookingResponse)
|
function(bookingResponse)
|
||||||
{
|
{
|
||||||
Grocy.Api.Get('stock/products/' + productId,
|
Grocy.Api.Get('stock/products/' + productId,
|
||||||
function (result)
|
function(result)
|
||||||
{
|
{
|
||||||
var toastMessage = __t('Removed %1$s of %2$s from stock', consumeAmount.toString() + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural), result.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse.transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
var toastMessage = __t('Removed %1$s of %2$s from stock', consumeAmount.toString() + " " + __n(consumeAmount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural), result.product.name) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse.transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||||
|
|
||||||
@@ -741,7 +741,7 @@ $(document).on("click", ".recipe-popup-button", function(e)
|
|||||||
cancel: {
|
cancel: {
|
||||||
label: __t('Close'),
|
label: __t('Close'),
|
||||||
className: 'btn-secondary responsive-button',
|
className: 'btn-secondary responsive-button',
|
||||||
callback: function ()
|
callback: function()
|
||||||
{
|
{
|
||||||
bootbox.hideAll();
|
bootbox.hideAll();
|
||||||
}
|
}
|
||||||
@@ -797,12 +797,12 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
|||||||
|
|
||||||
function UndoStockTransaction(transactionId)
|
function UndoStockTransaction(transactionId)
|
||||||
{
|
{
|
||||||
Grocy.Api.Post('stock/transactions/' + transactionId.toString() + '/undo', { },
|
Grocy.Api.Post('stock/transactions/' + transactionId.toString() + '/undo', {},
|
||||||
function (result)
|
function(result)
|
||||||
{
|
{
|
||||||
toastr.success(__t("Transaction successfully undone"));
|
toastr.success(__t("Transaction successfully undone"));
|
||||||
},
|
},
|
||||||
function (xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
console.error(xhr);
|
console.error(xhr);
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
components: {
|
components: {
|
||||||
Topbar: function () { return null }
|
Topbar: function() { return null }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -48,7 +48,7 @@
|
|||||||
var jsonDataBarcode = {};
|
var jsonDataBarcode = {};
|
||||||
jsonDataBarcode.barcode = prefillBarcode;
|
jsonDataBarcode.barcode = prefillBarcode;
|
||||||
jsonDataBarcode.product_id = result.created_object_id;
|
jsonDataBarcode.product_id = result.created_object_id;
|
||||||
jsonDataBarcode.qu_factor_purchase_to_stock = jsonData.qu_factor_purchase_to_stock;
|
jsonDataBarcode.qu_factor_purchase_to_stock = jsonData.qu_factor_purchase_to_stock;
|
||||||
jsonDataBarcode.shopping_location_id = jsonData.shopping_location_id;
|
jsonDataBarcode.shopping_location_id = jsonData.shopping_location_id;
|
||||||
|
|
||||||
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
|
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
|
||||||
@@ -82,7 +82,7 @@
|
|||||||
window.location.href = redirectDestination.replace("editobjectid", Grocy.EditObjectId);;
|
window.location.href = redirectDestination.replace("editobjectid", Grocy.EditObjectId);;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
function (xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
Grocy.FrontendHelpers.EndUiBusy("product-form");
|
Grocy.FrontendHelpers.EndUiBusy("product-form");
|
||||||
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
||||||
@@ -106,7 +106,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function (xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
Grocy.FrontendHelpers.EndUiBusy("product-form");
|
Grocy.FrontendHelpers.EndUiBusy("product-form");
|
||||||
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
||||||
@@ -343,7 +343,7 @@ $("#allow_partial_units_in_stock").on("click", function()
|
|||||||
});
|
});
|
||||||
|
|
||||||
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;
|
Grocy.DeleteProductPictureOnSave = true;
|
||||||
$("#current-product-picture").addClass("d-none");
|
$("#current-product-picture").addClass("d-none");
|
||||||
@@ -426,7 +426,7 @@ $(document).on('click', '.qu-conversion-delete-button', function(e)
|
|||||||
{
|
{
|
||||||
if (result === true)
|
if (result === true)
|
||||||
{
|
{
|
||||||
Grocy.Api.Delete('objects/quantity_unit_conversions/' + objectId, { },
|
Grocy.Api.Delete('objects/quantity_unit_conversions/' + objectId, {},
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
Grocy.ProductEditFormRedirectUri = "reload";
|
Grocy.ProductEditFormRedirectUri = "reload";
|
||||||
@@ -466,7 +466,7 @@ $(document).on('click', '.barcode-delete-button', function(e)
|
|||||||
{
|
{
|
||||||
if (result === true)
|
if (result === true)
|
||||||
{
|
{
|
||||||
Grocy.Api.Delete('objects/product_barcodes/' + objectId, { },
|
Grocy.Api.Delete('objects/product_barcodes/' + objectId, {},
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
Grocy.ProductEditFormRedirectUri = "reload";
|
Grocy.ProductEditFormRedirectUri = "reload";
|
||||||
@@ -487,7 +487,8 @@ $('#qu_id_purchase').blur(function(e)
|
|||||||
// Preset the stock quantity unit with the purchase quantity unit, if the stock quantity unit is unset.
|
// Preset the stock quantity unit with the purchase quantity unit, if the stock quantity unit is unset.
|
||||||
var QuIdStock = $('#qu_id_stock');
|
var QuIdStock = $('#qu_id_stock');
|
||||||
var QuIdPurchase = $('#qu_id_purchase');
|
var QuIdPurchase = $('#qu_id_purchase');
|
||||||
if (QuIdStock[0].selectedIndex === 0 && QuIdPurchase[0].selectedIndex !== 0) {
|
if (QuIdStock[0].selectedIndex === 0 && QuIdPurchase[0].selectedIndex !== 0)
|
||||||
|
{
|
||||||
QuIdStock[0].selectedIndex = QuIdPurchase[0].selectedIndex;
|
QuIdStock[0].selectedIndex = QuIdPurchase[0].selectedIndex;
|
||||||
Grocy.FrontendHelpers.ValidateForm('product-form');
|
Grocy.FrontendHelpers.ValidateForm('product-form');
|
||||||
}
|
}
|
||||||
|
@@ -42,12 +42,12 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#product-group-form input').keyup(function (event)
|
$('#product-group-form input').keyup(function(event)
|
||||||
{
|
{
|
||||||
Grocy.FrontendHelpers.ValidateForm('product-group-form');
|
Grocy.FrontendHelpers.ValidateForm('product-group-form');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#product-group-form input').keydown(function (event)
|
$('#product-group-form input').keydown(function(event)
|
||||||
{
|
{
|
||||||
if (event.keyCode === 13) //Enter
|
if (event.keyCode === 13) //Enter
|
||||||
{
|
{
|
||||||
|
@@ -36,7 +36,7 @@ if (typeof GetUriParam("product-group") !== "undefined")
|
|||||||
$("#product-group-filter").trigger("change");
|
$("#product-group-filter").trigger("change");
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).on('click', '.product-delete-button', function (e)
|
$(document).on('click', '.product-delete-button', function(e)
|
||||||
{
|
{
|
||||||
var objectName = $(e.currentTarget).attr('data-product-name');
|
var objectName = $(e.currentTarget).attr('data-product-name');
|
||||||
var objectId = $(e.currentTarget).attr('data-product-id');
|
var objectId = $(e.currentTarget).attr('data-product-id');
|
||||||
@@ -61,18 +61,18 @@ $(document).on('click', '.product-delete-button', function (e)
|
|||||||
className: 'btn-danger'
|
className: 'btn-danger'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
callback: function (result)
|
callback: function(result)
|
||||||
{
|
{
|
||||||
if (result === true)
|
if (result === true)
|
||||||
{
|
{
|
||||||
jsonData = {};
|
jsonData = {};
|
||||||
jsonData.active = 0;
|
jsonData.active = 0;
|
||||||
Grocy.Api.Put('objects/products/' + objectId, jsonData,
|
Grocy.Api.Put('objects/products/' + objectId, jsonData,
|
||||||
function (result)
|
function(result)
|
||||||
{
|
{
|
||||||
window.location.href = U('/products');
|
window.location.href = U('/products');
|
||||||
},
|
},
|
||||||
function (xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
console.error(xhr);
|
console.error(xhr);
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,8 @@
|
|||||||
var jsonData = {};
|
var jsonData = {};
|
||||||
jsonData.amount = amount;
|
jsonData.amount = amount;
|
||||||
jsonData.best_before_date = Grocy.Components.DateTimePicker.GetValue();
|
jsonData.best_before_date = Grocy.Components.DateTimePicker.GetValue();
|
||||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) {
|
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
|
||||||
|
{
|
||||||
jsonData.shopping_location_id = Grocy.Components.ShoppingLocationPicker.GetValue();
|
jsonData.shopping_location_id = Grocy.Components.ShoppingLocationPicker.GetValue();
|
||||||
}
|
}
|
||||||
jsonData.price = price;
|
jsonData.price = price;
|
||||||
@@ -54,7 +55,7 @@
|
|||||||
var jsonDataBarcode = {};
|
var jsonDataBarcode = {};
|
||||||
jsonDataBarcode.barcode = addBarcode;
|
jsonDataBarcode.barcode = addBarcode;
|
||||||
jsonDataBarcode.product_id = jsonForm.product_id;
|
jsonDataBarcode.product_id = jsonForm.product_id;
|
||||||
jsonDataBarcode.qu_factor_purchase_to_stock = jsonForm.qu_factor_purchase_to_stock;
|
jsonDataBarcode.qu_factor_purchase_to_stock = jsonForm.qu_factor_purchase_to_stock;
|
||||||
jsonDataBarcode.shopping_location_id = jsonForm.shopping_location_id;
|
jsonDataBarcode.shopping_location_id = jsonForm.shopping_location_id;
|
||||||
|
|
||||||
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
|
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
|
||||||
@@ -62,7 +63,7 @@
|
|||||||
{
|
{
|
||||||
$("#flow-info-addbarcodetoselection").addClass("d-none");
|
$("#flow-info-addbarcodetoselection").addClass("d-none");
|
||||||
$('#barcode-lookup-disabled-hint').addClass('d-none');
|
$('#barcode-lookup-disabled-hint').addClass('d-none');
|
||||||
window.history.replaceState({ }, document.title, U("/purchase"));
|
window.history.replaceState({}, document.title, U("/purchase"));
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
@@ -100,7 +101,8 @@
|
|||||||
}
|
}
|
||||||
Grocy.Components.DateTimePicker.Clear();
|
Grocy.Components.DateTimePicker.Clear();
|
||||||
Grocy.Components.ProductPicker.SetValue('');
|
Grocy.Components.ProductPicker.SetValue('');
|
||||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) {
|
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
|
||||||
|
{
|
||||||
Grocy.Components.ShoppingLocationPicker.SetValue('');
|
Grocy.Components.ShoppingLocationPicker.SetValue('');
|
||||||
}
|
}
|
||||||
Grocy.Components.ProductPicker.GetInputElement().focus();
|
Grocy.Components.ProductPicker.GetInputElement().focus();
|
||||||
@@ -142,23 +144,23 @@ if (Grocy.Components.ProductPicker !== undefined)
|
|||||||
{
|
{
|
||||||
Grocy.Api.Get('productbarcodedetails/' + document.getElementById("product_id").getAttribute("barcode"),
|
Grocy.Api.Get('productbarcodedetails/' + document.getElementById("product_id").getAttribute("barcode"),
|
||||||
function(resultBarcode)
|
function(resultBarcode)
|
||||||
|
{
|
||||||
|
if (resultBarcode != null)
|
||||||
{
|
{
|
||||||
if (resultBarcode != null)
|
$('#product_id').attr("barcode-qu-factor-purchase-to-stock", resultBarcode.qu_factor_purchase_to_stock);
|
||||||
{
|
$('#product_id').attr("barcode-shopping-location-id", resultBarcode.shopping_location_id);
|
||||||
$('#product_id').attr("barcode-qu-factor-purchase-to-stock", resultBarcode.qu_factor_purchase_to_stock);
|
|
||||||
$('#product_id').attr("barcode-shopping-location-id", resultBarcode.shopping_location_id);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$('#product_id').attr("barcode-qu-factor-purchase-to-stock", "null");
|
|
||||||
$('#product_id').attr("barcode-shopping-location-id", "null");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function(xhr)
|
|
||||||
{
|
|
||||||
console.error(xhr);
|
|
||||||
}
|
}
|
||||||
);
|
else
|
||||||
|
{
|
||||||
|
$('#product_id').attr("barcode-qu-factor-purchase-to-stock", "null");
|
||||||
|
$('#product_id').attr("barcode-shopping-location-id", "null");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function(xhr)
|
||||||
|
{
|
||||||
|
console.error(xhr);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -184,15 +186,16 @@ if (Grocy.Components.ProductPicker !== undefined)
|
|||||||
{
|
{
|
||||||
if (productDetails.last_qu_factor_purchase_to_stock != null)
|
if (productDetails.last_qu_factor_purchase_to_stock != null)
|
||||||
{
|
{
|
||||||
qu_factor_purchase_to_stock = productDetails.last_qu_factor_purchase_to_stock;
|
qu_factor_purchase_to_stock = productDetails.last_qu_factor_purchase_to_stock;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qu_factor_purchase_to_stock = productDetails.product.qu_factor_purchase_to_stock;
|
qu_factor_purchase_to_stock = productDetails.product.qu_factor_purchase_to_stock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) {
|
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
|
||||||
|
{
|
||||||
if (barcode_shopping_location_id != null)
|
if (barcode_shopping_location_id != null)
|
||||||
{
|
{
|
||||||
Grocy.Components.ShoppingLocationPicker.SetId(barcode_shopping_location_id);
|
Grocy.Components.ShoppingLocationPicker.SetId(barcode_shopping_location_id);
|
||||||
@@ -401,7 +404,7 @@ $('#qu_factor_purchase_to_stock').on('change', function(e)
|
|||||||
{
|
{
|
||||||
var value = $(e.target).val();
|
var value = $(e.target).val();
|
||||||
$('#amount_qu_unit').attr("qu-factor-purchase-to-stock", value);
|
$('#amount_qu_unit').attr("qu-factor-purchase-to-stock", value);
|
||||||
$('#amount_qu_unit').text(document.getElementById("amount_qu_unit").getAttribute("quantity-unit-purchase-name") + " (" + __t("will be multiplied by a factor of %1$s to get %2$s", parseFloat(value).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: 2 }), __n(2, document.getElementById("amount_qu_unit").getAttribute("quantity-unit-stock-name"), document.getElementById("amount_qu_unit").getAttribute("quantity-unit-stock-name-plural")) + ")"));
|
$('#amount_qu_unit').text(document.getElementById("amount_qu_unit").getAttribute("quantity-unit-purchase-name") + " (" + __t("will be multiplied by a factor of %1$s to get %2$s", parseFloat(value).toLocaleString({ minimumFractionDigits: 0, maximumFractionDigits: 2 }), __n(2, document.getElementById("amount_qu_unit").getAttribute("quantity-unit-stock-name"), document.getElementById("amount_qu_unit").getAttribute("quantity-unit-stock-name-plural")) + ")"));
|
||||||
refreshPriceHint();
|
refreshPriceHint();
|
||||||
Grocy.FrontendHelpers.ValidateForm('purchase-form');
|
Grocy.FrontendHelpers.ValidateForm('purchase-form');
|
||||||
});
|
});
|
||||||
@@ -447,7 +450,7 @@ function refreshPriceHint()
|
|||||||
|
|
||||||
function UndoStockBooking(bookingId)
|
function UndoStockBooking(bookingId)
|
||||||
{
|
{
|
||||||
Grocy.Api.Post('stock/bookings/' + bookingId.toString() + '/undo', { },
|
Grocy.Api.Post('stock/bookings/' + bookingId.toString() + '/undo', {},
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
toastr.success(__t("Booking successfully undone"));
|
toastr.success(__t("Booking successfully undone"));
|
||||||
@@ -457,7 +460,7 @@ function UndoStockBooking(bookingId)
|
|||||||
{
|
{
|
||||||
window.postMessage(WindowMessageBag("ProductChanged", result.product_id), Grocy.BaseUrl);
|
window.postMessage(WindowMessageBag("ProductChanged", result.product_id), Grocy.BaseUrl);
|
||||||
},
|
},
|
||||||
function (xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
console.error(xhr);
|
console.error(xhr);
|
||||||
}
|
}
|
||||||
@@ -472,7 +475,7 @@ function UndoStockBooking(bookingId)
|
|||||||
|
|
||||||
function UndoStockTransaction(transactionId)
|
function UndoStockTransaction(transactionId)
|
||||||
{
|
{
|
||||||
Grocy.Api.Post('stock/transactions/' + transactionId.toString() + '/undo', { },
|
Grocy.Api.Post('stock/transactions/' + transactionId.toString() + '/undo', {},
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
toastr.success(__t("Transaction successfully undone"));
|
toastr.success(__t("Transaction successfully undone"));
|
||||||
@@ -482,7 +485,7 @@ function UndoStockTransaction(transactionId)
|
|||||||
{
|
{
|
||||||
window.postMessage(WindowMessageBag("ProductChanged", result[0].product_id), Grocy.BaseUrl);
|
window.postMessage(WindowMessageBag("ProductChanged", result[0].product_id), Grocy.BaseUrl);
|
||||||
},
|
},
|
||||||
function (xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
console.error(xhr);
|
console.error(xhr);
|
||||||
}
|
}
|
||||||
|
@@ -149,7 +149,7 @@ $(document).on('click', '.qu-conversion-delete-button', function(e)
|
|||||||
{
|
{
|
||||||
if (result === true)
|
if (result === true)
|
||||||
{
|
{
|
||||||
Grocy.Api.Delete('objects/quantity_unit_conversions/' + objectId, { },
|
Grocy.Api.Delete('objects/quantity_unit_conversions/' + objectId, {},
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
Grocy.QuantityUnitEditFormRedirectUri = "reload";
|
Grocy.QuantityUnitEditFormRedirectUri = "reload";
|
||||||
@@ -165,7 +165,7 @@ $(document).on('click', '.qu-conversion-delete-button', function(e)
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('click', '.qu-conversion-edit-button', function (e)
|
$(document).on('click', '.qu-conversion-edit-button', function(e)
|
||||||
{
|
{
|
||||||
var id = $(e.currentTarget).attr('data-qu-conversion-id');
|
var id = $(e.currentTarget).attr('data-qu-conversion-id');
|
||||||
Grocy.QuantityUnitEditFormRedirectUri = U("/quantityunitconversion/" + id.toString() + "?qu-unit=editobjectid");
|
Grocy.QuantityUnitEditFormRedirectUri = U("/quantityunitconversion/" + id.toString() + "?qu-unit=editobjectid");
|
||||||
|
@@ -19,7 +19,7 @@ $("#search").on("keyup", Delay(function()
|
|||||||
quantityUnitsTable.search(value).draw();
|
quantityUnitsTable.search(value).draw();
|
||||||
}, 200));
|
}, 200));
|
||||||
|
|
||||||
$(document).on('click', '.quantityunit-delete-button', function (e)
|
$(document).on('click', '.quantityunit-delete-button', function(e)
|
||||||
{
|
{
|
||||||
var objectName = $(e.currentTarget).attr('data-quantityunit-name');
|
var objectName = $(e.currentTarget).attr('data-quantityunit-name');
|
||||||
var objectId = $(e.currentTarget).attr('data-quantityunit-id');
|
var objectId = $(e.currentTarget).attr('data-quantityunit-id');
|
||||||
|
@@ -39,10 +39,11 @@ $('.save-recipe').on('click', function(e)
|
|||||||
|
|
||||||
const location = $(e.currentTarget).attr('data-location') == 'return' ? '/recipes?recipe=' : '/recipe/';
|
const location = $(e.currentTarget).attr('data-location') == 'return' ? '/recipes?recipe=' : '/recipe/';
|
||||||
|
|
||||||
if(Grocy.EditMode == 'create') {
|
if (Grocy.EditMode == 'create')
|
||||||
|
{
|
||||||
console.log(jsonData);
|
console.log(jsonData);
|
||||||
Grocy.Api.Post('objects/recipes', jsonData,
|
Grocy.Api.Post('objects/recipes', jsonData,
|
||||||
(result) => saveRecipePicture(result, location));
|
(result) => saveRecipePicture(result, location));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,11 +52,11 @@ $('.save-recipe').on('click', function(e)
|
|||||||
jsonData.picture_file_name = null;
|
jsonData.picture_file_name = null;
|
||||||
|
|
||||||
Grocy.Api.DeleteFile(Grocy.RecipePictureFileName, 'recipepictures', {},
|
Grocy.Api.DeleteFile(Grocy.RecipePictureFileName, 'recipepictures', {},
|
||||||
function (result)
|
function(result)
|
||||||
{
|
{
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
},
|
},
|
||||||
function (xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
Grocy.FrontendHelpers.EndUiBusy("recipe-form");
|
Grocy.FrontendHelpers.EndUiBusy("recipe-form");
|
||||||
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
||||||
@@ -106,7 +107,7 @@ $('#recipe-form input').keyup(function(event)
|
|||||||
Grocy.FrontendHelpers.ValidateForm('recipe-form');
|
Grocy.FrontendHelpers.ValidateForm('recipe-form');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#recipe-form input').keydown(function (event)
|
$('#recipe-form input').keydown(function(event)
|
||||||
{
|
{
|
||||||
if (event.keyCode === 13) //Enter
|
if (event.keyCode === 13) //Enter
|
||||||
{
|
{
|
||||||
@@ -212,7 +213,7 @@ $(document).on('click', '.recipe-pos-edit-button', function(e)
|
|||||||
var recipePosId = $(e.currentTarget).attr('data-recipe-pos-id');
|
var recipePosId = $(e.currentTarget).attr('data-recipe-pos-id');
|
||||||
|
|
||||||
bootbox.dialog({
|
bootbox.dialog({
|
||||||
message: '<iframe height="650px" class="embed-responsive" src="' + U("/recipe/") + Grocy.EditObjectId.toString() + '/pos/' + recipePosId.toString() + '?embedded&product=' + productId.toString() + '"></iframe>',
|
message: '<iframe height="650px" class="embed-responsive" src="' + U("/recipe/") + Grocy.EditObjectId.toString() + '/pos/' + recipePosId.toString() + '?embedded&product=' + productId.toString() + '"></iframe>',
|
||||||
size: 'large',
|
size: 'large',
|
||||||
backdrop: true,
|
backdrop: true,
|
||||||
closeButton: false,
|
closeButton: false,
|
||||||
@@ -229,7 +230,7 @@ $(document).on('click', '.recipe-pos-edit-button', function(e)
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('click', '.recipe-include-edit-button', function (e)
|
$(document).on('click', '.recipe-include-edit-button', function(e)
|
||||||
{
|
{
|
||||||
var id = $(e.currentTarget).attr('data-recipe-include-id');
|
var id = $(e.currentTarget).attr('data-recipe-include-id');
|
||||||
var recipeId = $(e.currentTarget).attr('data-recipe-included-recipe-id');
|
var recipeId = $(e.currentTarget).attr('data-recipe-included-recipe-id');
|
||||||
@@ -338,21 +339,23 @@ $('#save-recipe-include-button').on('click', function(e)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#recipe-picture").on("change", function (e) {
|
$("#recipe-picture").on("change", function(e)
|
||||||
$("#recipe-picture-label").removeClass("d-none");
|
{
|
||||||
$("#recipe-picture-label-none").addClass("d-none");
|
$("#recipe-picture-label").removeClass("d-none");
|
||||||
$("#delete-current-recipe-picture-on-save-hint").addClass("d-none");
|
$("#recipe-picture-label-none").addClass("d-none");
|
||||||
$("#current-recipe-picture").addClass("d-none");
|
$("#delete-current-recipe-picture-on-save-hint").addClass("d-none");
|
||||||
Grocy.DeleteRecipePictureOnSave = false;
|
$("#current-recipe-picture").addClass("d-none");
|
||||||
|
Grocy.DeleteRecipePictureOnSave = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
Grocy.DeleteRecipePictureOnSave = false;
|
Grocy.DeleteRecipePictureOnSave = false;
|
||||||
$("#delete-current-recipe-picture-button").on("click", function (e) {
|
$("#delete-current-recipe-picture-button").on("click", function(e)
|
||||||
Grocy.DeleteRecipePictureOnSave = true;
|
{
|
||||||
$("#current-recipe-picture").addClass("d-none");
|
Grocy.DeleteRecipePictureOnSave = true;
|
||||||
$("#delete-current-recipe-picture-on-save-hint").removeClass("d-none");
|
$("#current-recipe-picture").addClass("d-none");
|
||||||
$("#recipe-picture-label").addClass("d-none");
|
$("#delete-current-recipe-picture-on-save-hint").removeClass("d-none");
|
||||||
$("#recipe-picture-label-none").removeClass("d-none");
|
$("#recipe-picture-label").addClass("d-none");
|
||||||
|
$("#recipe-picture-label-none").removeClass("d-none");
|
||||||
});
|
});
|
||||||
|
|
||||||
Grocy.Components.UserfieldsForm.Load();
|
Grocy.Components.UserfieldsForm.Load();
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
Grocy.RecipePosFormProductChangeCount = 0;
|
Grocy.RecipePosFormProductChangeCount = 0;
|
||||||
|
|
||||||
$('#save-recipe-pos-button').on('click', function (e)
|
$('#save-recipe-pos-button').on('click', function(e)
|
||||||
{
|
{
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
@@ -42,7 +42,7 @@ if (typeof recipe !== "undefined")
|
|||||||
if (GetUriParam("search") !== undefined)
|
if (GetUriParam("search") !== undefined)
|
||||||
{
|
{
|
||||||
$("#search").val(GetUriParam("search"));
|
$("#search").val(GetUriParam("search"));
|
||||||
setTimeout(function ()
|
setTimeout(function()
|
||||||
{
|
{
|
||||||
$("#search").keyup();
|
$("#search").keyup();
|
||||||
}, 50);
|
}, 50);
|
||||||
@@ -61,7 +61,7 @@ $("#search").on("keyup", Delay(function()
|
|||||||
recipesTables.search(value).draw();
|
recipesTables.search(value).draw();
|
||||||
|
|
||||||
$(".recipe-gallery-item").removeClass("d-none");
|
$(".recipe-gallery-item").removeClass("d-none");
|
||||||
console.log( $(".recipe-gallery-item .card-title:not(:contains_case_insensitive(" + value + "))"));
|
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");
|
$(".recipe-gallery-item .card-title:not(:contains_case_insensitive(" + value + "))").parent().parent().parent().addClass("d-none");
|
||||||
}, 200));
|
}, 200));
|
||||||
@@ -186,7 +186,7 @@ $(".recipe-consume").on('click', function(e)
|
|||||||
{
|
{
|
||||||
Grocy.FrontendHelpers.BeginUiBusy();
|
Grocy.FrontendHelpers.BeginUiBusy();
|
||||||
|
|
||||||
Grocy.Api.Post('recipes/' + objectId + '/consume', { },
|
Grocy.Api.Post('recipes/' + objectId + '/consume', {},
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
Grocy.FrontendHelpers.EndUiBusy();
|
Grocy.FrontendHelpers.EndUiBusy();
|
||||||
@@ -258,7 +258,7 @@ $(".recipe-print").on('click', function(e)
|
|||||||
|
|
||||||
$('#servings-scale').keyup(function(event)
|
$('#servings-scale').keyup(function(event)
|
||||||
{
|
{
|
||||||
var data = { };
|
var data = {};
|
||||||
data.desired_servings = $(this).val();
|
data.desired_servings = $(this).val();
|
||||||
|
|
||||||
Grocy.Api.Put('objects/recipes/' + $(this).data("recipe-id"), data,
|
Grocy.Api.Put('objects/recipes/' + $(this).data("recipe-id"), data,
|
||||||
|
@@ -93,16 +93,16 @@ $("#delete-selected-shopping-list").on("click", function()
|
|||||||
className: 'btn-danger'
|
className: 'btn-danger'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
callback: function (result)
|
callback: function(result)
|
||||||
{
|
{
|
||||||
if (result === true)
|
if (result === true)
|
||||||
{
|
{
|
||||||
Grocy.Api.Delete('objects/shopping_lists/' + objectId, {},
|
Grocy.Api.Delete('objects/shopping_lists/' + objectId, {},
|
||||||
function (result)
|
function(result)
|
||||||
{
|
{
|
||||||
window.location.href = U('/shoppinglist');
|
window.location.href = U('/shoppinglist');
|
||||||
},
|
},
|
||||||
function (xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
console.error(xhr);
|
console.error(xhr);
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ $(document).on('click', '.shoppinglist-delete-button', function(e)
|
|||||||
var shoppingListItemId = $(e.currentTarget).attr('data-shoppinglist-id');
|
var shoppingListItemId = $(e.currentTarget).attr('data-shoppinglist-id');
|
||||||
Grocy.FrontendHelpers.BeginUiBusy();
|
Grocy.FrontendHelpers.BeginUiBusy();
|
||||||
|
|
||||||
Grocy.Api.Delete('objects/shopping_list/' + shoppingListItemId, { },
|
Grocy.Api.Delete('objects/shopping_list/' + shoppingListItemId, {},
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
animateCSS("#shoppinglistitem-" + shoppingListItemId + "-row", "fadeOut", function()
|
animateCSS("#shoppinglistitem-" + shoppingListItemId + "-row", "fadeOut", function()
|
||||||
|
@@ -40,7 +40,7 @@ $('#shopping-list-form input').keyup(function(event)
|
|||||||
Grocy.FrontendHelpers.ValidateForm('shopping-list-form');
|
Grocy.FrontendHelpers.ValidateForm('shopping-list-form');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#shopping-list-form input').keydown(function (event)
|
$('#shopping-list-form input').keydown(function(event)
|
||||||
{
|
{
|
||||||
if (event.keyCode === 13) //Enter
|
if (event.keyCode === 13) //Enter
|
||||||
{
|
{
|
||||||
|
@@ -16,12 +16,12 @@
|
|||||||
if (GetUriParam("embedded") !== undefined)
|
if (GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
Grocy.Api.Get('stock/products/' + jsonData.product_id,
|
Grocy.Api.Get('stock/products/' + jsonData.product_id,
|
||||||
function (productDetails)
|
function(productDetails)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", __t("Added %1$s of %2$s to the shopping list \"%3$s\"", jsonData.product_amount + " " + __n(jsonData.product_amount, productDetails.quantity_unit_purchase.name, productDetails.quantity_unit_purchase.name_plural), productDetails.product.name, $("#shopping_list_id option:selected").text())), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", __t("Added %1$s of %2$s to the shopping list \"%3$s\"", jsonData.product_amount + " " + __n(jsonData.product_amount, productDetails.quantity_unit_purchase.name, productDetails.quantity_unit_purchase.name_plural), productDetails.product.name, $("#shopping_list_id option:selected").text())), Grocy.BaseUrl);
|
||||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
||||||
},
|
},
|
||||||
function (xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
console.error(xhr);
|
console.error(xhr);
|
||||||
}
|
}
|
||||||
@@ -48,12 +48,12 @@
|
|||||||
if (GetUriParam("embedded") !== undefined)
|
if (GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
Grocy.Api.Get('stock/products/' + jsonData.product_id,
|
Grocy.Api.Get('stock/products/' + jsonData.product_id,
|
||||||
function (productDetails)
|
function(productDetails)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", __t("Added %1$s of %2$s to the shopping list \"%3$s\"", jsonData.amount + " " + __n(jsonData.amount, productDetails.quantity_unit_purchase.name, productDetails.quantity_unit_purchase.name_plural), productDetails.product.name, $("#shopping_list_id option:selected").text())), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", __t("Added %1$s of %2$s to the shopping list \"%3$s\"", jsonData.amount + " " + __n(jsonData.amount, productDetails.quantity_unit_purchase.name, productDetails.quantity_unit_purchase.name_plural), productDetails.product.name, $("#shopping_list_id option:selected").text())), Grocy.BaseUrl);
|
||||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
||||||
},
|
},
|
||||||
function (xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
console.error(xhr);
|
console.error(xhr);
|
||||||
}
|
}
|
||||||
@@ -79,12 +79,12 @@
|
|||||||
if (GetUriParam("embedded") !== undefined)
|
if (GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
Grocy.Api.Get('stock/products/' + jsonData.product_id,
|
Grocy.Api.Get('stock/products/' + jsonData.product_id,
|
||||||
function (productDetails)
|
function(productDetails)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", __t("Added %1$s of %2$s to the shopping list \"%3$s\"", jsonData.amount + " " + __n(jsonData.amount, productDetails.quantity_unit_purchase.name, productDetails.quantity_unit_purchase.name_plural), productDetails.product.name, $("#shopping_list_id option:selected").text())), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", __t("Added %1$s of %2$s to the shopping list \"%3$s\"", jsonData.amount + " " + __n(jsonData.amount, productDetails.quantity_unit_purchase.name, productDetails.quantity_unit_purchase.name_plural), productDetails.product.name, $("#shopping_list_id option:selected").text())), Grocy.BaseUrl);
|
||||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
||||||
},
|
},
|
||||||
function (xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
console.error(xhr);
|
console.error(xhr);
|
||||||
}
|
}
|
||||||
@@ -113,7 +113,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
|||||||
Grocy.Components.ProductCard.Refresh(productId);
|
Grocy.Components.ProductCard.Refresh(productId);
|
||||||
|
|
||||||
Grocy.Api.Get('stock/products/' + productId,
|
Grocy.Api.Get('stock/products/' + productId,
|
||||||
function (productDetails)
|
function(productDetails)
|
||||||
{
|
{
|
||||||
$('#amount_qu_unit').text(productDetails.quantity_unit_purchase.name);
|
$('#amount_qu_unit').text(productDetails.quantity_unit_purchase.name);
|
||||||
|
|
||||||
|
@@ -42,12 +42,12 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#shoppinglocation-form input').keyup(function (event)
|
$('#shoppinglocation-form input').keyup(function(event)
|
||||||
{
|
{
|
||||||
Grocy.FrontendHelpers.ValidateForm('shoppinglocation-form');
|
Grocy.FrontendHelpers.ValidateForm('shoppinglocation-form');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#shoppinglocation-form input').keydown(function (event)
|
$('#shoppinglocation-form input').keydown(function(event)
|
||||||
{
|
{
|
||||||
if (event.keyCode === 13) //Enter
|
if (event.keyCode === 13) //Enter
|
||||||
{
|
{
|
||||||
|
@@ -19,7 +19,7 @@ $("#search").on("keyup", Delay(function()
|
|||||||
locationsTable.search(value).draw();
|
locationsTable.search(value).draw();
|
||||||
}, 200));
|
}, 200));
|
||||||
|
|
||||||
$(document).on('click', '.shoppinglocation-delete-button', function (e)
|
$(document).on('click', '.shoppinglocation-delete-button', function(e)
|
||||||
{
|
{
|
||||||
var objectName = $(e.currentTarget).attr('data-shoppinglocation-name');
|
var objectName = $(e.currentTarget).attr('data-shoppinglocation-name');
|
||||||
var objectId = $(e.currentTarget).attr('data-shoppinglocation-id');
|
var objectId = $(e.currentTarget).attr('data-shoppinglocation-id');
|
||||||
|
@@ -43,7 +43,7 @@ $(document).on('click', '.stock-consume-button', function(e)
|
|||||||
|
|
||||||
var wasSpoiled = $(e.currentTarget).hasClass("stock-consume-button-spoiled");
|
var wasSpoiled = $(e.currentTarget).hasClass("stock-consume-button-spoiled");
|
||||||
|
|
||||||
Grocy.Api.Post('stock/products/' + productId + '/consume', { 'amount': consumeAmount, 'spoiled': wasSpoiled, 'location_id': locationId, 'stock_entry_id': specificStockEntryId},
|
Grocy.Api.Post('stock/products/' + productId + '/consume', { 'amount': consumeAmount, 'spoiled': wasSpoiled, 'location_id': locationId, 'stock_entry_id': specificStockEntryId },
|
||||||
function(bookingResponse)
|
function(bookingResponse)
|
||||||
{
|
{
|
||||||
Grocy.Api.Get('stock/products/' + productId,
|
Grocy.Api.Get('stock/products/' + productId,
|
||||||
@@ -190,7 +190,7 @@ function RefreshStockEntryRow(stockRowId)
|
|||||||
$('#stock-' + stockRowId + '-shopping-location').attr('data-shopping-location-id', result.location_id);
|
$('#stock-' + stockRowId + '-shopping-location').attr('data-shopping-location-id', result.location_id);
|
||||||
$('#stock-' + stockRowId + '-shopping-location').text(shoppingLocationName);
|
$('#stock-' + stockRowId + '-shopping-location').text(shoppingLocationName);
|
||||||
},
|
},
|
||||||
function (xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
console.error(xhr);
|
console.error(xhr);
|
||||||
}
|
}
|
||||||
@@ -236,7 +236,7 @@ Grocy.Components.ProductPicker.GetPicker().trigger('change');
|
|||||||
|
|
||||||
function UndoStockBookingEntry(bookingId, stockRowId)
|
function UndoStockBookingEntry(bookingId, stockRowId)
|
||||||
{
|
{
|
||||||
Grocy.Api.Post('stock/bookings/' + bookingId.toString() + '/undo', { },
|
Grocy.Api.Post('stock/bookings/' + bookingId.toString() + '/undo', {},
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
window.postMessage(WindowMessageBag("StockEntryChanged", stockRowId), Grocy.BaseUrl);
|
window.postMessage(WindowMessageBag("StockEntryChanged", stockRowId), Grocy.BaseUrl);
|
||||||
|
@@ -10,11 +10,12 @@
|
|||||||
price = parseFloat(jsonForm.price).toFixed(2);
|
price = parseFloat(jsonForm.price).toFixed(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
var jsonData = { };
|
var jsonData = {};
|
||||||
jsonData.amount = jsonForm.amount;
|
jsonData.amount = jsonForm.amount;
|
||||||
jsonData.best_before_date = Grocy.Components.DateTimePicker.GetValue();
|
jsonData.best_before_date = Grocy.Components.DateTimePicker.GetValue();
|
||||||
jsonData.purchased_date = Grocy.Components.DateTimePicker2.GetValue();
|
jsonData.purchased_date = Grocy.Components.DateTimePicker2.GetValue();
|
||||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) {
|
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
|
||||||
|
{
|
||||||
jsonData.shopping_location_id = Grocy.Components.ShoppingLocationPicker.GetValue();
|
jsonData.shopping_location_id = Grocy.Components.ShoppingLocationPicker.GetValue();
|
||||||
}
|
}
|
||||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)
|
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)
|
||||||
@@ -52,7 +53,7 @@
|
|||||||
|
|
||||||
Grocy.FrontendHelpers.ValidateForm('stockentry-form');
|
Grocy.FrontendHelpers.ValidateForm('stockentry-form');
|
||||||
|
|
||||||
$('#stockentry-form input').keyup(function (event)
|
$('#stockentry-form input').keyup(function(event)
|
||||||
{
|
{
|
||||||
Grocy.FrontendHelpers.ValidateForm('stockentry-form');
|
Grocy.FrontendHelpers.ValidateForm('stockentry-form');
|
||||||
});
|
});
|
||||||
@@ -124,7 +125,7 @@ Grocy.Api.Get('stock/products/' + Grocy.EditObjectProductId,
|
|||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
function (xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
console.error(xhr);
|
console.error(xhr);
|
||||||
}
|
}
|
||||||
|
@@ -51,7 +51,7 @@ $(document).on('click', '.undo-stock-booking-button', function(e)
|
|||||||
correspondingBookingsRoot = $(".stock-booking-correlation-" + correlationId);
|
correspondingBookingsRoot = $(".stock-booking-correlation-" + correlationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
Grocy.Api.Post('stock/bookings/' + bookingId.toString() + '/undo', { },
|
Grocy.Api.Post('stock/bookings/' + bookingId.toString() + '/undo', {},
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
correspondingBookingsRoot.addClass("text-muted");
|
correspondingBookingsRoot.addClass("text-muted");
|
||||||
|
@@ -200,7 +200,8 @@ function RefreshStatistics()
|
|||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
var amountSum = 0;
|
var amountSum = 0;
|
||||||
result.forEach(element => {
|
result.forEach(element =>
|
||||||
|
{
|
||||||
amountSum += parseInt(element.amount);
|
amountSum += parseInt(element.amount);
|
||||||
});
|
});
|
||||||
$("#info-current-stock").text(__n(result.length, '%s Product', '%s Products'));
|
$("#info-current-stock").text(__n(result.length, '%s Product', '%s Products'));
|
||||||
|
@@ -19,7 +19,7 @@ $("#search").on("keyup", Delay(function()
|
|||||||
categoriesTable.search(value).draw();
|
categoriesTable.search(value).draw();
|
||||||
}, 200));
|
}, 200));
|
||||||
|
|
||||||
$(document).on('click', '.task-category-delete-button', function (e)
|
$(document).on('click', '.task-category-delete-button', function(e)
|
||||||
{
|
{
|
||||||
var objectName = $(e.currentTarget).attr('data-category-name');
|
var objectName = $(e.currentTarget).attr('data-category-name');
|
||||||
var objectId = $(e.currentTarget).attr('data-category-id');
|
var objectId = $(e.currentTarget).attr('data-category-id');
|
||||||
|
@@ -42,12 +42,12 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#task-category-form input').keyup(function (event)
|
$('#task-category-form input').keyup(function(event)
|
||||||
{
|
{
|
||||||
Grocy.FrontendHelpers.ValidateForm('task-category-form');
|
Grocy.FrontendHelpers.ValidateForm('task-category-form');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#task-category-form input').keydown(function (event)
|
$('#task-category-form input').keydown(function(event)
|
||||||
{
|
{
|
||||||
if (event.keyCode === 13) //Enter
|
if (event.keyCode === 13) //Enter
|
||||||
{
|
{
|
||||||
|
@@ -102,7 +102,7 @@ $(document).on('click', '.undo-task-button', function(e)
|
|||||||
var taskId = $(e.currentTarget).attr('data-task-id');
|
var taskId = $(e.currentTarget).attr('data-task-id');
|
||||||
var taskName = $(e.currentTarget).attr('data-task-name');
|
var taskName = $(e.currentTarget).attr('data-task-name');
|
||||||
|
|
||||||
Grocy.Api.Post('tasks/' + taskId + '/undo', { },
|
Grocy.Api.Post('tasks/' + taskId + '/undo', {},
|
||||||
function()
|
function()
|
||||||
{
|
{
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
@@ -115,7 +115,7 @@ $(document).on('click', '.undo-task-button', function(e)
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('click', '.delete-task-button', function (e)
|
$(document).on('click', '.delete-task-button', function(e)
|
||||||
{
|
{
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@@ -185,7 +185,8 @@ function RefreshStatistics()
|
|||||||
var overdueCount = 0;
|
var overdueCount = 0;
|
||||||
var now = moment();
|
var now = moment();
|
||||||
var nextXDaysThreshold = moment().add(nextXDays, "days");
|
var nextXDaysThreshold = moment().add(nextXDays, "days");
|
||||||
result.forEach(element => {
|
result.forEach(element =>
|
||||||
|
{
|
||||||
var date = moment(element.due_date);
|
var date = moment(element.due_date);
|
||||||
if (date.isBefore(now))
|
if (date.isBefore(now))
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
$('#save-transfer-button').on('click', function (e)
|
$('#save-transfer-button').on('click', function(e)
|
||||||
{
|
{
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@@ -33,14 +33,14 @@
|
|||||||
var jsonDataBarcode = {};
|
var jsonDataBarcode = {};
|
||||||
jsonDataBarcode.barcode = addBarcode;
|
jsonDataBarcode.barcode = addBarcode;
|
||||||
jsonDataBarcode.product_id = jsonForm.product_id;
|
jsonDataBarcode.product_id = jsonForm.product_id;
|
||||||
jsonDataBarcode.qu_factor_purchase_to_stock = productDetails.product.qu_factor_purchase_to_stock;
|
jsonDataBarcode.qu_factor_purchase_to_stock = productDetails.product.qu_factor_purchase_to_stock;
|
||||||
|
|
||||||
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
|
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
$("#flow-info-addbarcodetoselection").addClass("d-none");
|
$("#flow-info-addbarcodetoselection").addClass("d-none");
|
||||||
$('#barcode-lookup-disabled-hint').addClass('d-none');
|
$('#barcode-lookup-disabled-hint').addClass('d-none');
|
||||||
window.history.replaceState({ }, document.title, U("/transfer"));
|
window.history.replaceState({}, document.title, U("/transfer"));
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
@@ -52,11 +52,11 @@
|
|||||||
|
|
||||||
if (productDetails.product.enable_tare_weight_handling == 1)
|
if (productDetails.product.enable_tare_weight_handling == 1)
|
||||||
{
|
{
|
||||||
var successMessage = __t('Transfered %1$s of %2$s from %3$s to %4$s', Math.abs(jsonForm.amount - parseFloat(productDetails.product.tare_weight)) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name,$('option:selected', "#location_id_from").text(), $('option:selected', "#location_id_to").text()) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse.transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
var successMessage = __t('Transfered %1$s of %2$s from %3$s to %4$s', Math.abs(jsonForm.amount - parseFloat(productDetails.product.tare_weight)) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name, $('option:selected', "#location_id_from").text(), $('option:selected', "#location_id_to").text()) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse.transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var successMessage =__t('Transfered %1$s of %2$s from %3$s to %4$s', Math.abs(jsonForm.amount) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name, $('option:selected', "#location_id_from").text(), $('option:selected', "#location_id_to").text()) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse.transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
var successMessage = __t('Transfered %1$s of %2$s from %3$s to %4$s', Math.abs(jsonForm.amount) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name, $('option:selected', "#location_id_from").text(), $('option:selected', "#location_id_to").text()) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="UndoStockTransaction(\'' + bookingResponse.transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (GetUriParam("embedded") !== undefined)
|
||||||
@@ -137,7 +137,8 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
|||||||
Grocy.Api.Get('stock/products/' + productId,
|
Grocy.Api.Get('stock/products/' + productId,
|
||||||
function(productDetails)
|
function(productDetails)
|
||||||
{
|
{
|
||||||
if (productDetails.product.enable_tare_weight_handling == 1) {
|
if (productDetails.product.enable_tare_weight_handling == 1)
|
||||||
|
{
|
||||||
Grocy.Components.ProductPicker.GetPicker().parent().find(".invalid-feedback").text(__t('Products with Tare weight enabled are currently not supported for Transfer. Please select another product.'));
|
Grocy.Components.ProductPicker.GetPicker().parent().find(".invalid-feedback").text(__t('Products with Tare weight enabled are currently not supported for Transfer. Please select another product.'));
|
||||||
Grocy.Components.ProductPicker.Clear();
|
Grocy.Components.ProductPicker.Clear();
|
||||||
return;
|
return;
|
||||||
@@ -346,7 +347,7 @@ $("#specific_stock_entry").on("change", function(e)
|
|||||||
{
|
{
|
||||||
if ($(e.target).val() == "")
|
if ($(e.target).val() == "")
|
||||||
{
|
{
|
||||||
var sumValue = 0;
|
var sumValue = 0;
|
||||||
Grocy.Api.Get("stock/products/" + Grocy.Components.ProductPicker.GetValue() + '/entries',
|
Grocy.Api.Get("stock/products/" + Grocy.Components.ProductPicker.GetValue() + '/entries',
|
||||||
function(stockEntries)
|
function(stockEntries)
|
||||||
{
|
{
|
||||||
@@ -402,7 +403,7 @@ $("#use_specific_stock_entry").on("change", function()
|
|||||||
|
|
||||||
function UndoStockBooking(bookingId)
|
function UndoStockBooking(bookingId)
|
||||||
{
|
{
|
||||||
Grocy.Api.Post('stock/bookings/' + bookingId.toString() + '/undo', { },
|
Grocy.Api.Post('stock/bookings/' + bookingId.toString() + '/undo', {},
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
toastr.success(__t("Booking successfully undone"));
|
toastr.success(__t("Booking successfully undone"));
|
||||||
@@ -416,12 +417,12 @@ function UndoStockBooking(bookingId)
|
|||||||
|
|
||||||
function UndoStockTransaction(transactionId)
|
function UndoStockTransaction(transactionId)
|
||||||
{
|
{
|
||||||
Grocy.Api.Post('stock/transactions/' + transactionId.toString() + '/undo', { },
|
Grocy.Api.Post('stock/transactions/' + transactionId.toString() + '/undo', {},
|
||||||
function (result)
|
function(result)
|
||||||
{
|
{
|
||||||
toastr.success(__t("Transaction successfully undone"));
|
toastr.success(__t("Transaction successfully undone"));
|
||||||
},
|
},
|
||||||
function (xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
console.error(xhr);
|
console.error(xhr);
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,7 @@ $("#search").on("keyup", Delay(function()
|
|||||||
userentitiesTable.search(value).draw();
|
userentitiesTable.search(value).draw();
|
||||||
}, 200));
|
}, 200));
|
||||||
|
|
||||||
$(document).on('click', '.userentity-delete-button', function (e)
|
$(document).on('click', '.userentity-delete-button', function(e)
|
||||||
{
|
{
|
||||||
var objectName = $(e.currentTarget).attr('data-userentity-name');
|
var objectName = $(e.currentTarget).attr('data-userentity-name');
|
||||||
var objectId = $(e.currentTarget).attr('data-userentity-id');
|
var objectId = $(e.currentTarget).attr('data-userentity-id');
|
||||||
@@ -41,7 +41,7 @@ $(document).on('click', '.userentity-delete-button', function (e)
|
|||||||
{
|
{
|
||||||
if (result === true)
|
if (result === true)
|
||||||
{
|
{
|
||||||
Grocy.Api.Delete('objects/userentities/' + objectId, { },
|
Grocy.Api.Delete('objects/userentities/' + objectId, {},
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
window.location.href = U('/userentities');
|
window.location.href = U('/userentities');
|
||||||
|
@@ -31,7 +31,7 @@ $("#entity-filter").on("change", function()
|
|||||||
$("#new-userfield-button").attr("href", U("/userfield/new?entity=" + value));
|
$("#new-userfield-button").attr("href", U("/userfield/new?entity=" + value));
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('click', '.userfield-delete-button', function (e)
|
$(document).on('click', '.userfield-delete-button', function(e)
|
||||||
{
|
{
|
||||||
var objectName = $(e.currentTarget).attr('data-userfield-name');
|
var objectName = $(e.currentTarget).attr('data-userfield-name');
|
||||||
var objectId = $(e.currentTarget).attr('data-userfield-id');
|
var objectId = $(e.currentTarget).attr('data-userfield-id');
|
||||||
|
@@ -35,7 +35,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#user-form input').keyup(function (event)
|
$('#user-form input').keyup(function(event)
|
||||||
{
|
{
|
||||||
var element = document.getElementById("password_confirm");
|
var element = document.getElementById("password_confirm");
|
||||||
if ($("#password").val() !== $("#password_confirm").val())
|
if ($("#password").val() !== $("#password_confirm").val())
|
||||||
@@ -50,7 +50,7 @@ $('#user-form input').keyup(function (event)
|
|||||||
Grocy.FrontendHelpers.ValidateForm('user-form');
|
Grocy.FrontendHelpers.ValidateForm('user-form');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#user-form input').keydown(function (event)
|
$('#user-form input').keydown(function(event)
|
||||||
{
|
{
|
||||||
if (event.keyCode === 13) //Enter
|
if (event.keyCode === 13) //Enter
|
||||||
{
|
{
|
||||||
|
@@ -19,7 +19,7 @@ $("#search").on("keyup", Delay(function()
|
|||||||
userobjectsTable.search(value).draw();
|
userobjectsTable.search(value).draw();
|
||||||
}, 200));
|
}, 200));
|
||||||
|
|
||||||
$(document).on('click', '.userobject-delete-button', function (e)
|
$(document).on('click', '.userobject-delete-button', function(e)
|
||||||
{
|
{
|
||||||
var objectId = $(e.currentTarget).attr('data-userobject-id');
|
var objectId = $(e.currentTarget).attr('data-userobject-id');
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ $(document).on('click', '.userobject-delete-button', function (e)
|
|||||||
{
|
{
|
||||||
if (result === true)
|
if (result === true)
|
||||||
{
|
{
|
||||||
Grocy.Api.Delete('objects/userobjects/' + objectId, { },
|
Grocy.Api.Delete('objects/userobjects/' + objectId, {},
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
$('input.permission-cb').click(
|
$('input.permission-cb').click(
|
||||||
function () {
|
function()
|
||||||
|
{
|
||||||
check_hierachy(this.checked, this.name);
|
check_hierachy(this.checked, this.name);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
function check_hierachy(checked, name) {
|
function check_hierachy(checked, name)
|
||||||
|
{
|
||||||
var disabled = checked;
|
var disabled = checked;
|
||||||
$('#permission-sub-' + name).find('input.permission-cb')
|
$('#permission-sub-' + name).find('input.permission-cb')
|
||||||
.prop('checked', disabled)
|
.prop('checked', disabled)
|
||||||
@@ -12,28 +14,37 @@ function check_hierachy(checked, name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$('#permission-save').click(
|
$('#permission-save').click(
|
||||||
function () {
|
function()
|
||||||
|
{
|
||||||
var permission_list = $('input.permission-cb')
|
var permission_list = $('input.permission-cb')
|
||||||
.filter(function () {
|
.filter(function()
|
||||||
|
{
|
||||||
return $(this).prop('checked') && !$(this).attr('disabled');
|
return $(this).prop('checked') && !$(this).attr('disabled');
|
||||||
}).map(function () {
|
}).map(function()
|
||||||
|
{
|
||||||
return $(this).data('perm-id');
|
return $(this).data('perm-id');
|
||||||
}).toArray();
|
}).toArray();
|
||||||
Grocy.Api.Put('users/' + Grocy.EditObjectId + '/permissions', {
|
Grocy.Api.Put('users/' + Grocy.EditObjectId + '/permissions', {
|
||||||
'permissions': permission_list,
|
'permissions': permission_list,
|
||||||
}, function (result) {
|
}, function(result)
|
||||||
toastr.success(__t("Permissions saved"));
|
{
|
||||||
}, function (xhr) {
|
toastr.success(__t("Permissions saved"));
|
||||||
toastr.error(__t(JSON.parse(xhr.response).error_message));
|
}, function(xhr)
|
||||||
}
|
{
|
||||||
|
toastr.error(__t(JSON.parse(xhr.response).error_message));
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Grocy.EditObjectId == Grocy.UserId) {
|
if (Grocy.EditObjectId == Grocy.UserId)
|
||||||
$('input.permission-cb[name=ADMIN]').click(function () {
|
{
|
||||||
if (!this.checked) {
|
$('input.permission-cb[name=ADMIN]').click(function()
|
||||||
if (!confirm(__t('Are you sure you want to remove full permissions for yourself?'))) {
|
{
|
||||||
|
if (!this.checked)
|
||||||
|
{
|
||||||
|
if (!confirm(__t('Are you sure you want to remove full permissions for yourself?')))
|
||||||
|
{
|
||||||
this.checked = true;
|
this.checked = true;
|
||||||
check_hierachy(this.checked, this.name);
|
check_hierachy(this.checked, this.name);
|
||||||
}
|
}
|
||||||
|
@@ -19,7 +19,7 @@ $("#search").on("keyup", Delay(function()
|
|||||||
usersTable.search(value).draw();
|
usersTable.search(value).draw();
|
||||||
}, 200));
|
}, 200));
|
||||||
|
|
||||||
$(document).on('click', '.user-delete-button', function (e)
|
$(document).on('click', '.user-delete-button', function(e)
|
||||||
{
|
{
|
||||||
var objectName = $(e.currentTarget).attr('data-user-username');
|
var objectName = $(e.currentTarget).attr('data-user-username');
|
||||||
var objectId = $(e.currentTarget).attr('data-user-id');
|
var objectId = $(e.currentTarget).attr('data-user-id');
|
||||||
|
Reference in New Issue
Block a user