Permalink
Browse files

MINOR Selection bugfixes for CMSMain.AddForm.js, more efficient tree …

…metadata
  • Loading branch information...
1 parent 6dd0535 commit 6887b88099655adbd4feb5b1e011c7348642e4af @chillu chillu committed Jan 5, 2012
Showing with 15 additions and 7 deletions.
  1. +3 −4 code/controllers/CMSMain.php
  2. +12 −3 javascript/CMSMain.AddForm.js
View
7 code/controllers/CMSMain.php
@@ -230,7 +230,6 @@ public function SiteTreeHints() {
$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 @@ public function SiteTreeHints() {
// 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 @@ public function SiteTreeHints() {
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;
}
View
15 javascript/CMSMain.AddForm.js
@@ -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');
}
});

0 comments on commit 6887b88

Please sign in to comment.