mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 09:05:16 +01:00
Added correct handling of namespaces for the getValues function
This commit is contained in:
parent
2fc29718f1
commit
0c71ee3931
@ -40,5 +40,5 @@ var et2_box = et2_baseWidget.extend({
|
||||
|
||||
});
|
||||
|
||||
et2_register_widget(et2_box, ["hbox", "vbox"]);
|
||||
et2_register_widget(et2_box, ["hbox", "vbox", "box"]);
|
||||
|
||||
|
@ -64,6 +64,32 @@ et2_contentArrayMgr.prototype.getValueForID = function(_id)
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path to this content array manager perspective as an array
|
||||
* containing the key values
|
||||
*
|
||||
* @param _path is used internally, do not supply it manually.
|
||||
*/
|
||||
et2_contentArrayMgr.prototype.getPath = function(_path)
|
||||
{
|
||||
if (typeof _path == "undefined")
|
||||
{
|
||||
_path = [];
|
||||
}
|
||||
|
||||
if (this.perspectiveData.key != null)
|
||||
{
|
||||
_path.push(this.perspectiveData.key);
|
||||
}
|
||||
|
||||
if (this.parentMgr != null)
|
||||
{
|
||||
this.parentMgr.getPath(_path);
|
||||
}
|
||||
|
||||
return _path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array entry is the equivalent to the boetemplate get_array function.
|
||||
* It returns a reference to the (sub) array with the given key. This also works
|
||||
@ -201,7 +227,7 @@ et2_contentArrayMgr.prototype.openPerspective = function(_owner, _root, _col, _r
|
||||
// Set the root key
|
||||
if (typeof _root == "string")
|
||||
{
|
||||
mgr.perspectiveData.key == _root;
|
||||
mgr.perspectiveData.key = _root;
|
||||
}
|
||||
|
||||
// Set the _col and _row parameter
|
||||
|
@ -477,34 +477,52 @@ var et2_widget = Class.extend({
|
||||
* Fetches all input element values and returns them in an associative
|
||||
* array. Widgets which introduce namespacing can use the internal _target
|
||||
* parameter to add another layer.
|
||||
*
|
||||
* @param _target is used internally and should no be supplied.
|
||||
*/
|
||||
getValues: function(_target) {
|
||||
if (typeof _target == "undefined")
|
||||
{
|
||||
_target = {};
|
||||
}
|
||||
getValues: function() {
|
||||
var result = {};
|
||||
|
||||
// Add the value of this element to the result object
|
||||
if (this.implements(et2_IInput))
|
||||
{
|
||||
if (typeof _target[this.id] != "undefined")
|
||||
// Iterate over the widget tree
|
||||
this.iterateOver(function(_widget) {
|
||||
|
||||
// Get the path to the node we have to store the value at
|
||||
var path = _widget.getContentMgr().getPath();
|
||||
|
||||
// Set the _target variable to that node
|
||||
var _target = result;
|
||||
for (var i = 0; i < path.length; i++)
|
||||
{
|
||||
// Create a new object for not-existing path nodes
|
||||
if (typeof _target[path[i]] == "undefined")
|
||||
{
|
||||
_target[path[i]] = {};
|
||||
}
|
||||
|
||||
// Check whether the path node is really an object
|
||||
if (_target[path[i]] instanceof Object)
|
||||
{
|
||||
_target = _target[path[i]];
|
||||
}
|
||||
else
|
||||
{
|
||||
et2_debug("error", "ID collision while writing at path " +
|
||||
"node '" + path[i] + "'");
|
||||
}
|
||||
}
|
||||
|
||||
// Check whether the entry is really undefined
|
||||
if (typeof _target[_widget.id] != "undefined")
|
||||
{
|
||||
et2_debug("error", "Overwriting value of '" + this.id +
|
||||
"', id exists twice!");
|
||||
}
|
||||
|
||||
_target[this.id] = this.getValue();
|
||||
}
|
||||
// Store the value of the widget and reset its dirty flag,
|
||||
_target[_widget.id] = _widget.getValue();
|
||||
_widget.resetDirty();
|
||||
|
||||
// Store the values of the children in the target array
|
||||
for (var i = 0; i < this._children.length; i++)
|
||||
{
|
||||
this._children[i].getValues(_target);
|
||||
}
|
||||
}, this, et2_IInput);
|
||||
|
||||
return _target;
|
||||
return result;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,9 @@
|
||||
var expression_test_data = {
|
||||
"test": {
|
||||
"display_text": "true"
|
||||
"display_text": "true",
|
||||
"textbox": "And this is the inner textbox."
|
||||
},
|
||||
"display_text": "false"
|
||||
"display_text": "false",
|
||||
"textbox": "This is the outer textbox."
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
<overlay>
|
||||
<template id="test">
|
||||
<description disabled="!@display_text" value="Dies ist nur ein test!" />
|
||||
<vbox>
|
||||
<description disabled="!@display_text" value="Dies ist nur ein test!" />
|
||||
<textbox id="textbox" />
|
||||
</vbox>
|
||||
</template>
|
||||
<textbox id="textbox" />
|
||||
</overlay>
|
||||
|
Loading…
Reference in New Issue
Block a user