Etemplate: Fix editing entry so it no longer matched current filters would cause missing rows and incorrect total

This commit is contained in:
nathangray 2020-10-02 10:38:49 -06:00
parent 55b615af5f
commit f07303b321
4 changed files with 34 additions and 25 deletions

View File

@ -550,6 +550,12 @@ var et2_nextmatch = /** @class */ (function (_super) {
this.type == et2_nextmatch.ADD ? this.nm.refresh_add(this.uid, this.type)
: this.nm.refresh_update(this.uid);
}
else if (this.type == et2_nextmatch.UPDATE) {
// Remove row from controller
this.nm.controller.deleteRow(this.uid);
// Adjust total rows, clean grid
this.nm.controller._grid.setTotalCount(this.nm.controller._grid._total - _row_ids.length);
}
}, { type: _type, nm: this_1, uid: uid_1 }, [_row_ids]);
return { value: void 0 };
}
@ -622,34 +628,30 @@ var et2_nextmatch = /** @class */ (function (_super) {
*/
et2_nextmatch.prototype.refresh_add = function (uid, type) {
if (type === void 0) { type = et2_nextmatch.ADD; }
var _a, _b;
var index = egw.preference("lazy-update") !== "exact" ? 0 :
(this.is_sorted_by_modified() ? 0 : false);
// No add, do a full refresh
if (index === false) {
return false;
}
// Increase displayed row count or we lose the last row when we add
this.controller._grid.setTotalCount(this.controller._grid.getTotalCount() + 1);
// Insert at the top of the list, or where app said
var entry = this.controller._selectionMgr._getRegisteredRowsEntry(uid);
entry.idx = typeof index == "number" ? index : 0;
this.controller._insertDataRow(entry, true);
// Set "new entry" class - but it has to stay so register and re-add it after the data is there
(_b = (_a = entry.row) === null || _a === void 0 ? void 0 : _a.tr) === null || _b === void 0 ? void 0 : _b.addClass("new_entry");
var time = new Date().valueOf();
var callback = function (data) {
var _a;
if (data) {
if (data.class) {
data.class += " new_entry";
}
// Don't remove if new data has not arrived
var stored = egw.dataGetUIDdata(uid);
if (((_a = stored) === null || _a === void 0 ? void 0 : _a.timestamp) >= time)
return;
//if(stored?.timestamp >= time) return;
// Increase displayed row count or we lose the last row when we add and the total is wrong
this.controller._grid.setTotalCount(this.controller._grid.getTotalCount() + 1);
// Insert at the top of the list, or where app said
var entry = this.controller._selectionMgr._getRegisteredRowsEntry(uid);
entry.idx = typeof index == "number" ? index : 0;
this.controller._insertDataRow(entry, true);
}
else {
debugger;
// Server didn't give us our row data
// Delete from internal references
this.controller.deleteRow(uid);

View File

@ -849,6 +849,14 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
this.type == et2_nextmatch.ADD ? this.nm.refresh_add(this.uid, this.type)
: this.nm.refresh_update(this.uid);
}
else if (this.type == et2_nextmatch.UPDATE)
{
// Remove row from controller
this.nm.controller.deleteRow(this.uid);
// Adjust total rows, clean grid
this.nm.controller._grid.setTotalCount(this.nm.controller._grid._total- _row_ids.length);
}
}, {type: _type, nm: this, uid: uid}, [_row_ids]
);
return;
@ -932,16 +940,6 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
return false;
}
// Increase displayed row count or we lose the last row when we add
this.controller._grid.setTotalCount(this.controller._grid.getTotalCount()+1);
// Insert at the top of the list, or where app said
var entry = this.controller._selectionMgr._getRegisteredRowsEntry(uid);
entry.idx = typeof index == "number" ? index : 0;
this.controller._insertDataRow(entry,true);
// Set "new entry" class - but it has to stay so register and re-add it after the data is there
entry.row?.tr?.addClass("new_entry");
let time = new Date().valueOf();
let callback = function(data) {
@ -953,10 +951,19 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
}
// Don't remove if new data has not arrived
let stored = egw.dataGetUIDdata(uid);
if(stored?.timestamp >= time) return;
//if(stored?.timestamp >= time) return;
// Increase displayed row count or we lose the last row when we add and the total is wrong
this.controller._grid.setTotalCount(this.controller._grid.getTotalCount()+1);
// Insert at the top of the list, or where app said
var entry = this.controller._selectionMgr._getRegisteredRowsEntry(uid);
entry.idx = typeof index == "number" ? index : 0;
this.controller._insertDataRow(entry,true);
}
else
{
debugger;
// Server didn't give us our row data
// Delete from internal references
this.controller.deleteRow(uid);

View File

@ -159,7 +159,7 @@ var et2_nextmatch_controller = /** @class */ (function (_super) {
* @param {string} uid
*/
et2_nextmatch_controller.prototype.deleteRow = function (uid) {
var entry = this._selectionMgr._getRegisteredRowsEntry(uid);
var entry = Object.values(this._indexMap).find(function (entry) { return entry.uid == uid; });
// Unselect
this._selectionMgr.setSelected(uid, false);
if (entry && entry.idx !== null) {

View File

@ -185,7 +185,7 @@ export class et2_nextmatch_controller extends et2_dataview_controller implements
*/
deleteRow( uid)
{
var entry = this._selectionMgr._getRegisteredRowsEntry(uid);
var entry = Object.values(this._indexMap).find(entry => entry.uid == uid);
// Unselect
this._selectionMgr.setSelected(uid,false);