Added correct handling of namespaces

This commit is contained in:
Andreas Stöckel 2011-08-12 16:29:24 +00:00
parent 8a420df721
commit 2fc29718f1
7 changed files with 74 additions and 7 deletions

View File

@ -169,5 +169,3 @@ var et2_placeholder = et2_baseWidget.extend({
}
});

View File

@ -29,6 +29,13 @@ var et2_box = et2_baseWidget.extend({
.addClass("et2_" + _type);
this.setDOMNode(this.div[0]);
},
set_id: function(_value) {
this._super.apply(this, arguments);
// Check whether a namespace exists for this element
this.checkCreateNamespace();
}
});

View File

@ -34,6 +34,7 @@ function et2_contentArrayMgr(_data, _parentMgr)
// Holds information about the current perspective
this.perspectiveData = {
"owner": null,
"key": null,
"col": 0,
"row": 0
@ -140,8 +141,10 @@ et2_contentArrayMgr.prototype.expandName = function(_ident)
{
_ident = this.getRoot().getEntry(_ident.substr(2));
}
_ident = this.getEntry(_ident.substr(1));
else
{
_ident = this.getEntry(_ident.substr(1));
}
}
return _ident;
@ -183,7 +186,7 @@ et2_contentArrayMgr.prototype.parseBoolExpression = function(_expression)
return val != '' && (typeof val != "string" || val.toLowerCase() != "false");
}
et2_contentArrayMgr.prototype.openPerspective = function(_root, _col, _row)
et2_contentArrayMgr.prototype.openPerspective = function(_owner, _root, _col, _row)
{
// Get the root node
var root = typeof _root == "string" ? this.data[_root] :
@ -192,6 +195,9 @@ et2_contentArrayMgr.prototype.openPerspective = function(_root, _col, _row)
// Create a new content array manager with the given root
var mgr = new et2_contentArrayMgr(root, this);
// Set the owner
mgr.perspectiveData.owner = _owner;
// Set the root key
if (typeof _root == "string")
{

View File

@ -489,6 +489,12 @@ var et2_grid = et2_DOMWidget.extend({
// Create the table
this.createTableFromCells(cells);
// Copy a reference to the content array manager
if (_obj._mgr)
{
this._mgr = _obj._mgr;
}
}
else
{
@ -514,6 +520,13 @@ var et2_grid = et2_DOMWidget.extend({
}
return null;
},
set_id: function(_value) {
this._super.apply(this, arguments);
// Check whether a namespace exists for this element
this.checkCreateNamespace();
}
});

View File

@ -136,6 +136,9 @@ var et2_template = et2_DOMWidget.extend({
else
{
this._super(_value);
// Check whether a namespace exists for this element
this.checkCreateNamespace();
}
}
},

View File

@ -136,6 +136,7 @@ var et2_widget = Class.extend({
// Delete all references to other objects
this._children = [];
this._parent = null;
this._mgr = null;
this.onSetParent();
},
@ -176,6 +177,12 @@ var et2_widget = Class.extend({
this.setAttribute(key, _obj.getAttribute(key));
}
}
// Copy a reference to the content array manager
if (_obj._mgr)
{
this._mgr = _obj._mgr;
}
},
/**
@ -498,8 +505,38 @@ var et2_widget = Class.extend({
}
return _target;
}
},
/**
* Checks whether a namespace exists for this element in the content array.
* If yes, an own perspective of the content array is created. If not, the
* parent content manager is used.
*/
checkCreateNamespace: function() {
// Get the content manager
var mgr = this.getContentMgr();
// Get the original content manager if we have already created a
// perspective for this node
if (this._mgr != null && this._mgr.perspectiveData.owner == this)
{
mgr = mgr.parentMgr;
}
// Check whether the manager has a namespace for the id of this object
if (mgr.getEntry(this.id) instanceof Object)
{
// The content manager has a own node for this object, so create
// an own perspective.
this._mgr = mgr.openPerspective(this, this.id);
}
else
{
// The current content manager does not have an own namespace for
// this element, so use the content manager of the parent.
this._mgr = null;
}
}
});

View File

@ -1,4 +1,7 @@
var expression_test_data = {
"display_text": "true"
"test": {
"display_text": "true"
},
"display_text": "false"
};