forked from extern/egroupware
Fix up caching, clearing and filtering, so we cache what we need and clear only what we have to when filtering
Selection still needs work.
This commit is contained in:
parent
58e13743fc
commit
4d997bf7c8
@ -292,7 +292,7 @@ class etemplate_widget_nextmatch extends etemplate_widget
|
||||
|
||||
$value['start'] = (int)$queriedRange['start'];
|
||||
$value['num_rows'] = (int)$queriedRange['num_rows'];
|
||||
if($value['num_rows'] == 0) $value['num_rows'] = 20;
|
||||
if($value['num_rows'] == 0) $value['num_rows'] = self::INITIAL_ROWS;
|
||||
// if app supports parent_id / hierarchy ($value['parent_id'] not empty), set parent_id as filter
|
||||
if (($parent_id = $value['parent_id']))
|
||||
{
|
||||
|
@ -135,14 +135,22 @@ var et2_dataview_controller = Class.extend({
|
||||
// TODO: Actually stuff here should be done if the server responds that
|
||||
// there at all were some changes (needs implementation of "refresh")
|
||||
|
||||
// Tell the grid not to try and update itself while we do this
|
||||
this._grid.doInvalidate = false;
|
||||
|
||||
if(clear)
|
||||
{
|
||||
this._grid.clear.apply(this._grid,[]);
|
||||
// Scroll to top
|
||||
this._grid.makeIndexVisible(0);
|
||||
this._grid.clear();
|
||||
|
||||
// Clear the map
|
||||
this._indexMap = {}
|
||||
// Clear the queue
|
||||
this._queue = {};
|
||||
}
|
||||
// Remove all rows which are outside the view range
|
||||
this._grid.cleanup();
|
||||
|
||||
// ---------
|
||||
|
||||
// Get the currently visible range from the grid
|
||||
var range = this._grid.getIndexRange();
|
||||
@ -357,7 +365,7 @@ var et2_dataview_controller = Class.extend({
|
||||
// Insert the row into the table -- the same row must never be inserted
|
||||
// twice into the grid, so this function only executes the following
|
||||
// code only if it is a newly created row.
|
||||
if (createdRow)
|
||||
if (createdRow && _entry.row)
|
||||
{
|
||||
this._grid.insertRow(_entry.idx, _entry.row);
|
||||
}
|
||||
@ -421,6 +429,7 @@ var et2_dataview_controller = Class.extend({
|
||||
if (this._queueTimer === null && !_isUpdate)
|
||||
{
|
||||
var self = this;
|
||||
egw.debug('log', 'Dataview queue: ', _range);
|
||||
this._queueTimer = window.setTimeout(function () {
|
||||
self._flushQueue(false);
|
||||
}, ET2_DATAVIEW_FETCH_TIMEOUT);
|
||||
@ -508,8 +517,12 @@ var et2_dataview_controller = Class.extend({
|
||||
fetchList.push({
|
||||
"start": 0, "count": 0
|
||||
});
|
||||
|
||||
// Disable grid invalidate, or it might request again before we're done
|
||||
this._grid.doInvalidate = false;
|
||||
}
|
||||
|
||||
egw.debug("log", "Dataview flush", fetchList);
|
||||
// Execute all queries
|
||||
for (var i = 0; i < fetchList.length; i++)
|
||||
{
|
||||
@ -825,9 +838,15 @@ var et2_dataview_controller = Class.extend({
|
||||
this.self._selectionMgr.unregisterRow("",0,row.get(0));
|
||||
}
|
||||
|
||||
// Now it's OK to invalidate, if it wasn't before
|
||||
this.self._grid.doInvalidate = true;
|
||||
|
||||
// Update the total element count in the grid
|
||||
this.self._grid.setTotalCount(_response.total);
|
||||
this.self._selectionMgr.setTotalCount(_response.total);
|
||||
|
||||
// Schedule an invalidate, in case total is the same
|
||||
this.self._grid.invalidate();
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -152,7 +152,6 @@ var et2_dataview_selectionManager = Class.extend(
|
||||
if (!_noDelete
|
||||
&& this._registeredRows[_uid].state === EGW_AO_STATE_NORMAL)
|
||||
{
|
||||
delete this._indexMap[this._registeredRows[_uid].idx];
|
||||
delete this._registeredRows[_uid];
|
||||
}
|
||||
|
||||
|
@ -89,6 +89,9 @@ var et2_dataview_grid = et2_dataview_container.extend(et2_dataview_IViewRange,
|
||||
this._invalidateCallback = null;
|
||||
this._invalidateContext = null;
|
||||
|
||||
// Flag for stopping invalidate while working
|
||||
this.doInvalidate = true;
|
||||
|
||||
// _map contains a mapping between the grid indices and the elements
|
||||
// associated to it. The first element in the array always refers to the
|
||||
// element starting at index zero (being a spacer if the grid currently
|
||||
@ -483,9 +486,15 @@ var et2_dataview_grid = et2_dataview_container.extend(et2_dataview_IViewRange,
|
||||
window.clearTimeout(this._invalidateTimeout);
|
||||
}
|
||||
|
||||
if(!this.doInvalidate)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
var _super = this._super;
|
||||
this._invalidateTimeout = window.setTimeout(function() {
|
||||
egw.debug("log","Dataview grid timed invalidate");
|
||||
// Clear the "_avgHeight"
|
||||
self._avgHeight = false;
|
||||
self._avgCount = false;
|
||||
@ -775,7 +784,9 @@ var et2_dataview_grid = et2_dataview_container.extend(et2_dataview_IViewRange,
|
||||
var vtop = Math.max(0, vcr_top);
|
||||
var idxStart = Math.floor(
|
||||
Math.min(cidx + ccnt - 1,
|
||||
cidx + (vtop - elemRange.top) / avg));
|
||||
cidx + (vtop - elemRange.top) / avg,
|
||||
this._total
|
||||
));
|
||||
|
||||
// Calculate the end index -- prevent vtop from getting
|
||||
// negative (and so idxEnd being smaller than cidx) and
|
||||
@ -784,7 +795,9 @@ var et2_dataview_grid = et2_dataview_container.extend(et2_dataview_IViewRange,
|
||||
var vbot = Math.max(0, vcr_bot);
|
||||
var idxEnd = Math.ceil(
|
||||
Math.min(cidx + ccnt - 1,
|
||||
cidx + (vbot - elemRange.top) / avg));
|
||||
cidx + (vbot - elemRange.top) / avg,
|
||||
this._total
|
||||
));
|
||||
|
||||
// Initial resize while the grid is hidden will give NaN
|
||||
// This is an important optimisation, as it is involved in not
|
||||
@ -802,6 +815,7 @@ var et2_dataview_grid = et2_dataview_container.extend(et2_dataview_IViewRange,
|
||||
if (this._callback)
|
||||
{
|
||||
var self = this;
|
||||
egw.debug("log","Dataview grid flag for update: ", {start:idxStart,end:idxEnd});
|
||||
window.setTimeout(function() {
|
||||
// If row template changes, self._callback might disappear
|
||||
if(typeof self._callback != "undefined")
|
||||
|
@ -400,9 +400,6 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput],
|
||||
}
|
||||
}, this.activeFilters.col_filter, et2_INextmatchHeader);
|
||||
|
||||
// Explicitly the total count to zero, we're going to get some new info
|
||||
this.controller._grid.setTotalCount(0);
|
||||
|
||||
// Trigger an update
|
||||
this.controller.update(true);
|
||||
},
|
||||
|
@ -692,7 +692,6 @@ ul.et2_vfs {
|
||||
background-color: #FFFE36;
|
||||
border: 1px solid #E1E16D;
|
||||
color: #000000;
|
||||
display: none;
|
||||
font-size: 11px;
|
||||
height: 15px;
|
||||
padding: 4px 10px;
|
||||
|
Loading…
Reference in New Issue
Block a user