grocy/public/viewjs/userpermissions.js
Bernd Bestel cf34df5e3f
Squashed commit
Fixed some localization strings
Reviewed/optimized product deletion handling
Add option to hide products from the stock overview page (closes #906)
Prefill default_due_days also on the inventory page (closes #591)
Added DataTables accent chinese-string plugin (closes #872)
Show costs and calories per recipe ingredient (closes #1072)
Fixed user permission saving (fixes #1099)
User permissions should not have an effect for demo mode (closes #972)
Handle QU conversion when consuming a substituation (child) product (fixes #1118)
Consume/open any child product when the parent product is not in stock (closes #899)
Added a retry camera barcode scanning button to product picker workflow (closes #736)
2020-12-07 19:48:33 +01:00

55 lines
1.1 KiB
JavaScript

$('input.permission-cb').click(
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);
}
$('#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(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?')))
{
this.checked = true;
check_hierachy(this.checked, this.name);
}
}
})
}