mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
MINOR Selection bugfixes for CMSMain.AddForm.js, more efficient tree metadata
This commit is contained in:
parent
6dd0535442
commit
6887b88099
@ -230,7 +230,6 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
$classes = ClassInfo::subclassesFor( $this->stat('tree_class') );
|
||||
|
||||
$def['Root'] = array();
|
||||
$def['Root']['disallowedChildren'] = array();
|
||||
$def['Root']['disallowedParents'] = array();
|
||||
|
||||
foreach($classes as $class) {
|
||||
@ -242,8 +241,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
|
||||
// SiteTree::allowedChildren() returns null rather than an empty array if SiteTree::allowed_chldren == 'none'
|
||||
if($allowedChildren == null) $allowedChildren = array();
|
||||
|
||||
$def[$class]['disallowedChildren'] = array_keys(array_diff($classes, $allowedChildren));
|
||||
$allowedChildren = array_keys(array_diff($classes, $allowedChildren));
|
||||
if($allowedChildren) $def[$class]['disallowedChildren'] = $allowedChildren;
|
||||
|
||||
$defaultChild = $obj->defaultChild();
|
||||
|
||||
@ -255,7 +254,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
||||
|
||||
if ($defaultParent != 1 && $defaultParent != null) $def[$class]['defaultParent'] = $defaultParent;
|
||||
|
||||
if(is_array($def[$class]['disallowedChildren'])) {
|
||||
if(isset($def[$class]['disallowedChildren'])) {
|
||||
foreach($def[$class]['disallowedChildren'] as $disallowedChild) {
|
||||
$def[$disallowedChild]['disallowedParents'][] = $class;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
this.find('#ParentID .TreeDropdownField').bind('change', function() {
|
||||
self.updateTypeList();
|
||||
});
|
||||
this.updateTypeList();
|
||||
},
|
||||
|
||||
/**
|
||||
@ -42,7 +43,7 @@
|
||||
var hints = this.find('.hints').data('hints'),
|
||||
metadata = this.find('#ParentID .TreeDropdownField').data('metadata'),
|
||||
id = this.find('#ParentID .TreeDropdownField').getValue(),
|
||||
newClassName = metadata.ClassName,
|
||||
newClassName = metadata ? metadata.ClassName : null,
|
||||
disallowedChildren = hints[newClassName ? newClassName : 'Root'].disallowedChildren || [],
|
||||
defaultChildClass = hints[newClassName ? newClassName : 'Root'].defaultChild || null;
|
||||
|
||||
@ -64,12 +65,20 @@
|
||||
});
|
||||
|
||||
$(".cms-add-form #PageType li").entwine({
|
||||
onclick: function() {
|
||||
this.setSelected(true);
|
||||
},
|
||||
setSelected: function(bool) {
|
||||
this.toggleClass('selected', bool);
|
||||
if(bool) {
|
||||
this.siblings().setSelected(false);
|
||||
this.find('input').attr('checked', 'checked');
|
||||
}
|
||||
},
|
||||
setEnabled: function(bool) {
|
||||
$(this).toggleClass('disabled', bool);
|
||||
$(this).find('input').attr('disabled', bool ? '' : 'disabled');
|
||||
$(this).toggleClass('disabled', !bool);
|
||||
if(!bool) $(this).find('input').attr('disabled', 'disabled').removeAttr('checked');
|
||||
else $(this).find('input').removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user