diff --git a/api/js/etemplate/et2_extension_nextmatch.js b/api/js/etemplate/et2_extension_nextmatch.js index 0ebedc2781..c5cb6d9228 100644 --- a/api/js/etemplate/et2_extension_nextmatch.js +++ b/api/js/etemplate/et2_extension_nextmatch.js @@ -589,6 +589,8 @@ var et2_nextmatch = /** @class */ (function (_super) { this.egw().dataRegisterUID(uid, callback_1, this, this.getInstanceManager().etemplate_exec_id, this.id); this.controller._insertDataRow(entry, true); } + // Update does not need to increase row count, but refresh_add() adds it in + this.controller._grid.setTotalCount(this.controller._grid.getTotalCount() - 1); return true; }; /** @@ -605,6 +607,8 @@ var et2_nextmatch = /** @class */ (function (_super) { 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; @@ -613,12 +617,16 @@ var et2_nextmatch = /** @class */ (function (_super) { entry.row.tr.addClass("new_entry"); var callback = function (data) { if (data) { - // Increase displayed row count - this.controller._grid.setTotalCount(this.controller._grid.getTotalCount() + 1); if (data.class) { data.class += " new_entry"; } } + else { + // Server didn't give us our row data + // Delete from internal references + this.controller.deleteRow(uid); + this.controller._grid.setTotalCount(this.controller._grid.getTotalCount() - 1); + } this.egw().dataUnregisterUID(uid, callback, this); }; this.egw().dataRegisterUID(uid, callback, this, this.getInstanceManager().etemplate_exec_id, this.id); diff --git a/api/js/etemplate/et2_extension_nextmatch.ts b/api/js/etemplate/et2_extension_nextmatch.ts index e40d023703..a9a50619fd 100644 --- a/api/js/etemplate/et2_extension_nextmatch.ts +++ b/api/js/etemplate/et2_extension_nextmatch.ts @@ -886,6 +886,8 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2 this.egw().dataRegisterUID(uid, callback, this, this.getInstanceManager().etemplate_exec_id, this.id); this.controller._insertDataRow(entry,true); } + // Update does not need to increase row count, but refresh_add() adds it in + this.controller._grid.setTotalCount(this.controller._grid.getTotalCount()-1); return true; } @@ -907,6 +909,8 @@ 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); @@ -918,13 +922,18 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2 let callback = function(data) { if(data) { - // Increase displayed row count - this.controller._grid.setTotalCount(this.controller._grid.getTotalCount()+1); if(data.class) { data.class += " new_entry"; } } + else + { + // Server didn't give us our row data + // Delete from internal references + this.controller.deleteRow(uid); + this.controller._grid.setTotalCount(this.controller._grid.getTotalCount()-1); + } this.egw().dataUnregisterUID(uid, callback, this); }; this.egw().dataRegisterUID(uid, callback, this, this.getInstanceManager().etemplate_exec_id, this.id); diff --git a/api/js/jsapi/egw_data.js b/api/js/jsapi/egw_data.js index 89a5bfdf6a..4638ec7387 100644 --- a/api/js/jsapi/egw_data.js +++ b/api/js/jsapi/egw_data.js @@ -806,7 +806,10 @@ egw.extend("data_storage", egw.MODULE_GLOBAL, function (_app, _wnd) { ); } catch (e) { // Remove this callback from the list - registeredCallbacks[_uid].splice(i, 1); + if(typeof registeredCallbacks[_uid] != "undefined") + { + registeredCallbacks[_uid].splice(i, 1); + } } } }