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($) {
|
(function($) {
|
||||||
Behaviour.register({
|
|
||||||
|
$.entwine('ss', function($){
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Automatically check and disable all checkboxes if ADMIN permissions are selected.
|
* 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),
|
* As they're disabled, any changes won't be submitted (which is intended behaviour),
|
||||||
* checking all boxes is purely presentational.
|
* checking all boxes is purely presentational.
|
||||||
*/
|
*/
|
||||||
'.permissioncheckboxset .valADMIN input': {
|
$('.permissioncheckboxset .valADMIN input').entwine({
|
||||||
initialize: function() {
|
|
||||||
this.toggleCheckboxes();
|
|
||||||
},
|
|
||||||
onclick: function(e) {
|
onclick: function(e) {
|
||||||
this.toggleCheckboxes();
|
this.toggleCheckboxes();
|
||||||
},
|
},
|
||||||
@ -32,20 +31,21 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Automatically check all "CMS section" checkboxes when "Access to all CMS interfaces" is ticked.
|
* 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
|
* @todo This should really be abstracted into a declarative dependency system
|
||||||
* instead of custom logic.
|
* instead of custom logic.
|
||||||
*/
|
*/
|
||||||
'.permissioncheckboxset .valCMS_ACCESS_LeftAndMain input': {
|
$('.permissioncheckboxset .valCMS_ACCESS_LeftAndMain input').entwine({
|
||||||
getCheckboxesExceptThisOne: function() {
|
getCheckboxesExceptThisOne: function() {
|
||||||
return $(this).parents('.field:eq(0)').find('li').filter(function(i) {
|
return $(this).parents('.field:eq(0)').find('li').filter(function(i) {
|
||||||
return ($(this).attr('class').match(/CMS_ACCESS_/));
|
return ($(this).attr('class').match(/CMS_ACCESS_/));
|
||||||
}).find('.checkbox').not(this);
|
}).find('.checkbox').not(this);
|
||||||
},
|
},
|
||||||
initialize: function() {
|
onmatch: function() {
|
||||||
var checkboxes = this.getCheckboxesExceptThisOne();
|
var checkboxes = this.getCheckboxesExceptThisOne();
|
||||||
if($(this).is(':checked')) {
|
if($(this).is(':checked')) {
|
||||||
checkboxes.each(function() {
|
checkboxes.each(function() {
|
||||||
@ -53,6 +53,8 @@
|
|||||||
$(this).attr('checked', 'checked');
|
$(this).attr('checked', 'checked');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._super();
|
||||||
},
|
},
|
||||||
onclick: function(e) {
|
onclick: function(e) {
|
||||||
var checkboxes = this.getCheckboxesExceptThisOne();
|
var checkboxes = this.getCheckboxesExceptThisOne();
|
||||||
@ -68,6 +70,7 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}(jQuery));
|
}(jQuery));
|
@ -60,6 +60,8 @@ class Group extends DataObject {
|
|||||||
* @return FieldSet
|
* @return FieldSet
|
||||||
*/
|
*/
|
||||||
public function getCMSFields() {
|
public function getCMSFields() {
|
||||||
|
Requirements::javascript(SAPPHIRE_DIR . '/javascript/PermissionCheckboxSetField.js');
|
||||||
|
|
||||||
$fields = new FieldSet(
|
$fields = new FieldSet(
|
||||||
new TabSet("Root",
|
new TabSet("Root",
|
||||||
new Tab('Members', _t('SecurityAdmin.MEMBERS', 'Members'),
|
new Tab('Members', _t('SecurityAdmin.MEMBERS', 'Members'),
|
||||||
|
Loading…
Reference in New Issue
Block a user