diff --git a/src/renderers/InfluenceConditionsRenderer.js b/src/renderers/InfluenceConditionsRenderer.js index 0ba0f2477c96b5cbb9fd5ac60b79de1be61bc8a3..3ed8474cd1274b9b310713121ab4e877932210bc 100644 --- a/src/renderers/InfluenceConditionsRenderer.js +++ b/src/renderers/InfluenceConditionsRenderer.js @@ -18,15 +18,20 @@ export class InfluenceConditionsRenderer { if (!Array.isArray(conditions)) { conditions = [conditions]; } + // Reset default browser styles for details and summary + const detailsStyle = 'margin: 0; padding: 0; border: 1px solid #ccc; padding: 8px; margin-bottom: 10px;'; + const summaryStyle = 'margin: 0; padding: 0; list-style: none;'; conditions.forEach(condition => { // Create a collapsible section for each influence condition const details = document.createElement('details'); + details.setAttribute('style', detailsStyle); details.style.border = '1px solid #ccc'; details.style.padding = '8px'; details.style.marginBottom = '10px'; - + details.open = false; // collapsed by default // Summary: always visible, shows the condition name and, if only one quantity exists, its value (plain text) const summary = document.createElement('summary'); + summary.style.fontWeight = 'bold'; const condName = this._getText(condition['dcc:name']); let summaryText = condName; const quantities = this._getQuantities(condition); diff --git a/src/renderers/MeasurementRenderer.js b/src/renderers/MeasurementRenderer.js index b2c583454faff1099074de35232450ddaa90f45b..52757c0f96b160e056aa92876ef35ce37b20ab0e 100644 --- a/src/renderers/MeasurementRenderer.js +++ b/src/renderers/MeasurementRenderer.js @@ -117,10 +117,9 @@ export function renderMeasurementResults(measurementResults, language) { // *** NEW: Render Measuring Equipments using the new renderer (collapsible by default) *** const equipmentsRenderer = new MeasuringEquipmentsRenderer(result['dcc:measuringEquipments'], language); - const equipmentsDetails = document.createElement('details'); + const equipmentsDetails = document.createElement('div'); equipmentsDetails.open = false; const equipmentsSummary = document.createElement('summary'); - equipmentsSummary.textContent = 'Measuring Equipments'; equipmentsDetails.appendChild(equipmentsSummary); equipmentsDetails.appendChild(equipmentsRenderer.render()); tabPanel.appendChild(equipmentsDetails); diff --git a/src/renderers/MeasuringEquipmentRenderer.js b/src/renderers/MeasuringEquipmentRenderer.js index 858ddc8cc91010da6548d795cc455c5589cefeb2..defba945d7c660971b6bb5ce6f6e5d3fcb7506ae 100644 --- a/src/renderers/MeasuringEquipmentRenderer.js +++ b/src/renderers/MeasuringEquipmentRenderer.js @@ -8,10 +8,8 @@ export class MeasuringEquipmentsRenderer { } render() { - // Create a container without an extra header (if you prefer to not duplicate the title) const container = document.createElement('div'); - // Optionally, you could add a header here if desired: - // container.innerHTML = `<h3>Measuring Equipments</h3>`; + container.innerHTML = `<h3>Measuring Equipments</h3>`; let equipments = this.data && this.data['dcc:measuringEquipment']; if (!equipments) { @@ -22,59 +20,66 @@ export class MeasuringEquipmentsRenderer { equipments = [equipments]; } - // Reset default browser styles for details and summary - const detailsStyle = 'margin: 0; padding: 0; border: 1px solid #ccc; padding: 8px; margin-bottom: 10px;'; - const summaryStyle = 'margin: 0; padding: 0; list-style: none;'; - + // For each measuring equipment, create an individual collapsible section. equipments.forEach(equipment => { - // Each equipment is rendered in a collapsible details block. const details = document.createElement('details'); - details.setAttribute('style', detailsStyle); + // Apply styling similar to influence conditions renderer + details.style.margin = '0'; + details.style.padding = '8px'; + details.style.border = '1px solid #ccc'; + details.style.marginBottom = '10px'; details.open = false; // collapsed by default - // Create summary for collapsed view + // Summary: always visible – shows equipment name, manufacturer, model and first identification. const summary = document.createElement('summary'); - summary.setAttribute('style', summaryStyle); - // Equipment name (language‑specific) + summary.style.fontWeight = 'bold'; + // Equipment name const eqName = this._getText(equipment['dcc:name']); // Manufacturer name (if available) const manufacturer = equipment['dcc:manufacturer'] ? this._getText(equipment['dcc:manufacturer']['dcc:name']) : ''; // Model - const model = equipment['dcc:model'] ? equipment['dcc:model'] : ''; + const model = equipment['dcc:model'] || ''; // First identification (if available) let firstId = ''; - if (equipment['dcc:identifications'] && equipment['dcc:identifications']['dcc:identification']) { - let ident = equipment['dcc:identifications']['dcc:identification']; - if (!Array.isArray(ident)) { ident = [ident]; } - const first = ident[0]; + if ( + equipment['dcc:identifications'] && + equipment['dcc:identifications']['dcc:identification'] + ) { + let idents = equipment['dcc:identifications']['dcc:identification']; + if (!Array.isArray(idents)) { + idents = [idents]; + } + const first = idents[0]; firstId = `<small>${this._getText(first['dcc:name'])}: ${first['dcc:value']}</small>`; } summary.innerHTML = `<strong>${eqName}</strong> – ${manufacturer} – Model: ${model} – ${firstId}`; details.appendChild(summary); - // Expanded content + // Expanded content container const contentDiv = document.createElement('div'); contentDiv.style.marginTop = '8px'; contentDiv.style.fontFamily = 'sans-serif'; - // Render full identifications + // Render full identifications if available if (equipment['dcc:identifications']) { - const identDiv = document.createElement('div'); - identDiv.innerHTML = `<h4>Identifications</h4>`; - let ident = equipment['dcc:identifications']['dcc:identification']; - if (!Array.isArray(ident)) { ident = [ident]; } - ident.forEach(id => { + const identSection = document.createElement('div'); + identSection.innerHTML = `<h4>Identifications</h4>`; + let idents = equipment['dcc:identifications']['dcc:identification']; + if (!Array.isArray(idents)) { + idents = [idents]; + } + idents.forEach(id => { const idName = this._getText(id['dcc:name']); const idValue = id['dcc:value'] || ''; const issuer = id['dcc:issuer'] || ''; - identDiv.innerHTML += `<p><small>${idName} (${issuer}): ${idValue}</small></p>`; + identSection.innerHTML += `<p><small>${idName} (${issuer}): ${idValue}</small></p>`; }); - contentDiv.appendChild(identDiv); + contentDiv.appendChild(identSection); } - // Render measuring equipment quantities as a table if available + // Render measuring equipment quantities as a table (if available) if ( equipment['dcc:measuringEquipmentQuantities'] && equipment['dcc:measuringEquipmentQuantities']['dcc:measuringEquipmentQuantity'] @@ -84,6 +89,8 @@ export class MeasuringEquipmentsRenderer { const table = document.createElement('table'); table.style.width = '100%'; table.style.borderCollapse = 'collapse'; + + // Table header const headerRow = document.createElement('tr'); ['Quantity', 'Value'].forEach(text => { const th = document.createElement('th'); @@ -93,21 +100,23 @@ export class MeasuringEquipmentsRenderer { headerRow.appendChild(th); }); table.appendChild(headerRow); + + // Render each equipment quantity quantities.forEach(q => { - const tr = document.createElement('tr'); + const row = document.createElement('tr'); const nameCell = document.createElement('td'); nameCell.style.border = '1px solid #ccc'; nameCell.style.padding = '4px'; nameCell.textContent = this._getText(q['dcc:name']); - tr.appendChild(nameCell); + row.appendChild(nameCell); const valueCell = document.createElement('td'); valueCell.style.border = '1px solid #ccc'; valueCell.style.padding = '4px'; - // Render value and unit using DCCRealListQuantity - let qtyObj = new DCCRealListQuantity(q); + const qtyObj = new DCCRealListQuantity(q); + // Use the DSIUnit library to convert the unit string into HTML valueCell.innerHTML = qtyObj.getValues().join(' ') + ' ' + qtyObj.getUnit({ oneLine: true }); - tr.appendChild(valueCell); - table.appendChild(tr); + row.appendChild(valueCell); + table.appendChild(row); }); contentDiv.appendChild(table); } @@ -115,9 +124,11 @@ export class MeasuringEquipmentsRenderer { details.appendChild(contentDiv); container.appendChild(details); }); + return container; } + // Helper: extract language-specific text from a node _getText(node) { if (!node) return ''; const content = node['dcc:content'];