mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR Rewrite of PermissionCheckboxSetField.js from Behaviour.js to jQuery.entwine
This commit is contained in:
parent
efe710e2d3
commit
2b7c633e6e
@ -1,14 +1,13 @@
|
||||
(function($) {
|
||||
Behaviour.register({
|
||||
|
||||
$.entwine('ss', function($){
|
||||
|
||||
/**
|
||||
* Automatically check and disable all checkboxes if ADMIN permissions are selected.
|
||||
* As they're disabled, any changes won't be submitted (which is intended behaviour),
|
||||
* checking all boxes is purely presentational.
|
||||
*/
|
||||
'.permissioncheckboxset .valADMIN input': {
|
||||
initialize: function() {
|
||||
this.toggleCheckboxes();
|
||||
},
|
||||
$('.permissioncheckboxset .valADMIN input').entwine({
|
||||
onclick: function(e) {
|
||||
this.toggleCheckboxes();
|
||||
},
|
||||
@ -32,20 +31,21 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* 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': {
|
||||
$('.permissioncheckboxset .valCMS_ACCESS_LeftAndMain input').entwine({
|
||||
getCheckboxesExceptThisOne: function() {
|
||||
return $(this).parents('.field:eq(0)').find('li').filter(function(i) {
|
||||
return ($(this).attr('class').match(/CMS_ACCESS_/));
|
||||
}).find('.checkbox').not(this);
|
||||
},
|
||||
initialize: function() {
|
||||
onmatch: function() {
|
||||
var checkboxes = this.getCheckboxesExceptThisOne();
|
||||
if($(this).is(':checked')) {
|
||||
checkboxes.each(function() {
|
||||
@ -53,6 +53,8 @@
|
||||
$(this).attr('checked', 'checked');
|
||||
});
|
||||
}
|
||||
|
||||
this._super();
|
||||
},
|
||||
onclick: function(e) {
|
||||
var checkboxes = this.getCheckboxesExceptThisOne();
|
||||
@ -68,6 +70,7 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}(jQuery));
|
@ -60,6 +60,8 @@ class Group extends DataObject {
|
||||
* @return FieldSet
|
||||
*/
|
||||
public function getCMSFields() {
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/PermissionCheckboxSetField.js');
|
||||
|
||||
$fields = new FieldSet(
|
||||
new TabSet("Root",
|
||||
new Tab('Members', _t('SecurityAdmin.MEMBERS', 'Members'),
|
||||
|
Loading…
Reference in New Issue
Block a user