Applied EditorConfig settings to all files

This commit is contained in:
Bernd Bestel
2020-08-29 16:41:27 +02:00
parent 2c966c77fd
commit 3b0d29bed0
87 changed files with 797 additions and 798 deletions

View File

@@ -79,7 +79,7 @@ a.discrete-link:focus {
top: 0;
left: 0;
}
body.fullscreen-card {
overflow: hidden;
}
@@ -575,13 +575,13 @@ canvas.drawingBuffer {
}
.print-view {
width: 100%;
max-width: 100%;
flex-basis: 100%;
width: 100%;
max-width: 100%;
flex-basis: 100%;
}
}
.not-allowed {
pointer-events: none;
pointer-events: none;
opacity: 0.5;
}
}

View File

@@ -220,23 +220,23 @@
}
.night-mode .note-editor.note-frame .note-editing-area .note-editable {
color: #c1c1c1;
background-color: #333131;
color: #c1c1c1;
background-color: #333131;
}
.night-mode .bootstrap-datetimepicker-widget table td.day {
background-color: #333131;
background-color: #333131;
}
.night-mode .bootstrap-datetimepicker-widget table td {
background-color: #333131;
background-color: #333131;
}
.night-mode .bootstrap-datetimepicker-widget table td,
.night-mode .bootstrap-datetimepicker-widget table td,
.night-mode .bootstrap-datetimepicker-widget table th {
background-color: #333131;
background-color: #333131;
}
.night-mode .dropdown-menu {
background-color: #333131;
background-color: #333131;
}

View File

@@ -36,7 +36,7 @@ try
}
catch (ERequirementNotMet $ex)
{
die('Unable to run grocy: ' . $ex->getMessage());
die('Unable to run grocy: ' . $ex->getMessage());
}
require_once __DIR__ . '/../app.php';

View File

@@ -91,25 +91,25 @@ FindObjectInArrayByPropertyValue = function(array, propertyName, propertyValue)
{
if (array[i][propertyName] == propertyValue)
{
return array[i];
}
return array[i];
}
}
return null;
return null;
}
FindAllObjectsInArrayByPropertyValue = function(array, propertyName, propertyValue)
{
var returnArray = [];
for (var i = 0; i < array.length; i++)
{
if (array[i][propertyName] == propertyValue)
{
returnArray.push(array[i]);
}
}
}
return returnArray;
}
@@ -137,7 +137,7 @@ function Delay(callable, delayMilliseconds)
{
var context = this;
var args = arguments;
clearTimeout(timer);
timer = setTimeout(function()
{
@@ -150,7 +150,7 @@ $.fn.isVisibleInViewport = function(extraHeightPadding = 0)
{
var elementTop = $(this).offset().top;
var viewportTop = $(window).scrollTop() - extraHeightPadding;
return elementTop + $(this).outerHeight() > viewportTop && elementTop < viewportTop + $(window).height();
};
@@ -163,7 +163,7 @@ function animateCSS(selector, animationName, callback, speed = "faster")
{
nodes.removeClass('animated').removeClass(speed).removeClass(animationName);
nodes.unbind('animationend', handleAnimationEnd);
if (typeof callback === 'function')
{
callback();

View File

@@ -234,7 +234,7 @@ __t = function(text, ...placeholderValues)
var text2 = text;
Grocy.Api.Post('system/log-missing-localization', { "text": text2 });
}
return Grocy.Translator.__(text, ...placeholderValues)
}
__n = function(number, singularForm, pluralForm)
@@ -572,7 +572,7 @@ function RefreshLocaleNumberDisplay(rootSelector = "#page-content")
{
return;
}
$(this).text(parseFloat($(this).text()).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 2 }));
});
}
@@ -625,7 +625,7 @@ $(document).on("click", ".show-as-dialog-link", function(e)
e.preventDefault();
var link = $(e.currentTarget).attr("href");
bootbox.dialog({
message: '<iframe height="650px" class="embed-responsive" src="' + link + '"></iframe>',
size: 'large',

View File

@@ -38,7 +38,7 @@ $(document).on("keyup", "#auto-night-mode-time-range-from, #auto-night-mode-time
{
var value = $(this).val();
var valueIsValid = moment(value, "HH:mm", true).isValid();
if (valueIsValid)
{
$(this).removeClass("bg-danger");
@@ -105,7 +105,7 @@ function CheckNightMode()
$("body").removeClass("night-mode");
$("#currently-inside-night-mode-range").prop("checked", false);
$("#currently-inside-night-mode-range").trigger("change");
}
}
}
}
if (Grocy.UserId !== -1)

View File

@@ -54,7 +54,7 @@ function OnBarcodeScanned(barcode)
{
return;
}
var bgClass = "";
if (barcode != $("#expected_barcode").val())
{
@@ -91,6 +91,6 @@ $(document).on("Grocy.BarcodeScanned", function(e, barcode, target)
{
return;
}
OnBarcodeScanned(barcode);
});

View File

@@ -7,7 +7,7 @@
{
jsonData.assignment_config = $("#assignment_config").val().join(",");
}
Grocy.FrontendHelpers.BeginUiBusy("chore-form");
if (Grocy.EditMode === 'create')

View File

@@ -8,14 +8,14 @@ Grocy.Components.BarcodeScanner.CheckCapabilities = async 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) {
cameraSelect.style.display = cameras.length > 1 ? 'inline-block' : 'none';
}
// Check if the camera is capable to turn on a torch.
var canTorch = typeof capabilities.torch === 'boolean' && capabilities.torch
// Remove the torch button, if either the device can not torch or AutoTorchOn is set.
@@ -133,7 +133,7 @@ Grocy.Components.BarcodeScanner.StartScanning = function()
Grocy.Components.BarcodeScanner.StopScanning = function()
{
Quagga.stop();
Grocy.Components.BarcodeScanner.DecodedCodesCount = 0;
Grocy.Components.BarcodeScanner.DecodedCodesErrorCount = 0;
@@ -143,9 +143,9 @@ Grocy.Components.BarcodeScanner.StopScanning = function()
Grocy.Components.BarcodeScanner.TorchOn = function(track)
{
if (track) {
track.applyConstraints({
track.applyConstraints({
advanced: [
{
{
torch: true
}
]
@@ -214,7 +214,7 @@ $(document).on("click", "#barcodescanner-start-button", async function(e)
}
Grocy.Components.BarcodeScanner.CurrentTarget = inputElement.attr("data-target");
var dialog = bootbox.dialog({
message: '<div id="barcodescanner-container" class="col"><div id="barcodescanner-livestream"></div></div>',
title: __t('Scan a barcode'),
@@ -233,8 +233,8 @@ $(document).on("click", "#barcodescanner-start-button", async function(e)
{
Grocy.Components.BarcodeScanner.TorchOn(Quagga.CameraAccess.getActiveTrack());
return false;
}
},
}
},
cancel: {
label: __t('Cancel'),
className: 'btn-secondary responsive-button',
@@ -245,11 +245,11 @@ $(document).on("click", "#barcodescanner-start-button", async function(e)
}
}
});
// Add camera select to existing dialog
dialog.find('.bootbox-body').append('<div class="form-group py-0 my-1 cameraSelect-wrapper"><select class="form-control cameraSelect"><select class="form-control cameraSelect" style="display: none"></select></div>');
var cameraSelect = document.querySelector('.cameraSelect');
var cameras = await Quagga.CameraAccess.enumerateVideoDevices();
cameras.forEach(camera => {
var option = document.createElement("option");
@@ -266,7 +266,7 @@ $(document).on("click", "#barcodescanner-start-button", async function(e)
Quagga.stop();
Grocy.Components.BarcodeScanner.StartScanning();
};
Grocy.Components.BarcodeScanner.StartScanning();
});

View File

@@ -132,7 +132,7 @@ Grocy.Components.DateTimePicker.GetInputElement().on('keyup', function(e)
var centuryEnd = Number.parseInt(now.getFullYear().toString().substring(0, 2) + '99');
var format = Grocy.Components.DateTimePicker.GetInputElement().data('format');
var nextInputElement = $(Grocy.Components.DateTimePicker.GetInputElement().data('next-input-selector'));
//If input is empty and any arrow key is pressed, set date to today
if (value.length === 0 && (e.keyCode === 38 || e.keyCode === 40 || e.keyCode === 37 || e.keyCode === 39))
{
@@ -224,7 +224,7 @@ Grocy.Components.DateTimePicker.GetInputElement().on('keyup', function(e)
if ($(element).hasAttr("required"))
{
element.setCustomValidity("error");
}
}
}
else
{

View File

@@ -132,7 +132,7 @@ Grocy.Components.DateTimePicker2.GetInputElement().on('keyup', function(e)
var centuryEnd = Number.parseInt(now.getFullYear().toString().substring(0, 2) + '99');
var format = Grocy.Components.DateTimePicker2.GetInputElement().data('format');
var nextInputElement = $(Grocy.Components.DateTimePicker2.GetInputElement().data('next-input-selector'));
//If input is empty and any arrow key is pressed, set date to today
if (value.length === 0 && (e.keyCode === 38 || e.keyCode === 40 || e.keyCode === 37 || e.keyCode === 39))
{
@@ -224,7 +224,7 @@ Grocy.Components.DateTimePicker2.GetInputElement().on('keyup', function(e)
if ($(element).hasAttr("required"))
{
element.setCustomValidity("error");
}
}
}
else
{

View File

@@ -50,7 +50,7 @@ Grocy.Components.ProductAmountPicker.SetQuantityUnit = function(quId)
Grocy.Components.ProductAmountPicker.AllowAnyQu = function(keepInitialQu = false)
{
Grocy.Components.ProductAmountPicker.AllowAnyQuEnabled = true;
$("#qu_id").find("option").remove().end();
Grocy.QuantityUnits.forEach(qu =>
{

View File

@@ -156,7 +156,7 @@ Grocy.Components.ProductCard.Refresh = function(productId)
{
key = dataPoint.shopping_location.name
}
if (!datasets[key]) {
datasets[key] = []
}

View File

@@ -130,13 +130,13 @@ $('#product_id_text_input').on('blur', function(e)
{
if (Grocy.Components.ProductPicker.GetPicker().hasClass("combobox-menu-visible"))
{
return;
return;
}
$('#product_id').attr("barcode", "null");
var input = $('#product_id_text_input').val().toString();
var possibleOptionElement = $("#product_id option[data-additional-searchdata*=\"" + input + ",\"]").first();
if (GetUriParam('addbarcodetoselection') === undefined && input.length > 0 && possibleOptionElement.length > 0)
{
$('#product_id').val(possibleOptionElement.val());
@@ -235,7 +235,7 @@ $(document).on("Grocy.BarcodeScanned", function(e, barcode, target)
{
return;
}
// Don't know why the blur event does not fire immediately ... this works...
Grocy.Components.ProductPicker.GetInputElement().focusout();
@@ -243,7 +243,7 @@ $(document).on("Grocy.BarcodeScanned", function(e, barcode, target)
Grocy.Components.ProductPicker.GetInputElement().blur();
Grocy.Components.ProductPicker.GetInputElement().val(barcode);
setTimeout(function()
{
Grocy.Components.ProductPicker.GetInputElement().focusout();

View File

@@ -69,7 +69,7 @@ Grocy.Components.UserfieldsForm.Load = function()
$.each(result, function(key, value)
{
var input = $(".userfield-input[data-userfield-name='" + key + "']");
if (input.attr("type") == "checkbox" && value == 1)
{
input.prop("checked", true);

View File

@@ -215,7 +215,7 @@ $("#location_id").on('change', function(e)
amount: stockEntry.amount,
text: __t("Amount: %1$s; Expires on %2$s; Bought on %3$s", stockEntry.amount, moment(stockEntry.best_before_date).format("YYYY-MM-DD"), moment(stockEntry.purchased_date).format("YYYY-MM-DD")) + "; " + openTxt
}));
sumValue = sumValue + parseFloat(stockEntry.amount);
if (stockEntry.stock_id == stockId)

View File

@@ -24,7 +24,7 @@
{
jsonData.location_id = Grocy.Components.LocationPicker.GetValue();
}
jsonData.price = price;
var bookingResponse = null;
@@ -33,7 +33,7 @@
function(result)
{
bookingResponse = result;
var addBarcode = GetUriParam('addbarcodetoselection');
if (addBarcode !== undefined)
{
@@ -62,7 +62,7 @@
function(result)
{
var successMessage = __t('Stock amount of %1$s is now %2$s', result.product.name, result.stock_amount + " " + __n(result.stock_amount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural)) + '<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)
{
window.parent.postMessage(WindowMessageBag("ProductChanged", jsonForm.product_id), Grocy.BaseUrl);
@@ -245,7 +245,7 @@ $('#new_amount').on('keyup', function(e)
function(productDetails)
{
var productStockAmount = parseFloat(productDetails.stock_amount || parseFloat('0'));
var containerWeight = parseFloat("0");
if (productDetails.product.enable_tare_weight_handling == 1)
{

View File

@@ -48,7 +48,7 @@ var calendar = $("#calendar").fullCalendar({
var weekRecipeName = view.start.year().toString() + "-" + ((view.start.week() - 1).toString().padStart(2, "0")).toString();
var weekRecipe = FindObjectInArrayByPropertyValue(internalRecipes, "name", weekRecipeName);
var weekCosts = 0;
var weekRecipeOrderMissingButtonHtml = "";
var weekRecipeConsumeButtonHtml = "";
@@ -66,7 +66,7 @@ var calendar = $("#calendar").fullCalendar({
{
weekRecipeOrderMissingButtonDisabledClasses = "disabled";
}
var weekRecipeConsumeButtonDisabledClasses = "";
if (FindObjectInArrayByPropertyValue(recipesResolved, "recipe_id", weekRecipe.id).need_fulfilled == 0 || weekCosts == 0)
{
@@ -174,7 +174,7 @@ var calendar = $("#calendar").fullCalendar({
{
return false;
}
if (productDetails.last_price === null)
{
productDetails.last_price = 0;
@@ -458,7 +458,7 @@ $('#save-add-note-button').on('click', function(e)
}
);
}
});
$('#save-add-product-button').on('click', function(e)
@@ -562,7 +562,7 @@ $(document).on('click', '.recipe-order-missing-button', function(e)
// Remove the focus from the current button
// to prevent that the tooltip stays until clicked anywhere else
document.activeElement.blur();
var objectName = $(e.currentTarget).attr('data-recipe-name');
var objectId = $(e.currentTarget).attr('data-recipe-id');
var button = $(this);

View File

@@ -482,7 +482,7 @@ $(document).on('click', '.barcode-delete-button', function(e)
});
});
$('#qu_id_purchase').blur(function(e)
$('#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');

View File

@@ -153,7 +153,7 @@ if (Grocy.Components.ProductPicker !== undefined)
$('#product_id').attr("barcode-qu-factor-purchase-to-stock", "null");
$('#product_id').attr("barcode-shopping-location-id", "null");
}
},
},
function(xhr)
{
console.error(xhr);
@@ -171,7 +171,7 @@ if (Grocy.Components.ProductPicker !== undefined)
{
$('#price').val(parseFloat(productDetails.last_price).toLocaleString({ minimumFractionDigits: 2, maximumFractionDigits: 2 }));
var qu_factor_purchase_to_stock = null;
var barcode_shopping_location_id = null;
@@ -184,14 +184,14 @@ if (Grocy.Components.ProductPicker !== undefined)
{
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
{
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 (barcode_shopping_location_id != null)
{

View File

@@ -36,10 +36,10 @@
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
}
);
if ($("#create_inverse").is(":checked"))
if ($("#create_inverse").is(":checked"))
{
jsonData.to_qu_id = inverse_to_qu_id;
jsonData.from_qu_id = inverse_from_qu_id;
jsonData.to_qu_id = inverse_to_qu_id;
jsonData.from_qu_id = inverse_from_qu_id;
jsonData.factor = 1 / jsonData.factor;
//Create Inverse
@@ -124,7 +124,7 @@ $("#create_inverse").on("change", function()
if (value)
{
$('#qu-conversion-inverse-info').removeClass('d-none');
$('#qu-conversion-inverse-info').removeClass('d-none');
}
else
{

View File

@@ -1,5 +1,5 @@
function saveRecipePicture(result, location)
{
{
$recipeId = Grocy.EditObjectId || result.created_object_id;
Grocy.Components.UserfieldsForm.Save(() =>
{
@@ -38,7 +38,7 @@ $('.save-recipe').on('click', function(e)
}
const location = $(e.currentTarget).attr('data-location') == 'return' ? '/recipes?recipe=' : '/recipe/';
if(Grocy.EditMode == 'create') {
console.log(jsonData);
Grocy.Api.Post('objects/recipes', jsonData,
@@ -210,7 +210,7 @@ $(document).on('click', '.recipe-pos-edit-button', function(e)
var productId = $(e.currentTarget).attr("data-product-id");
var recipePosId = $(e.currentTarget).attr('data-recipe-pos-id');
bootbox.dialog({
message: '<iframe height="650px" class="embed-responsive" src="' + U("/recipe/") + Grocy.EditObjectId.toString() + '/pos/' + recipePosId.toString() + '?embedded&product=' + productId.toString() + '"></iframe>',
size: 'large',
@@ -234,7 +234,7 @@ $(document).on('click', '.recipe-include-edit-button', function (e)
var id = $(e.currentTarget).attr('data-recipe-include-id');
var recipeId = $(e.currentTarget).attr('data-recipe-included-recipe-id');
var recipeServings = $(e.currentTarget).attr('data-recipe-included-recipe-servings');
Grocy.Api.Put('objects/recipes/' + Grocy.EditObjectId, $('#recipe-form').serializeJSON(),
function(result)
{

View File

@@ -49,12 +49,12 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
if (productId)
{
Grocy.Components.ProductCard.Refresh(productId);
Grocy.Api.Get('stock/products/' + productId,
function(productDetails)
{
Grocy.RecipePosFormProductChangeCount++;
if (Grocy.RecipePosFormProductChangeCount < 3) // This triggers twice on initial page load, however
{
Grocy.Components.ProductAmountPicker.Reload(productDetails.product.id, productDetails.quantity_unit_stock.id, true);

View File

@@ -62,7 +62,7 @@ $("#search").on("keyup", Delay(function()
$(".recipe-gallery-item").removeClass("d-none");
console.log( $(".recipe-gallery-item .card-title:not(:contains_case_insensitive(" + value + "))"));
$(".recipe-gallery-item .card-title:not(:contains_case_insensitive(" + value + "))").parent().parent().parent().addClass("d-none");
}, 200));
@@ -80,7 +80,7 @@ $("#status-filter").on("change", function()
$(".recipe-delete").on('click', function(e)
{
e.preventDefault();
var objectName = $(e.currentTarget).attr('data-recipe-name');
var objectId = $(e.currentTarget).attr('data-recipe-id');
@@ -245,7 +245,7 @@ $(".recipe-fullscreen").on('click', function(e)
$(".recipe-print").on('click', function(e)
{
e.preventDefault();
e.preventDefault();
$("#selectedRecipeCard").removeClass("fullscreen");
$("body").removeClass("fullscreen-card");

View File

@@ -287,7 +287,7 @@ $(document).on('click', '.order-listitem-button', function(e)
Grocy.FrontendHelpers.BeginUiBusy();
var listItemId = $(e.currentTarget).attr('data-item-id');
var done = 1;
if ($(e.currentTarget).attr('data-item-done') == 1)
{
@@ -319,7 +319,7 @@ $(document).on('click', '.order-listitem-button', function(e)
}
);
var statusInfoCell = $("#shoppinglistitem-" + listItemId + "-status-info");
if (done == 1)
{
@@ -403,7 +403,7 @@ $(".switch-view-mode-button").on('click', function(e)
if ($("body").hasClass("fullscreen-card"))
{
window.location.hash = "#compact";
window.location.hash = "#compact";
}
else
{

View File

@@ -116,7 +116,7 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
function (productDetails)
{
$('#amount_qu_unit').text(productDetails.quantity_unit_purchase.name);
$('#amount').focus();
Grocy.FrontendHelpers.ValidateForm('shoppinglist-form');
},

View File

@@ -15,7 +15,7 @@ $.fn.dataTable.ext.search.push(function(settings, data, dataIndex)
{
return true;
}
return false;
});
@@ -90,7 +90,7 @@ $(document).on('click', '.product-open-button', function(e)
var specificStockEntryId = $(e.currentTarget).attr('data-stock-id');
var stockRowId = $(e.currentTarget).attr('data-stockrow-id');
var button = $(e.currentTarget);
Grocy.Api.Post('stock/products/' + productId + '/open', { 'amount': 1, 'stock_entry_id': specificStockEntryId },
function(bookingResponse)
{
@@ -125,7 +125,7 @@ function RefreshStockEntryRow(stockRowId)
{
window.location.reload();
}
if (result == null || result.amount == 0)
{
animateCSS("#stock-" + stockRowId + "-row", "fadeOut", function()
@@ -175,7 +175,7 @@ function RefreshStockEntryRow(stockRowId)
console.error(xhr);
}
);
$('#stock-' + stockRowId + '-price').text(result.price);
$('#stock-' + stockRowId + '-qu-factor-purchase-to-stock').text(result.qu_factor_purchase_to_stock);
$('#stock-' + stockRowId + '-purchased-date').text(result.purchased_date);

View File

@@ -39,7 +39,7 @@ $("#product-group-filter").on("change", function()
{
value = "xx" + value + "xx";
}
stockOverviewTable.column(7).search(value).draw();
});
@@ -116,7 +116,7 @@ $(document).on('click', '.product-consume-button', function(e)
{
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>';
}
if (wasSpoiled)
{
toastMessage += " (" + __t("Spoiled") + ")";
@@ -244,7 +244,7 @@ function RefreshProductRow(productId)
var expiringThreshold = moment().add($("#info-expiring-products").data("next-x-days"), "days");
var now = moment();
var nextBestBeforeDate = moment(result.next_best_before_date);
productRow.removeClass("table-warning");
productRow.removeClass("table-danger");
productRow.removeClass("table-info");

View File

@@ -55,7 +55,7 @@ $('#user-form input').keydown(function (event)
if (event.keyCode === 13) //Enter
{
event.preventDefault();
if (document.getElementById('user-form').checkValidity() === false) //There is at least one validation error
{
return false;

View File

@@ -4,7 +4,7 @@
var jsonData = {};
jsonData.userentity_id = Grocy.EditObjectParentId;
Grocy.FrontendHelpers.BeginUiBusy("userobject-form");
if (Grocy.EditMode === 'create')

View File

@@ -1,42 +1,42 @@
$('input.permission-cb').click(
function () {
check_hierachy(this.checked, this.name);
}
function () {
check_hierachy(this.checked, this.name);
}
);
function check_hierachy(checked, name) {
var disabled = checked;
$('#permission-sub-' + name).find('input.permission-cb')
.prop('checked', disabled)
.attr('disabled', disabled);
var disabled = checked;
$('#permission-sub-' + name).find('input.permission-cb')
.prop('checked', disabled)
.attr('disabled', disabled);
}
$('#permission-save').click(
function () {
var permission_list = $('input.permission-cb')
.filter(function () {
return $(this).prop('checked') && !$(this).attr('disabled');
}).map(function () {
return $(this).data('perm-id');
}).toArray();
Grocy.Api.Put('users/' + Grocy.EditObjectId + '/permissions', {
'permissions': permission_list,
}, function (result) {
toastr.success(__t("Permissions saved"));
}, function (xhr) {
toastr.error(__t(JSON.parse(xhr.response).error_message));
}
);
}
function () {
var permission_list = $('input.permission-cb')
.filter(function () {
return $(this).prop('checked') && !$(this).attr('disabled');
}).map(function () {
return $(this).data('perm-id');
}).toArray();
Grocy.Api.Put('users/' + Grocy.EditObjectId + '/permissions', {
'permissions': permission_list,
}, function (result) {
toastr.success(__t("Permissions saved"));
}, 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 stop being an ADMIN?'))) {
this.checked = true;
check_hierachy(this.checked, this.name);
}
}
})
$('input.permission-cb[name=ADMIN]').click(function () {
if (!this.checked) {
if (!confirm(__t('Are you sure you want to stop being an ADMIN?'))) {
this.checked = true;
check_hierachy(this.checked, this.name);
}
}
})
}