Etemplate: Ask for new data before we put the row in, then if the entry doesn't match the filters, don't put it in. Should stop most blinking rows.

This commit is contained in:
nathangray 2020-09-15 09:05:25 -06:00
parent 55c9487517
commit afb342f66b
2 changed files with 49 additions and 25 deletions

View File

@ -487,6 +487,9 @@ var et2_nextmatch = /** @class */ (function (_super) {
else if (update_pref == "exact" && _type == et2_nextmatch.ADD && !this.is_sorted_by_modified()) { else if (update_pref == "exact" && _type == et2_nextmatch.ADD && !this.is_sorted_by_modified()) {
_type = et2_nextmatch.EDIT; _type = et2_nextmatch.EDIT;
} }
if (_type == et2_nextmatch.ADD && !(update_pref == "lazy" || update_pref == "exact" && this.is_sorted_by_modified())) {
_type = et2_nextmatch.EDIT;
}
if (typeof _type == 'undefined') if (typeof _type == 'undefined')
_type = et2_nextmatch.EDIT; _type = et2_nextmatch.EDIT;
if (typeof _row_ids == 'string' || typeof _row_ids == 'number') if (typeof _row_ids == 'string' || typeof _row_ids == 'number')
@ -539,26 +542,32 @@ var et2_nextmatch = /** @class */ (function (_super) {
_type = et2_nextmatch.EDIT; _type = et2_nextmatch.EDIT;
} }
} }
if ([et2_nextmatch.ADD, et2_nextmatch.UPDATE].indexOf(_type) !== -1) {
// Pre-ask for the row data, and only proceed if we actually get it
// need to send nextmatch filters too, as server-side will merge old version from request otherwise
this_1.egw().dataFetch(this_1.getInstanceManager().etemplate_exec_id, { refresh: _row_ids }, this_1.controller._filters, this_1.id, function (data) {
if (data.total >= 1) {
this.type == et2_nextmatch.ADD ? this.nm.refresh_add(this.uid, this.type)
: this.nm.refresh_update(this.uid);
}
}, { type: _type, nm: this_1, uid: uid_1 }, [_row_ids]);
return { value: void 0 };
}
switch (_type) { switch (_type) {
// update-in-place = update, but always only in place // update-in-place = update, but always only in place
case et2_nextmatch.UPDATE_IN_PLACE: case et2_nextmatch.UPDATE_IN_PLACE:
this_1.egw().dataRefreshUID(uid_1); this_1.egw().dataRefreshUID(uid_1);
break; break;
// update [existing] row, maybe we'll put it on top // These ones handled above in dataFetch() callback
case et2_nextmatch.UPDATE: case et2_nextmatch.UPDATE:
if (!this_1.refresh_update(uid_1)) { // update [existing] row, maybe we'll put it on top
return "break-id_loop";
}
break; break;
case et2_nextmatch.DELETE: case et2_nextmatch.DELETE:
// Handled above, more code to execute after loop so don't exit early // Handled above, more code to execute after loop so don't exit early
break; break;
case et2_nextmatch.ADD: case et2_nextmatch.ADD:
if (update_pref == "lazy" || update_pref == "exact" && this_1.is_sorted_by_modified()) { break;
if (this_1.refresh_add(uid_1)) // No more smart things we can do, refresh the whole thing
break;
}
// fall-through / full refresh, if refresh_add returns false
case et2_nextmatch.EDIT: case et2_nextmatch.EDIT:
default: default:
// Trigger refresh // Trigger refresh
@ -569,6 +578,8 @@ var et2_nextmatch = /** @class */ (function (_super) {
var this_1 = this; var this_1 = this;
id_loop: for (var i = 0; i < _row_ids.length; i++) { id_loop: for (var i = 0; i < _row_ids.length; i++) {
var state_1 = _loop_1(); var state_1 = _loop_1();
if (typeof state_1 === "object")
return state_1.value;
switch (state_1) { switch (state_1) {
case "break-id_loop": break id_loop; case "break-id_loop": break id_loop;
} }
@ -585,8 +596,6 @@ var et2_nextmatch = /** @class */ (function (_super) {
et2_nextmatch.prototype.refresh_update = function (uid) { et2_nextmatch.prototype.refresh_update = function (uid) {
// Row data update has been sent, let's move it where app wants it // Row data update has been sent, let's move it where app wants it
var entry = this.controller._selectionMgr._getRegisteredRowsEntry(uid); var entry = this.controller._selectionMgr._getRegisteredRowsEntry(uid);
// Ask for new data
this.egw().dataRefreshUID(uid);
// Need to delete first as there's a good chance indexes will change in an unknown way // 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 // and we can't always find it by UID after due to duplication
this.controller.deleteRow(uid); this.controller.deleteRow(uid);

View File

@ -760,6 +760,10 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
{ {
_type = et2_nextmatch.EDIT; _type = et2_nextmatch.EDIT;
} }
if( _type == et2_nextmatch.ADD && !( update_pref == "lazy" || update_pref == "exact" && this.is_sorted_by_modified() ))
{
_type = et2_nextmatch.EDIT;
}
if (typeof _type == 'undefined') _type = et2_nextmatch.EDIT; if (typeof _type == 'undefined') _type = et2_nextmatch.EDIT;
if (typeof _row_ids == 'string' || typeof _row_ids == 'number') _row_ids = [_row_ids]; if (typeof _row_ids == 'string' || typeof _row_ids == 'number') _row_ids = [_row_ids];
@ -830,29 +834,43 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
_type = et2_nextmatch.EDIT; _type = et2_nextmatch.EDIT;
} }
} }
if([et2_nextmatch.ADD, et2_nextmatch.UPDATE].indexOf(_type) !== -1)
{
// Pre-ask for the row data, and only proceed if we actually get it
// need to send nextmatch filters too, as server-side will merge old version from request otherwise
this.egw().dataFetch(
this.getInstanceManager().etemplate_exec_id,
{refresh:_row_ids},
this.controller._filters,
this.id, function(data)
{
if(data.total >= 1)
{
this.type == et2_nextmatch.ADD ? this.nm.refresh_add(this.uid, this.type)
: this.nm.refresh_update(this.uid);
}
}, {type: _type, nm: this, uid: uid}, [_row_ids]
);
return;
}
switch(_type) switch(_type)
{ {
// update-in-place = update, but always only in place // update-in-place = update, but always only in place
case et2_nextmatch.UPDATE_IN_PLACE: case et2_nextmatch.UPDATE_IN_PLACE:
this.egw().dataRefreshUID(uid); this.egw().dataRefreshUID(uid);
break; break;
// update [existing] row, maybe we'll put it on top
// These ones handled above in dataFetch() callback
case et2_nextmatch.UPDATE: case et2_nextmatch.UPDATE:
if(!this.refresh_update(uid)) // update [existing] row, maybe we'll put it on top
{
// Could not update just the row, full refresh has been requested
break id_loop;
}
break; break;
case et2_nextmatch.DELETE: case et2_nextmatch.DELETE:
// Handled above, more code to execute after loop so don't exit early // Handled above, more code to execute after loop so don't exit early
break; break;
case et2_nextmatch.ADD: case et2_nextmatch.ADD:
if( update_pref == "lazy" || update_pref == "exact" && this.is_sorted_by_modified() ) break;
{
if (this.refresh_add(uid)) break; // No more smart things we can do, refresh the whole thing
}
// fall-through / full refresh, if refresh_add returns false
case et2_nextmatch.EDIT: case et2_nextmatch.EDIT:
default: default:
// Trigger refresh // Trigger refresh
@ -875,9 +893,6 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
// Row data update has been sent, let's move it where app wants it // Row data update has been sent, let's move it where app wants it
let entry = this.controller._selectionMgr._getRegisteredRowsEntry(uid); let entry = this.controller._selectionMgr._getRegisteredRowsEntry(uid);
// Ask for new data
this.egw().dataRefreshUID(uid);
// Need to delete first as there's a good chance indexes will change in an unknown way // 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 // and we can't always find it by UID after due to duplication
this.controller.deleteRow(uid); this.controller.deleteRow(uid);