forked from extern/egroupware
Etemplate: Fix some nm / push bugs
- Handling for sub-grids - Fix some index issues in selectionMgr causing rows to jump around
This commit is contained in:
parent
eb5468e837
commit
a485301dd9
@ -354,8 +354,12 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
if (this._disable_autorefresh && this._indexMap[_entry.idx].uid !== _entry.uid) {
|
||||
var max = parseInt(Object.keys(this._indexMap).reduce(function (a, b) { return _this._indexMap[a] > _this._indexMap[b] ? a : b; }));
|
||||
for (var idx = max; idx >= _entry.idx; idx--) {
|
||||
var entry = this._indexMap[idx];
|
||||
this._indexMap[idx].idx = idx + 1;
|
||||
this._indexMap[this._indexMap[idx].idx] = this._indexMap[idx];
|
||||
if (this._selectionMgr && this._selectionMgr._registeredRows[entry.uid]) {
|
||||
this._selectionMgr._registeredRows[entry.uid].idx = entry.idx;
|
||||
}
|
||||
}
|
||||
this._indexMap[_entry.idx] = _entry;
|
||||
}
|
||||
|
@ -491,8 +491,13 @@ export class et2_dataview_controller
|
||||
let max = parseInt(Object.keys(this._indexMap).reduce((a, b) => this._indexMap[a] > this._indexMap[b] ? a : b));
|
||||
for(let idx = max; idx >= _entry.idx; idx--)
|
||||
{
|
||||
let entry = this._indexMap[idx];
|
||||
this._indexMap[idx].idx = idx+1;
|
||||
this._indexMap[this._indexMap[idx].idx] = this._indexMap[idx];
|
||||
if(this._selectionMgr && this._selectionMgr._registeredRows[entry.uid])
|
||||
{
|
||||
this._selectionMgr._registeredRows[entry.uid].idx = entry.idx;
|
||||
}
|
||||
}
|
||||
this._indexMap[_entry.idx] = _entry
|
||||
}
|
||||
|
@ -572,6 +572,10 @@ var et2_nextmatch = /** @class */ (function (_super) {
|
||||
// Need to delete first as there's a good chance indexes will change in an unknown way
|
||||
// and we can't always find it by UID after due to duplication
|
||||
this.controller.deleteRow(uid);
|
||||
// Trigger controller to remove from internals so we can ask for new data
|
||||
this.egw().dataStoreUID(uid, null);
|
||||
// Stop caring about this ID
|
||||
this.egw().dataDeleteUID(uid);
|
||||
// Pretend it's a new row, let app tell us where it goes and we'll mark it as new
|
||||
if (!this.refresh_add(uid, et2_nextmatch.UPDATE)) {
|
||||
// App did not want the row, or doesn't know where it goes but we've already removed it...
|
||||
@ -598,7 +602,7 @@ var et2_nextmatch = /** @class */ (function (_super) {
|
||||
// workaround for datagrid deleting the last row, see ticket #48204
|
||||
// if we only have a couple of rows, do a full refresh instead
|
||||
if (this.controller.getTotalCount() < 15 && type != et2_nextmatch.UPDATE) {
|
||||
return false;
|
||||
// return false;
|
||||
}
|
||||
// No add, do a full refresh
|
||||
if (index === false) {
|
||||
@ -651,6 +655,32 @@ var et2_nextmatch = /** @class */ (function (_super) {
|
||||
}
|
||||
return { ids: [], all: false };
|
||||
};
|
||||
/**
|
||||
* Log some debug information about internal values
|
||||
*/
|
||||
et2_nextmatch.prototype.spillYourGuts = function () {
|
||||
var guts = function (controller) {
|
||||
console.log("Controller:", controller);
|
||||
console.log("Controller indexMap:", controller._indexMap);
|
||||
console.log("Grid:", controller._grid);
|
||||
console.log("Selection Manager:", controller._selectionMgr);
|
||||
console.log("Selection registered rows:", controller._selectionMgr._registeredRows);
|
||||
if (controller && controller._children.length > 0) {
|
||||
console.groupCollapsed("Sub-grids");
|
||||
var child_index = 0;
|
||||
for (var _i = 0, _a = controller._children; _i < _a.length; _i++) {
|
||||
var child = _a[_i];
|
||||
console.groupCollapsed("Child " + (++child_index));
|
||||
guts(child);
|
||||
console.groupEnd();
|
||||
}
|
||||
console.groupEnd();
|
||||
}
|
||||
};
|
||||
console.group("Nextmatch internals");
|
||||
guts(this.controller);
|
||||
console.groupEnd();
|
||||
};
|
||||
/**
|
||||
* Event handler for when the selection changes
|
||||
*
|
||||
|
@ -865,6 +865,12 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
|
||||
// and we can't always find it by UID after due to duplication
|
||||
this.controller.deleteRow(uid);
|
||||
|
||||
// Trigger controller to remove from internals so we can ask for new data
|
||||
this.egw().dataStoreUID(uid,null);
|
||||
|
||||
// Stop caring about this ID
|
||||
this.egw().dataDeleteUID(uid);
|
||||
|
||||
// Pretend it's a new row, let app tell us where it goes and we'll mark it as new
|
||||
if(!this.refresh_add(uid, et2_nextmatch.UPDATE))
|
||||
{
|
||||
@ -896,7 +902,7 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
|
||||
// if we only have a couple of rows, do a full refresh instead
|
||||
if (this.controller.getTotalCount() < 15 && type != et2_nextmatch.UPDATE)
|
||||
{
|
||||
return false;
|
||||
// return false;
|
||||
}
|
||||
|
||||
// No add, do a full refresh
|
||||
|
@ -163,13 +163,10 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
|
||||
// Unselect
|
||||
this._selectionMgr.setSelected(uid, false);
|
||||
if (entry && entry.idx !== null) {
|
||||
this._selectionMgr.unregisterRow(uid, entry.tr);
|
||||
// This will remove the row, but add an empty to the end.
|
||||
// That's OK, because it will be removed when we update the row count
|
||||
this._grid.deleteRow(entry.idx);
|
||||
// Trigger controller to remove from internals
|
||||
this.egw.dataStoreUID(uid, null);
|
||||
// Stop caring about this ID
|
||||
this.egw.dataDeleteUID(uid);
|
||||
// Remove from internal map
|
||||
delete this._indexMap[entry.idx];
|
||||
// Update the indices of all elements after the current one
|
||||
@ -183,6 +180,7 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
|
||||
reg.idx = entry.idx;
|
||||
if (reg.ao && reg.ao._index)
|
||||
reg.ao._index = entry.idx;
|
||||
this._selectionMgr._registeredRows[entry.uid].idx = reg.idx;
|
||||
}
|
||||
}
|
||||
// Remove last one, it was moved to mapIndex-1 before increment
|
||||
@ -190,6 +188,10 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
|
||||
// Not needed, they share by reference
|
||||
// this._selectionMgr.setIndexMap(this._indexMap);
|
||||
}
|
||||
for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
|
||||
var child = _a[_i];
|
||||
child.deleteRow(uid);
|
||||
}
|
||||
};
|
||||
/** -- PRIVATE FUNCTIONS -- **/
|
||||
/**
|
||||
|
@ -192,14 +192,12 @@ export class et2_nextmatch_controller extends et2_dataview_controller implements
|
||||
|
||||
if(entry && entry.idx !== null)
|
||||
{
|
||||
this._selectionMgr.unregisterRow(uid, entry.tr);
|
||||
// This will remove the row, but add an empty to the end.
|
||||
// That's OK, because it will be removed when we update the row count
|
||||
this._grid.deleteRow(entry.idx);
|
||||
|
||||
// Trigger controller to remove from internals
|
||||
this.egw.dataStoreUID(uid,null);
|
||||
// Stop caring about this ID
|
||||
this.egw.dataDeleteUID(uid);
|
||||
|
||||
// Remove from internal map
|
||||
delete this._indexMap[entry.idx];
|
||||
|
||||
@ -216,6 +214,7 @@ export class et2_nextmatch_controller extends et2_dataview_controller implements
|
||||
var reg = this._selectionMgr._getRegisteredRowsEntry(entry.uid);
|
||||
reg.idx = entry.idx;
|
||||
if(reg.ao && reg.ao._index) reg.ao._index = entry.idx;
|
||||
this._selectionMgr._registeredRows[entry.uid].idx = reg.idx;
|
||||
}
|
||||
}
|
||||
// Remove last one, it was moved to mapIndex-1 before increment
|
||||
@ -224,6 +223,11 @@ export class et2_nextmatch_controller extends et2_dataview_controller implements
|
||||
// Not needed, they share by reference
|
||||
// this._selectionMgr.setIndexMap(this._indexMap);
|
||||
}
|
||||
|
||||
for(let child of this._children)
|
||||
{
|
||||
child.deleteRow(uid);
|
||||
}
|
||||
}
|
||||
|
||||
/** -- PRIVATE FUNCTIONS -- **/
|
||||
|
Loading…
Reference in New Issue
Block a user