From 9c60b09c6bd3b547f001d196947a63114339b4db Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Thu, 27 Dec 2018 14:50:12 -0800 Subject: [PATCH] Fix texture MB column not sorting correctly in entity list --- scripts/system/html/js/entityList.js | 35 ++++++++++++++++------------ 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index 406f434a65..156006619d 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -24,6 +24,19 @@ const DELTA_X_MOVE_COLUMNS_THRESHOLD = 2; const DELTA_X_COLUMN_SWAP_POSITION = 5; const CERTIFIED_PLACEHOLDER = "** Certified **"; +function decimalMegabytes(number) { + return number ? (number / BYTES_PER_MEGABYTE).toFixed(1) : ""; +} + +function displayIfNonZero(number) { + return number ? number : ""; +} + +function getFilename(url) { + let urlParts = url.split('/'); + return urlParts[urlParts.length - 1]; +} + const COLUMNS = { type: { columnHeader: "Type", @@ -79,6 +92,7 @@ const COLUMNS = { dropdownLabel: "Texture Size", propertyID: "texturesSize", initialWidth: 0.10, + format: decimalMegabytes }, hasTransparent: { columnHeader: "", @@ -605,19 +619,6 @@ function loaded() { })); } - function decimalMegabytes(number) { - return number ? (number / BYTES_PER_MEGABYTE).toFixed(1) : ""; - } - - function displayIfNonZero(number) { - return number ? number : ""; - } - - function getFilename(url) { - let urlParts = url.split('/'); - return urlParts[urlParts.length - 1]; - } - function updateEntityData(entityData) { entities = []; entitiesByID = {}; @@ -639,7 +640,7 @@ function loaded() { certificateID: entity.certificateID, verticesCount: displayIfNonZero(entity.verticesCount), texturesCount: displayIfNonZero(entity.texturesCount), - texturesSize: decimalMegabytes(entity.texturesSize), + texturesSize: entity.texturesSize, hasTransparent: entity.hasTransparent, isBaked: entity.isBaked, drawCalls: displayIfNonZero(entity.drawCalls), @@ -874,7 +875,11 @@ function loaded() { if (column.data.glyph) { elCell.innerHTML = itemData[column.data.propertyID] ? column.data.columnHeader : null; } else { - elCell.innerHTML = itemData[column.data.propertyID]; + let value = itemData[column.data.propertyID]; + if (column.data.format) { + value = column.data.format(value); + } + elCell.innerHTML = value; } elCell.style = "min-width:" + column.widthPx + "px;" + "max-width:" + column.widthPx + "px;"; elCell.className = createColumnClassName(column.columnID);