mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-22 13:58:40 +01:00
Added getValues() function to the base widget which creates an associative 'array' with all form values.
This commit is contained in:
parent
2a95927fc8
commit
b9bb6280e3
@ -440,6 +440,9 @@ var et2_grid = et2_DOMWidget.extend({
|
|||||||
assign: function(_obj) {
|
assign: function(_obj) {
|
||||||
if (_obj instanceof et2_grid)
|
if (_obj instanceof et2_grid)
|
||||||
{
|
{
|
||||||
|
// Remember all widgets which have already been instanciated
|
||||||
|
var instances = [];
|
||||||
|
|
||||||
// Copy the cells array of the other grid and clone the widgets
|
// Copy the cells array of the other grid and clone the widgets
|
||||||
// inside of it
|
// inside of it
|
||||||
var cells = new Array(_obj.cells.length);
|
var cells = new Array(_obj.cells.length);
|
||||||
@ -451,10 +454,32 @@ var et2_grid = et2_DOMWidget.extend({
|
|||||||
for (var x = 0; x < _obj.cells[y].length; x++)
|
for (var x = 0; x < _obj.cells[y].length; x++)
|
||||||
{
|
{
|
||||||
var srcCell = _obj.cells[y][x];
|
var srcCell = _obj.cells[y][x];
|
||||||
|
|
||||||
|
var widget = null;
|
||||||
|
if (srcCell.widget)
|
||||||
|
{
|
||||||
|
// Search for the widget inside the instances array
|
||||||
|
for (var i = 0; i < instances.length; i++)
|
||||||
|
{
|
||||||
|
if (instances[i].srcWidget == srcCell.widget)
|
||||||
|
{
|
||||||
|
widget = instances[i].widget;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (widget == null)
|
||||||
|
{
|
||||||
|
widget = srcCell.widget.clone(this, srcCell.widget.type);
|
||||||
|
instances.push({
|
||||||
|
"widget": widget,
|
||||||
|
"srcWidget": srcCell.widget
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cells[y][x] = {
|
cells[y][x] = {
|
||||||
"widget": (srcCell.widget ?
|
"widget": widget,
|
||||||
srcCell.widget.clone(this, srcCell.widget.type) :
|
|
||||||
null),
|
|
||||||
"td": null,
|
"td": null,
|
||||||
"colSpan": srcCell.colSpan,
|
"colSpan": srcCell.colSpan,
|
||||||
"rowSpan": srcCell.rowSpan
|
"rowSpan": srcCell.rowSpan
|
||||||
@ -464,7 +489,6 @@ var et2_grid = et2_DOMWidget.extend({
|
|||||||
|
|
||||||
// Create the table
|
// Create the table
|
||||||
this.createTableFromCells(cells);
|
this.createTableFromCells(cells);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -96,7 +96,9 @@ var et2_inputWidget = et2_baseWidget.extend(et2_IInput, {
|
|||||||
var node = this.getInputNode();
|
var node = this.getInputNode();
|
||||||
if (node)
|
if (node)
|
||||||
{
|
{
|
||||||
return $j(node).val();
|
var val = $j(node).val();
|
||||||
|
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._oldValue;
|
return this._oldValue;
|
||||||
|
@ -142,6 +142,19 @@ var et2_template = et2_DOMWidget.extend({
|
|||||||
|
|
||||||
getDOMNode: function(_fromProxy) {
|
getDOMNode: function(_fromProxy) {
|
||||||
return this.div;
|
return this.div;
|
||||||
|
},
|
||||||
|
|
||||||
|
getValues: function(_target) {
|
||||||
|
if (this.proxiedTemplate)
|
||||||
|
{
|
||||||
|
return this.proxiedTemplate.getValues(_target);
|
||||||
|
}
|
||||||
|
else if (!this.isProxied)
|
||||||
|
{
|
||||||
|
return this._super(_target);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _target;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -442,6 +442,40 @@ var et2_widget = Class.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the value of this element to the result object
|
||||||
|
if (this.implements(et2_IInput))
|
||||||
|
{
|
||||||
|
if (typeof _target[this.id] != "undefined")
|
||||||
|
{
|
||||||
|
et2_debug("error", "Overwriting value of '" + this.id +
|
||||||
|
"', id exists twice!");
|
||||||
|
}
|
||||||
|
|
||||||
|
_target[this.id] = this.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store the values of the children in the target array
|
||||||
|
for (var i = 0; i < this._children.length; i++)
|
||||||
|
{
|
||||||
|
this._children[i].getValues(_target);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _target;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<overlay>
|
<overlay>
|
||||||
<textbox value="This is a single line textbox." statustext="Write something here!"/>
|
<textbox id="test1" value="This is a single line textbox." statustext="Write something here!"/>
|
||||||
<textbox multiline="true" value="This is a multi line textbox."/>
|
<textbox id="test2" multiline="true" value="This is a multi line textbox."/>
|
||||||
|
|
||||||
<template id="testbox">
|
<template id="testbox">
|
||||||
<textbox value="This is a single line textbox." statustext="And something else here!"/>
|
<textbox id="test3" value="This is a single line textbox." statustext="And something else here!"/>
|
||||||
<textbox multiline="true" value="This is a multi line textbox."/>
|
<textbox id="test4" multiline="true" value="This is a multi line textbox."/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template id="testbox"/>
|
<template id="testbox"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user