fix for recurring_invoice permissions (#2159)

This commit is contained in:
David Bomba 2018-06-10 21:15:04 +10:00 committed by GitHub
parent f4db62cf51
commit 3c8b1791ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -130,20 +130,7 @@
@section('onReady') @section('onReady')
//start legacy
$('#first_name').focus(); $('#first_name').focus();
$('#is_admin, #permissions_view_all').change(fixCheckboxes);
function fixCheckboxes(){
var adminChecked = $('#is_admin').is(':checked');
var viewChecked = $('#permissions_view_all').is(':checked');
$('#permissions_view_all').prop('disabled', adminChecked);
$('#permissions_create_all').prop('disabled', adminChecked);
$('#permissions_edit_all').prop('disabled', adminChecked || !viewChecked);
if(!viewChecked)$('#permissions_edit_all').prop('checked',false)
}
fixCheckboxes();
//end legacy
/* /*
* *
@ -154,7 +141,13 @@
$("input[type='checkbox'][id^='view_']").each(function() { $("input[type='checkbox'][id^='view_']").each(function() {
var entity = $(this).attr('id').split("_")[1].replace("]",""); //get entity name var entity = $(this).attr('id')
.replace('create_',"")
.replace('view_',"")
.replace('edit_',"")
.replace(']',"")
.replace('[',""); //get entity name
$('#edit_' + entity).prop('disabled', !$('#view_' + entity).is(':checked')); //set state of edit checkbox $('#edit_' + entity).prop('disabled', !$('#view_' + entity).is(':checked')); //set state of edit checkbox
}); });
@ -168,7 +161,12 @@
$("input[type='checkbox'][id^='view_']").change(function(){ $("input[type='checkbox'][id^='view_']").change(function(){
var entity = $(this).attr('id').split("_")[1].replace("]",""); //get entity name var entity = $(this).attr('id')
.replace('create_',"")
.replace('view_',"")
.replace('edit_',"")
.replace(']',"")
.replace('[',""); //get entity name
$('#edit_' + entity).prop('disabled', !$('#view_' + entity).is(':checked')); //set state of edit checkbox $('#edit_' + entity).prop('disabled', !$('#view_' + entity).is(':checked')); //set state of edit checkbox
@ -185,15 +183,25 @@
$("input[type='checkbox'][id^=" + permission_type + "]").each(function() { $("input[type='checkbox'][id^=" + permission_type + "]").each(function() {
var entity = $(this).attr('id').split("_")[1].replace("]",""); //get entity name var entity = $(this).attr('id')
.replace('create_',"")
.replace('view_',"")
.replace('edit_',"")
.replace(']',"")
.replace('[',""); //get entity name
$('#' + permission_type + entity).prop('checked', checked); //set state of edit checkbox $('#' + permission_type + entity).prop('checked', checked); //set state of edit checkbox
if(!$('#view_' + entity).is(':checked')) { if(!$('#view_' + entity).is(':checked')) {
$('#edit_' + entity).prop('checked', false); //remove checkbox value from edit dependant on View state. $('#edit_' + entity).prop('checked', false); //remove checkbox value from edit dependant on View state.
} }
$('#edit_' + entity).prop('disabled', !$('#view_' + entity).is(':checked')); //set state of edit checkbox
}); });
}); });