mirror of
https://github.com/grocy/grocy.git
synced 2025-08-15 10:14:39 +00:00
Applied VSCode JS formatting settings
This commit is contained in:
@@ -122,7 +122,8 @@ function RefreshStatistics()
|
||||
var overdueCount = 0;
|
||||
var now = moment();
|
||||
var nextXDaysThreshold = moment().add(nextXDays, "days");
|
||||
result.forEach(element => {
|
||||
result.forEach(element =>
|
||||
{
|
||||
var date = moment(element.next_estimated_charge_time);
|
||||
if (date.isBefore(now))
|
||||
{
|
||||
|
@@ -17,7 +17,8 @@ var calendar = $("#calendar").fullCalendar({
|
||||
"eventLimit": false,
|
||||
"height": "auto",
|
||||
"eventSources": fullcalendarEventSources,
|
||||
eventClick: function(info) {
|
||||
eventClick: function(info)
|
||||
{
|
||||
location.href = info.link;
|
||||
}
|
||||
});
|
||||
|
@@ -182,7 +182,8 @@ function RefreshStatistics()
|
||||
var assignedToMeCount = 0;
|
||||
var now = moment();
|
||||
var nextXDaysThreshold = moment().add(nextXDays, "days");
|
||||
result.forEach(element => {
|
||||
result.forEach(element =>
|
||||
{
|
||||
var date = moment(element.next_estimated_execution_time);
|
||||
if (date.isBefore(now))
|
||||
{
|
||||
|
@@ -5,14 +5,16 @@ Grocy.Components.BarcodeScanner.CheckCapabilities = async function()
|
||||
{
|
||||
var track = Quagga.CameraAccess.getActiveTrack();
|
||||
var capabilities = {};
|
||||
if (typeof track.getCapabilities === 'function') {
|
||||
if (typeof track.getCapabilities === 'function')
|
||||
{
|
||||
capabilities = track.getCapabilities();
|
||||
}
|
||||
|
||||
// If there is more than 1 camera, show the camera selection
|
||||
var cameras = await Quagga.CameraAccess.enumerateVideoDevices();
|
||||
var cameraSelect = document.querySelector('.cameraSelect-wrapper');
|
||||
if (cameraSelect) {
|
||||
if (cameraSelect)
|
||||
{
|
||||
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
|
||||
// Remove the torch button, if either the device can not torch or AutoTorchOn is set.
|
||||
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';
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
|
||||
@@ -142,7 +146,8 @@ Grocy.Components.BarcodeScanner.StopScanning = function()
|
||||
|
||||
Grocy.Components.BarcodeScanner.TorchOn = function(track)
|
||||
{
|
||||
if (track) {
|
||||
if (track)
|
||||
{
|
||||
track.applyConstraints({
|
||||
advanced: [
|
||||
{
|
||||
@@ -251,7 +256,8 @@ $(document).on("click", "#barcodescanner-start-button", async function(e)
|
||||
var cameraSelect = document.querySelector('.cameraSelect');
|
||||
|
||||
var cameras = await Quagga.CameraAccess.enumerateVideoDevices();
|
||||
cameras.forEach(camera => {
|
||||
cameras.forEach(camera =>
|
||||
{
|
||||
var option = document.createElement("option");
|
||||
option.text = camera.label ? camera.label : camera.deviceId; // Use camera label if it exists, else show device id
|
||||
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
|
||||
cameraSelect.value = window.localStorage.getItem('cameraId');
|
||||
|
||||
cameraSelect.onchange = function(){
|
||||
cameraSelect.onchange = function()
|
||||
{
|
||||
window.localStorage.setItem('cameraId', cameraSelect.value);
|
||||
Quagga.stop();
|
||||
Grocy.Components.BarcodeScanner.StartScanning();
|
||||
|
@@ -157,14 +157,16 @@ Grocy.Components.ProductCard.Refresh = function(productId)
|
||||
key = dataPoint.shopping_location.name
|
||||
}
|
||||
|
||||
if (!datasets[key]) {
|
||||
if (!datasets[key])
|
||||
{
|
||||
datasets[key] = []
|
||||
}
|
||||
chart.labels.push(moment(dataPoint.date).toDate());
|
||||
datasets[key].push(dataPoint.price);
|
||||
|
||||
});
|
||||
Object.keys(datasets).forEach((key) => {
|
||||
Object.keys(datasets).forEach((key) =>
|
||||
{
|
||||
chart.datasets.push({
|
||||
data: datasets[key],
|
||||
fill: false,
|
||||
|
@@ -17,7 +17,8 @@
|
||||
var jsonData = {};
|
||||
jsonData.new_amount = jsonForm.new_amount;
|
||||
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();
|
||||
}
|
||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)
|
||||
@@ -84,7 +85,8 @@
|
||||
$('#price').val('');
|
||||
Grocy.Components.DateTimePicker.Clear();
|
||||
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.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 }));
|
||||
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);
|
||||
}
|
||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)
|
||||
|
@@ -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.
|
||||
var QuIdStock = $('#qu_id_stock');
|
||||
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;
|
||||
Grocy.FrontendHelpers.ValidateForm('product-form');
|
||||
}
|
||||
|
@@ -30,7 +30,8 @@
|
||||
var jsonData = {};
|
||||
jsonData.amount = amount;
|
||||
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.price = price;
|
||||
@@ -100,7 +101,8 @@
|
||||
}
|
||||
Grocy.Components.DateTimePicker.Clear();
|
||||
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.ProductPicker.GetInputElement().focus();
|
||||
@@ -192,7 +194,8 @@ if (Grocy.Components.ProductPicker !== undefined)
|
||||
}
|
||||
}
|
||||
|
||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) {
|
||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
|
||||
{
|
||||
if (barcode_shopping_location_id != null)
|
||||
{
|
||||
Grocy.Components.ShoppingLocationPicker.SetId(barcode_shopping_location_id);
|
||||
|
@@ -39,7 +39,8 @@ $('.save-recipe').on('click', function(e)
|
||||
|
||||
const location = $(e.currentTarget).attr('data-location') == 'return' ? '/recipes?recipe=' : '/recipe/';
|
||||
|
||||
if(Grocy.EditMode == 'create') {
|
||||
if (Grocy.EditMode == 'create')
|
||||
{
|
||||
console.log(jsonData);
|
||||
Grocy.Api.Post('objects/recipes', jsonData,
|
||||
(result) => saveRecipePicture(result, location));
|
||||
@@ -338,7 +339,8 @@ $('#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");
|
||||
$("#delete-current-recipe-picture-on-save-hint").addClass("d-none");
|
||||
@@ -347,7 +349,8 @@ $("#recipe-picture").on("change", function (e) {
|
||||
});
|
||||
|
||||
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");
|
||||
$("#delete-current-recipe-picture-on-save-hint").removeClass("d-none");
|
||||
|
@@ -14,7 +14,8 @@
|
||||
jsonData.amount = jsonForm.amount;
|
||||
jsonData.best_before_date = Grocy.Components.DateTimePicker.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();
|
||||
}
|
||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING)
|
||||
|
@@ -200,7 +200,8 @@ function RefreshStatistics()
|
||||
function(result)
|
||||
{
|
||||
var amountSum = 0;
|
||||
result.forEach(element => {
|
||||
result.forEach(element =>
|
||||
{
|
||||
amountSum += parseInt(element.amount);
|
||||
});
|
||||
$("#info-current-stock").text(__n(result.length, '%s Product', '%s Products'));
|
||||
|
@@ -185,7 +185,8 @@ function RefreshStatistics()
|
||||
var overdueCount = 0;
|
||||
var now = moment();
|
||||
var nextXDaysThreshold = moment().add(nextXDays, "days");
|
||||
result.forEach(element => {
|
||||
result.forEach(element =>
|
||||
{
|
||||
var date = moment(element.due_date);
|
||||
if (date.isBefore(now))
|
||||
{
|
||||
|
@@ -137,7 +137,8 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
||||
Grocy.Api.Get('stock/products/' + productId,
|
||||
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.Clear();
|
||||
return;
|
||||
|
@@ -1,10 +1,12 @@
|
||||
$('input.permission-cb').click(
|
||||
function () {
|
||||
function()
|
||||
{
|
||||
check_hierachy(this.checked, this.name);
|
||||
}
|
||||
);
|
||||
|
||||
function check_hierachy(checked, name) {
|
||||
function check_hierachy(checked, name)
|
||||
{
|
||||
var disabled = checked;
|
||||
$('#permission-sub-' + name).find('input.permission-cb')
|
||||
.prop('checked', disabled)
|
||||
@@ -12,28 +14,37 @@ function check_hierachy(checked, name) {
|
||||
}
|
||||
|
||||
$('#permission-save').click(
|
||||
function () {
|
||||
function()
|
||||
{
|
||||
var permission_list = $('input.permission-cb')
|
||||
.filter(function () {
|
||||
.filter(function()
|
||||
{
|
||||
return $(this).prop('checked') && !$(this).attr('disabled');
|
||||
}).map(function () {
|
||||
}).map(function()
|
||||
{
|
||||
return $(this).data('perm-id');
|
||||
}).toArray();
|
||||
Grocy.Api.Put('users/' + Grocy.EditObjectId + '/permissions', {
|
||||
'permissions': permission_list,
|
||||
}, function (result) {
|
||||
}, function(result)
|
||||
{
|
||||
toastr.success(__t("Permissions saved"));
|
||||
}, function (xhr) {
|
||||
}, function(xhr)
|
||||
{
|
||||
toastr.error(__t(JSON.parse(xhr.response).error_message));
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
if (Grocy.EditObjectId == Grocy.UserId) {
|
||||
$('input.permission-cb[name=ADMIN]').click(function () {
|
||||
if (!this.checked) {
|
||||
if (!confirm(__t('Are you sure you want to remove full permissions for yourself?'))) {
|
||||
if (Grocy.EditObjectId == Grocy.UserId)
|
||||
{
|
||||
$('input.permission-cb[name=ADMIN]').click(function()
|
||||
{
|
||||
if (!this.checked)
|
||||
{
|
||||
if (!confirm(__t('Are you sure you want to remove full permissions for yourself?')))
|
||||
{
|
||||
this.checked = true;
|
||||
check_hierachy(this.checked, this.name);
|
||||
}
|
||||
|
Reference in New Issue
Block a user