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
scripts/system/html/js

View file

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

View file

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