ENHANCEMENT Automatically checking all "CMS section" checkboxes in PermissionCheckboxSetField.js when "Access to all CMS interfaces" is selected. Saving these permissions individually also resolves certain edge cases like #5438.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@103328 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-04-22 00:12:07 +00:00 committed by Sam Minnee
parent 2107985272
commit 09d0ee9de2

View File

@ -32,6 +32,37 @@
});
}
}
},
/**
* Automatically check all "CMS section" checkboxes when "Access to all CMS interfaces" is ticked.
*
* @todo This should really be abstracted into a declarative dependency system
* instead of custom logic.
*/
'.permissioncheckboxset .valCMS_ACCESS_LeftAndMain input': {
initialize: function() {
this.toggleCheckboxes();
},
onclick: function(e) {
this.toggleCheckboxes();
},
toggleCheckboxes: function() {
var checkboxes = $(this).parents('.field:eq(0)').find('li').filter(function(i) {
return ($(this).attr('class').match(/CMS_ACCESS_/));
}).find('.checkbox').not(this);
if($(this).is(':checked')) {
checkboxes.each(function() {
$(this).attr('disabled', 'disabled');
$(this).attr('checked', 'checked');
});
} else {
checkboxes.each(function() {
$(this).attr('checked', '');
$(this).attr('disabled', '');
});
}
}
}
});
}(jQuery));