Permalink
Browse files

MINOR Better failsafes for tree hints (allows add if hint for class i…

…s if not defined)
  • Loading branch information...
1 parent d88075e commit e34f56dcc6a2adffd7bea818ebc61edb5384d7f4 @chillu chillu committed Jan 9, 2012
Showing with 5 additions and 2 deletions.
  1. +5 −2 javascript/CMSMain.AddForm.js
@@ -44,8 +44,11 @@
metadata = this.find('#ParentID .TreeDropdownField').data('metadata'),
id = this.find('#ParentID .TreeDropdownField').getValue(),
newClassName = metadata ? metadata.ClassName : null,
- disallowedChildren = hints[newClassName ? newClassName : 'Root'].disallowedChildren || [],
- defaultChildClass = hints[newClassName ? newClassName : 'Root'].defaultChild || null;
+ hintKey = newClassName ? newClassName : 'Root',
+ hint = (typeof hints[hintKey] != 'undefined') ? hints[key] : null;
+
+ var disallowedChildren = (hint && typeof hint.disallowedChildren != 'undefined') ? hint.disallowedChildren : [],
+ defaultChildClass = (hint && typeof hint.defaultChild != 'undefined') ? hint.defaultChild : null;
// Limit selection
this.find('#PageType li').each(function() {

0 comments on commit e34f56d

Please sign in to comment.