This commit is contained in:
Thijs Wenker 2018-11-16 20:49:25 +01:00
parent e89346c146
commit 7b3d2bed15
2 changed files with 13 additions and 13 deletions

View file

@ -187,7 +187,7 @@ let startThClick = null;
let renameTimeout = null; let renameTimeout = null;
let renameLastBlur = null; let renameLastBlur = null;
let renameLastEntityID = null; let renameLastEntityID = null;
let isRenameFieldIsBeingMoved = false; let isRenameFieldBeingMoved = false;
let elEntityTable, let elEntityTable,
elEntityTableHeader, elEntityTableHeader,
@ -397,7 +397,7 @@ function loaded() {
elEntityTableHeaderRow = document.querySelectorAll("#entity-table thead th"); elEntityTableHeaderRow = document.querySelectorAll("#entity-table thead th");
entityList = new ListView(elEntityTableBody, elEntityTableScroll, elEntityTableHeaderRow, entityList = new ListView(elEntityTableBody, elEntityTableScroll, elEntityTableHeaderRow,
createRow, updateRow, clearRow, beforeUpdate, afterUpdate, WINDOW_NONVARIABLE_HEIGHT); createRow, updateRow, clearRow, preRefresh, postRefresh, WINDOW_NONVARIABLE_HEIGHT);
entityListContextMenu = new EntityListContextMenu(); entityListContextMenu = new EntityListContextMenu();
@ -424,7 +424,7 @@ function loaded() {
}; };
elRenameInput.onblur = function(event) { elRenameInput.onblur = function(event) {
if (isRenameFieldIsBeingMoved) { if (isRenameFieldBeingMoved) {
return; return;
} }
let value = elRenameInput.value; let value = elRenameInput.value;
@ -446,18 +446,18 @@ function loaded() {
elRenameInput.select(); elRenameInput.select();
} }
function beforeUpdate() { function preRefresh() {
// move the rename input to the body // move the rename input to the body
if (elRenameInput) { if (elRenameInput) {
isRenameFieldIsBeingMoved = true; isRenameFieldBeingMoved = true;
document.body.appendChild(elRenameInput); document.body.appendChild(elRenameInput);
// keep the focus // keep the focus
elRenameInput.select(); elRenameInput.select();
} }
} }
function afterUpdate() { function postRefresh() {
if (!elRenameInput || !isRenameFieldIsBeingMoved) { if (!elRenameInput || !isRenameFieldBeingMoved) {
return; return;
} }
let entity = entitiesByID[renameLastEntityID]; let entity = entitiesByID[renameLastEntityID];
@ -469,7 +469,7 @@ function loaded() {
elCell.appendChild(elRenameInput); elCell.appendChild(elRenameInput);
// keep the focus // keep the focus
elRenameInput.select(); elRenameInput.select();
isRenameFieldIsBeingMoved = false; isRenameFieldBeingMoved = false;
} }
entityListContextMenu.setOnSelectedCallback(function(optionName, selectedEntityID) { entityListContextMenu.setOnSelectedCallback(function(optionName, selectedEntityID) {

View file

@ -14,7 +14,7 @@ debugPrint = function (message) {
}; };
function ListView(elTableBody, elTableScroll, elTableHeaderRow, createRowFunction, function ListView(elTableBody, elTableScroll, elTableHeaderRow, createRowFunction,
updateRowFunction, clearRowFunction, beforeRefreshFunction, afterRefreshFunction, WINDOW_NONVARIABLE_HEIGHT) { updateRowFunction, clearRowFunction, preRefreshFunction, postRefreshFunction, WINDOW_NONVARIABLE_HEIGHT) {
this.elTableBody = elTableBody; this.elTableBody = elTableBody;
this.elTableScroll = elTableScroll; this.elTableScroll = elTableScroll;
this.elTableHeaderRow = elTableHeaderRow; this.elTableHeaderRow = elTableHeaderRow;
@ -25,8 +25,8 @@ function ListView(elTableBody, elTableScroll, elTableHeaderRow, createRowFunctio
this.createRowFunction = createRowFunction; this.createRowFunction = createRowFunction;
this.updateRowFunction = updateRowFunction; this.updateRowFunction = updateRowFunction;
this.clearRowFunction = clearRowFunction; this.clearRowFunction = clearRowFunction;
this.beforeRefreshFunction = beforeRefreshFunction; this.preRefreshFunction = preRefreshFunction;
this.afterRefreshFunction = afterRefreshFunction; this.postRefreshFunction = postRefreshFunction;
// the list of row elements created in the table up to max viewable height plus SCROLL_ROWS rows for scrolling buffer // the list of row elements created in the table up to max viewable height plus SCROLL_ROWS rows for scrolling buffer
this.elRows = []; this.elRows = [];
@ -175,7 +175,7 @@ ListView.prototype = {
}, },
refresh: function() { refresh: function() {
this.beforeRefreshFunction(); this.preRefreshFunction();
// block refreshing before rows are initialized // block refreshing before rows are initialized
let numRows = this.getNumRows(); let numRows = this.getNumRows();
if (numRows === 0) { if (numRows === 0) {
@ -214,7 +214,7 @@ ListView.prototype = {
this.lastRowShiftScrollTop = 0; this.lastRowShiftScrollTop = 0;
} }
} }
this.afterRefreshFunction(); this.postRefreshFunction();
}, },
refreshBuffers: function() { refreshBuffers: function() {