Skip to content
Snippets Groups Projects
Commit 8dd1581f authored by Benedikt's avatar Benedikt
Browse files

influence condition renderer improved

parent 16030d3b
No related branches found
No related tags found
No related merge requests found
Pipeline #52054 passed
...@@ -36,7 +36,7 @@ export class InfluenceConditionsRenderer { ...@@ -36,7 +36,7 @@ export class InfluenceConditionsRenderer {
const valueStr = this._formatQuantity(qty, true); const valueStr = this._formatQuantity(qty, true);
summaryText += ` : ${valueStr}`; summaryText += ` : ${valueStr}`;
} }
// Use innerHTML here so that any HTML markup in the unit is rendered // Use innerHTML so that HTML markup in the unit is rendered
summary.innerHTML = summaryText; summary.innerHTML = summaryText;
details.appendChild(summary); details.appendChild(summary);
...@@ -57,9 +57,9 @@ export class InfluenceConditionsRenderer { ...@@ -57,9 +57,9 @@ export class InfluenceConditionsRenderer {
table.style.width = '100%'; table.style.width = '100%';
table.style.borderCollapse = 'collapse'; table.style.borderCollapse = 'collapse';
// Header row for the table // Header row for the table (removed "Additional Info" column)
const headerRow = document.createElement('tr'); const headerRow = document.createElement('tr');
['Quantity', 'Value', 'Description', 'Additional Info'].forEach(text => { ['Quantity', 'Value', 'Description'].forEach(text => {
const th = document.createElement('th'); const th = document.createElement('th');
th.textContent = text; th.textContent = text;
th.style.border = '1px solid #ccc'; th.style.border = '1px solid #ccc';
...@@ -85,7 +85,7 @@ export class InfluenceConditionsRenderer { ...@@ -85,7 +85,7 @@ export class InfluenceConditionsRenderer {
valueCell.style.padding = '4px'; valueCell.style.padding = '4px';
const formattedValue = this._formatQuantity(q, false); const formattedValue = this._formatQuantity(q, false);
valueCell.innerHTML = formattedValue; valueCell.innerHTML = formattedValue;
// If additional (non-standard) data exists, attach a tooltip // Attach tooltip for additional data if present
const additional = this._getAdditionalData(q); const additional = this._getAdditionalData(q);
if (Object.keys(additional).length > 0) { if (Object.keys(additional).length > 0) {
const infoSpan = document.createElement('span'); const infoSpan = document.createElement('span');
...@@ -104,13 +104,6 @@ export class InfluenceConditionsRenderer { ...@@ -104,13 +104,6 @@ export class InfluenceConditionsRenderer {
descCell.textContent = this._getText(q['dcc:description']); descCell.textContent = this._getText(q['dcc:description']);
row.appendChild(descCell); row.appendChild(descCell);
// Column 4: Additional info (if any)
const additionalCell = document.createElement('td');
additionalCell.style.border = '1px solid #ccc';
additionalCell.style.padding = '4px';
additionalCell.textContent = Object.keys(additional).length > 0 ? JSON.stringify(additional) : '';
row.appendChild(additionalCell);
table.appendChild(row); table.appendChild(row);
}); });
contentDiv.appendChild(table); contentDiv.appendChild(table);
...@@ -143,8 +136,12 @@ export class InfluenceConditionsRenderer { ...@@ -143,8 +136,12 @@ export class InfluenceConditionsRenderer {
return quantities; return quantities;
} }
// Helper: format a quantity's value. /**
// If plain is true, render unit as plain text; otherwise use HTML from DSIUnit. * Helper: Format a quantity's value.
* @param {Object} quantity - The quantity node.
* @param {boolean} plain - If true, render unit as plain text; otherwise use HTML from DSIUnit.
* @returns {string}
*/
_formatQuantity(quantity, plain = false) { _formatQuantity(quantity, plain = false) {
// Handle noQuantity (categorical data) // Handle noQuantity (categorical data)
if (quantity['dcc:noQuantity']) { if (quantity['dcc:noQuantity']) {
...@@ -163,7 +160,7 @@ export class InfluenceConditionsRenderer { ...@@ -163,7 +160,7 @@ export class InfluenceConditionsRenderer {
if (real['si:unit']) { if (real['si:unit']) {
const rawUnit = real['si:unit'].trim(); const rawUnit = real['si:unit'].trim();
const unitObj = new DSIUnit(rawUnit); const unitObj = new DSIUnit(rawUnit);
unit = plain ? unitObj.toHTML() : unitObj.toHTML({ oneLine: true }); unit = plain ? unitObj.toHTML() : unitObj.toHTML({ oneLine: true });
} }
let uncertainty = ''; let uncertainty = '';
if (real['si:measurementUncertaintyUnivariate'] && if (real['si:measurementUncertaintyUnivariate'] &&
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment