2011-08-29 17:04:10 +02:00
|
|
|
/**
|
|
|
|
* eGroupWare eTemplate2 - Class which contains an management tree for the grid rows
|
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package etemplate
|
|
|
|
* @subpackage dataview
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Andreas Stöckel
|
|
|
|
* @copyright Stylite 2011
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
"use strict"
|
|
|
|
|
|
|
|
/*egw:uses
|
|
|
|
et2_core_common; // for et2_range functions
|
|
|
|
et2_core_inheritance;
|
|
|
|
|
2011-09-02 18:15:57 +02:00
|
|
|
et2_dataview_interfaces;
|
2011-08-29 17:04:10 +02:00
|
|
|
|
2011-09-02 18:15:57 +02:00
|
|
|
et2_dataview_view_partitionOrganizationNode;
|
|
|
|
et2_dataview_view_partitionContainerNodes;
|
|
|
|
*/
|
2011-08-29 17:04:10 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Main class for the usage of the partition tree
|
|
|
|
*/
|
|
|
|
var et2_dataview_partitionTree = et2_dataview_partitionOrganizationNode.extend({
|
|
|
|
|
2011-08-31 17:39:24 +02:00
|
|
|
init: function(_dataProvider, _rowProvider, _avgHeight, _node) {
|
|
|
|
this._super(this);
|
|
|
|
|
|
|
|
this._avgHeight = _avgHeight;
|
|
|
|
this._node = _node;
|
|
|
|
this._count = _dataProvider.getCount();
|
2011-08-29 17:04:10 +02:00
|
|
|
|
2011-08-31 17:39:24 +02:00
|
|
|
this._dataProvider = _dataProvider;
|
|
|
|
this._rowProvider = _rowProvider;
|
|
|
|
|
2012-03-05 14:07:38 +01:00
|
|
|
egw.debug("Creating partition tree with ", this._count,
|
2011-08-31 17:39:24 +02:00
|
|
|
" elements of avgHeight ", this._avgHeight);
|
|
|
|
|
|
|
|
// Append a spacer node to the children
|
|
|
|
var ph = new et2_dataview_partitionSpacerNode(this, this._count,
|
|
|
|
this._avgHeight);
|
2011-08-29 17:04:10 +02:00
|
|
|
ph.setParent(this);
|
2011-08-31 17:39:24 +02:00
|
|
|
ph.initializeContainer();
|
2011-08-29 17:04:10 +02:00
|
|
|
|
|
|
|
this._children = [ph];
|
2011-08-31 17:39:24 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
getAverageHeight: function() {
|
|
|
|
var data = {"count": 0, "height": 0};
|
|
|
|
|
|
|
|
this.getAvgHeightData(data);
|
|
|
|
|
|
|
|
if (data.count == 0)
|
|
|
|
{
|
|
|
|
return this._avgHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
return data.height / data.count;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the actual count of managed objects inside of the tree - getCount
|
|
|
|
* in contrast returns the count of "virtual" objects including the
|
|
|
|
* spacers.
|
|
|
|
*/
|
|
|
|
getManagedCount: function() {
|
|
|
|
var data = {"count": 0, "height": 0};
|
|
|
|
this.getAvgHeightData(data);
|
|
|
|
|
|
|
|
return data.count;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the node after which new nodes have to be inserted for the given
|
|
|
|
* index.
|
|
|
|
*/
|
|
|
|
getNodeAt: function(_idx) {
|
|
|
|
|
|
|
|
// Insert the given node to the top of the parent container
|
|
|
|
if (_idx < 0)
|
|
|
|
{
|
|
|
|
return this._node;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise search for the tree node with that index
|
|
|
|
return this._super(_idx);
|
|
|
|
},
|
|
|
|
|
|
|
|
getRowProvider: function() {
|
|
|
|
return this._rowProvider;
|
|
|
|
},
|
|
|
|
|
|
|
|
getDataProvider: function() {
|
|
|
|
return this._dataProvider;
|
2011-08-29 17:04:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|