mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-29 11:46:33 +00:00
handle edge case not covered by last commit
This commit is contained in:
@@ -261,6 +261,8 @@ function updateTableElement(blenderId, csvData, filename) {
|
|||||||
// else, replace the whole data and column definations
|
// else, replace the whole data and column definations
|
||||||
const firstLine = csvData.indexOf("\n");
|
const firstLine = csvData.indexOf("\n");
|
||||||
const newHeaders = csvData.substring(0, firstLine).split(",");
|
const newHeaders = csvData.substring(0, firstLine).split(",");
|
||||||
|
const hasRows = csvData.substring(firstLine + 1).trim().length > 0;
|
||||||
|
|
||||||
const sameHeaders = compareHeaders(
|
const sameHeaders = compareHeaders(
|
||||||
connectedClients[blenderId].headers,
|
connectedClients[blenderId].headers,
|
||||||
newHeaders
|
newHeaders
|
||||||
@@ -272,7 +274,12 @@ function updateTableElement(blenderId, csvData, filename) {
|
|||||||
table.replaceData(csvData, { importFormat: "csv" });
|
table.replaceData(csvData, { importFormat: "csv" });
|
||||||
} else {
|
} else {
|
||||||
table.setData(csvData);
|
table.setData(csvData);
|
||||||
connectedClients[blenderId].headers = newHeaders;
|
|
||||||
|
if (hasRows) {
|
||||||
|
connectedClients[blenderId].headers = newHeaders;
|
||||||
|
} else {
|
||||||
|
connectedClients[blenderId].headers = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$("#title-" + blenderId).text(filename);
|
$("#title-" + blenderId).text(filename);
|
||||||
}
|
}
|
||||||
@@ -289,7 +296,11 @@ function showWarning(blenderId, isDirty) {
|
|||||||
|
|
||||||
// Utility function to compare two csv header
|
// Utility function to compare two csv header
|
||||||
function compareHeaders(headers1, headers2) {
|
function compareHeaders(headers1, headers2) {
|
||||||
if (headers1.length !== headers2.length) {
|
if (
|
||||||
|
headers1.length !== headers2.length ||
|
||||||
|
headers1.length == 0 ||
|
||||||
|
headers2.length == 0
|
||||||
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (let i = 0; i < headers1.length; i++) {
|
for (let i = 0; i < headers1.length; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user