Fixed selection and getSelected() function; controllers and selection managers are now hirachical

This commit is contained in:
Andreas Stöckel
2012-03-30 14:20:11 +00:00
parent 4cdc5f39c1
commit f50b880c19
7 changed files with 117 additions and 26 deletions

View File

@ -27,15 +27,23 @@
*/
var et2_dataview_selectionManager = Class.extend({
init: function (_indexMap, _actionObjectManager, _queryRangeCallback,
_makeVisibleCallback, _context) {
init: function (_parent, _indexMap, _actionObjectManager,
_queryRangeCallback, _makeVisibleCallback, _context) {
// Copy the arguments
this._parent = _parent;
this._indexMap = _indexMap;
this._actionObjectManager = _actionObjectManager;
this._queryRangeCallback = _queryRangeCallback;
this._makeVisibleCallback = _makeVisibleCallback;
this._context = _context;
// Attach this manager to the parent manager if one is given
if (this._parent)
{
this._parent._children.push(this);
}
// Internal map which contains all curently selected uids and their
// state
this._registeredRows = {};
@ -43,6 +51,29 @@ var et2_dataview_selectionManager = Class.extend({
this._invertSelection = false;
this._inUpdate = false;
this._total = 0;
this._children = [];
},
destroy: function () {
// If we have a parent, unregister from that
if (this._parent)
{
var idx = this._parent._children.indexOf(this);
this._parent._children.splice(idx, 1);
}
// Destroy all children
for (var i = this._children.length - 1; i >= 0; i--)
{
this._children[i].free();
}
// Delete all still registered rows
for (var key in this._registeredRows)
{
this.unregisterRow(key, this._registeredRows[key].tr);
}
},
setIndexMap: function (_indexMap) {
@ -169,6 +200,12 @@ var et2_dataview_selectionManager = Class.extend({
}
}
// Push all events of the child managers onto the list
for (var i = 0; i < this._children.length; i++)
{
ids = ids.concat(this._children[i].getSelected().ids);
}
// Return an array containing those ids
return {
"inverted": this._invertSelection,
@ -360,6 +397,7 @@ var et2_dataview_selectionManager = Class.extend({
if (!_ctrl)
{
this.resetSelection();
this._actionObjectManager.setAllSelected(false); // needed for hirachical stuff
}
// Mark the element that was clicked as selected