mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 00:29:38 +01:00
Etemplate: Fix push add to an empty nextmatch would leave the 'No matches found' and throw errors for row actions
This commit is contained in:
parent
23aea3b42e
commit
855d6defc9
@ -337,8 +337,13 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
if (createdRow && _entry.row) {
|
||||
this._grid.insertRow(_entry.idx, _entry.row);
|
||||
}
|
||||
// Remove 'No matches found' row
|
||||
var row = jQuery(".egwGridView_empty", this._grid.innerTbody).remove();
|
||||
if (row.length) {
|
||||
this._selectionMgr.unregisterRow("", 0);
|
||||
}
|
||||
// Update index map only for push (autorefresh disabled)
|
||||
if (this._indexMap[_entry.idx].uid !== _entry.uid) {
|
||||
if (this._indexMap[_entry.idx] && 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];
|
||||
@ -348,8 +353,8 @@ var et2_dataview_controller = /** @class */ (function () {
|
||||
this._selectionMgr._registeredRows[entry.uid].idx = entry.idx;
|
||||
}
|
||||
}
|
||||
this._indexMap[_entry.idx] = _entry;
|
||||
}
|
||||
this._indexMap[_entry.idx] = _entry;
|
||||
return this.hasData;
|
||||
};
|
||||
/**
|
||||
|
@ -467,8 +467,15 @@ export class et2_dataview_controller
|
||||
this._grid.insertRow(_entry.idx, _entry.row);
|
||||
}
|
||||
|
||||
// Remove 'No matches found' row
|
||||
var row = jQuery(".egwGridView_empty",this._grid.innerTbody).remove();
|
||||
if(row.length)
|
||||
{
|
||||
this._selectionMgr.unregisterRow("", 0);
|
||||
}
|
||||
|
||||
// Update index map only for push (autorefresh disabled)
|
||||
if(this._indexMap[_entry.idx].uid !== _entry.uid)
|
||||
if(this._indexMap[_entry.idx] && this._indexMap[_entry.idx].uid !== _entry.uid)
|
||||
{
|
||||
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--)
|
||||
@ -481,8 +488,8 @@ export class et2_dataview_controller
|
||||
this._selectionMgr._registeredRows[entry.uid].idx = entry.idx;
|
||||
}
|
||||
}
|
||||
this._indexMap[_entry.idx] = _entry
|
||||
}
|
||||
this._indexMap[_entry.idx] = _entry;
|
||||
|
||||
return this.hasData;
|
||||
}
|
||||
|
@ -527,6 +527,7 @@ var et2_nextmatch = /** @class */ (function (_super) {
|
||||
// This will remove the last row!
|
||||
// That's OK, because grid adds one in this.controller.deleteRow()
|
||||
this.dataview.grid.setTotalCount(total);
|
||||
this.controller._selectionMgr.setTotalCount(total);
|
||||
// Re-enable automatic updating
|
||||
this.dataview.grid.doInvalidate = true;
|
||||
this.dataview.grid.invalidate();
|
||||
@ -559,6 +560,7 @@ var et2_nextmatch = /** @class */ (function (_super) {
|
||||
this.nm.controller.deleteRow(this.uid);
|
||||
// Adjust total rows, clean grid
|
||||
this.nm.controller._grid.setTotalCount(this.nm.controller._grid._total - _row_ids.length);
|
||||
this.controller._selectionMgr.setTotalCount(this.nm.controller._grid._total);
|
||||
}
|
||||
}, { type: _type, nm: this_1, uid: uid_1, prefix: this_1.controller.dataStorePrefix }, [_row_ids]);
|
||||
return { value: void 0 };
|
||||
@ -622,6 +624,7 @@ var et2_nextmatch = /** @class */ (function (_super) {
|
||||
}
|
||||
// Update does not need to increase row count, but refresh_add() adds it in
|
||||
this.controller._grid.setTotalCount(this.controller._grid.getTotalCount() - 1);
|
||||
this.controller._selectionMgr.setTotalCount(this.controller._grid.getTotalCount());
|
||||
return true;
|
||||
};
|
||||
/**
|
||||
@ -657,6 +660,7 @@ var et2_nextmatch = /** @class */ (function (_super) {
|
||||
//if(stored?.timestamp >= time) return;
|
||||
// Increase displayed row count or we lose the last row when we add and the total is wrong
|
||||
this.nm.controller._grid.setTotalCount(this.nm.controller._grid.getTotalCount() + 1);
|
||||
this.nm.controller._selectionMgr.setTotalCount(this.nm.controller._grid.getTotalCount());
|
||||
// Insert at the top of the list, or where app said
|
||||
var entry = this.nm.controller._selectionMgr._getRegisteredRowsEntry(this.uid);
|
||||
entry.idx = typeof this.index == "number" ? this.index : 0;
|
||||
@ -667,6 +671,7 @@ var et2_nextmatch = /** @class */ (function (_super) {
|
||||
// Delete from internal references
|
||||
this.nm.controller.deleteRow(this.uid);
|
||||
this.nm.controller._grid.setTotalCount(this.nm.controller._grid.getTotalCount() - 1);
|
||||
this.nm.controller._selectionMgr.setTotalCount(this.nm.controller._grid.getTotalCount());
|
||||
}
|
||||
this.nm.egw().dataUnregisterUID(this.uid, this.nm._push_add_callback, this);
|
||||
};
|
||||
|
@ -813,6 +813,8 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
|
||||
// This will remove the last row!
|
||||
// That's OK, because grid adds one in this.controller.deleteRow()
|
||||
this.dataview.grid.setTotalCount(total);
|
||||
this.controller._selectionMgr.setTotalCount(total);
|
||||
|
||||
// Re-enable automatic updating
|
||||
this.dataview.grid.doInvalidate = true;
|
||||
this.dataview.grid.invalidate();
|
||||
@ -860,6 +862,7 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
|
||||
|
||||
// Adjust total rows, clean grid
|
||||
this.nm.controller._grid.setTotalCount(this.nm.controller._grid._total- _row_ids.length);
|
||||
this.controller._selectionMgr.setTotalCount(this.nm.controller._grid._total);
|
||||
}
|
||||
}, {type: _type, nm: this, uid: uid, prefix: this.controller.dataStorePrefix}, [_row_ids]
|
||||
);
|
||||
@ -923,6 +926,7 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
|
||||
}
|
||||
// Update does not need to increase row count, but refresh_add() adds it in
|
||||
this.controller._grid.setTotalCount(this.controller._grid.getTotalCount()-1);
|
||||
this.controller._selectionMgr.setTotalCount(this.controller._grid.getTotalCount());
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -969,6 +973,7 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
|
||||
|
||||
// Increase displayed row count or we lose the last row when we add and the total is wrong
|
||||
this.nm.controller._grid.setTotalCount(this.nm.controller._grid.getTotalCount()+1);
|
||||
this.nm.controller._selectionMgr.setTotalCount(this.nm.controller._grid.getTotalCount());
|
||||
|
||||
// Insert at the top of the list, or where app said
|
||||
var entry = this.nm.controller._selectionMgr._getRegisteredRowsEntry(this.uid);
|
||||
@ -981,6 +986,7 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
|
||||
// Delete from internal references
|
||||
this.nm.controller.deleteRow(this.uid);
|
||||
this.nm.controller._grid.setTotalCount(this.nm.controller._grid.getTotalCount()-1);
|
||||
this.nm.controller._selectionMgr.setTotalCount(this.nm.controller._grid.getTotalCount());
|
||||
}
|
||||
this.nm.egw().dataUnregisterUID(this.uid, this.nm._push_add_callback, this);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user