diff --git a/previewers/betatest/css/refiqdas.css b/previewers/betatest/css/refiqdas.css index caeea1e..8a844ad 100644 --- a/previewers/betatest/css/refiqdas.css +++ b/previewers/betatest/css/refiqdas.css @@ -63,4 +63,8 @@ .tooltip-text { margin-top: 5px; +} + +label { + margin-left:5px; } \ No newline at end of file diff --git a/previewers/betatest/js/refiqdacore.js b/previewers/betatest/js/refiqdacore.js index 8d40f2a..88b2233 100644 --- a/previewers/betatest/js/refiqdacore.js +++ b/previewers/betatest/js/refiqdacore.js @@ -295,26 +295,33 @@ function parseData2(data) { let pdfSel = selection.pdfSelection; let textSel = selection.plainTextSelection; let selectionName = pdfSel.getAttribute("name"); + if(!selectionName) { + selectionName = "(Hover for more info)"; + } guid = pdfSel.getAttribute("guid"); codes = getCodeNames(pdfSel); // Codes are on the PDF selection + let sourceGuid = source.getAttribute("guid"); + selectionMatches = sourceMatches + pdfSel.getAttribute("creatingUser") + pdfSel.getAttribute("modifyingUser") + textSel.getAttribute("creatingUser") + textSel.getAttribute("modifyingUser") + - getCodeRelatedGUIDs(pdfSel); - - let sourceGuid = source.getAttribute("guid"); + getCodeRelatedGUIDs(pdfSel) + sourceGuid; displayName = createMergedSelectionWithTooltip(selectionName, pdfSel, textSel, sourceGuid); } else { // Handle regular selection node let selectionName = selection.getAttribute("name"); + if(!selectionName) { + selectionName = "(Hover for more info)"; + } guid = selection.getAttribute("guid"); codes = getCodeNames(selection); - selectionMatches = sourceMatches + selection.getAttribute("creatingUser") + selection.getAttribute("modifyingUser") + getCodeRelatedGUIDs(selection); - let sourceGuid = source.getAttribute("guid"); + + selectionMatches = sourceMatches + selection.getAttribute("creatingUser") + selection.getAttribute("modifyingUser") + getCodeRelatedGUIDs(selection) + sourceGuid; + displayName = selectionName; // Default display name if (selection.nodeName === "PDFSelection") { @@ -446,14 +453,29 @@ function parseData2(data) { desc = desc[0].childNodes[0]; } let matches = ''; - if (note.getAttribute("creatingUser")) { - matches = matches + note.getAttribute("creatingUser"); + let name = ''; + let creatingUserGuid = note.getAttribute("creatingUser"); + let modifyingUserGuid = note.getAttribute("modifyingUser"); + let userNames = new Set(); + + if (creatingUserGuid) { + matches += creatingUserGuid; + let user = userMap.get(creatingUserGuid); + if (user) { + userNames.add(user.getAttribute("name")); + } } - if (note.getAttribute("modifyingUser")) { - matches = matches + note.getAttribute("modifyingUser"); + + if (modifyingUserGuid) { + matches += modifyingUserGuid; + let user = userMap.get(modifyingUserGuid); + if (user) { + userNames.add(user.getAttribute("name")); + } } + name = Array.from(userNames).join(', '); - let tr = addRow(noteTable, note.getAttribute("name"), ptc, desc, userMap.get(note.getAttribute("creatingUser")).getAttribute("name")); + let tr = addRow(noteTable, note.getAttribute("name"), ptc, desc, name); tr.attr('data-guid', note.getAttribute("guid")); tr.attr('data-matches', matches); @@ -468,6 +490,62 @@ function parseData2(data) { tables.push(noteDataTable); } + let variables = xmlDoc.getElementsByTagName("Variable"); + let cases = xmlDoc.getElementsByTagName("Case"); + + if (variables.length > 0 && cases.length > 0) { + let variableMap = new Map(); + let variableHeaders = ["Source"]; // First column is the source document + + for (let variable of variables) { + let guid = variable.getAttribute("guid"); + let name = variable.getAttribute("name"); + // Store the variable name and its column index in the table + variableMap.set(guid, { name: name, index: variableHeaders.length }); + variableHeaders.push(name); + } + + let caseBlock = $('
').width(tableWidth).appendTo($(".preview")); + caseBlock.append($("").html("Cases")); + let caseTable = createTable("Cases", ...variableHeaders).appendTo(caseBlock); + caseTable.addClass("casetable compact stripe"); + + for (let caseNode of cases) { + let rowData = new Array(variableHeaders.length).fill(""); // Initialize row with empty strings + + // Find the source document for the case + let sourceRef = caseNode.getElementsByTagName("SourceRef")[0]; + if (sourceRef) { + let sourceGuid = sourceRef.getAttribute("targetGUID"); + let source = sourceMap.get(sourceGuid); + if (source) { + rowData[0] = createSourceReference(source, zipUrl); + } + } + + // Populate variable values for the case + let variableValues = caseNode.getElementsByTagName("VariableValue"); + for (let varValue of variableValues) { + let varRef = varValue.getElementsByTagName("VariableRef")[0]; + let textValue = varValue.getElementsByTagName("TextValue")[0]; + if (varRef && textValue) { + let varGuid = varRef.getAttribute("targetGUID"); + let variableInfo = variableMap.get(varGuid); + if (variableInfo) { + rowData[variableInfo.index] = textValue.textContent; + } + } + } + addRow(caseTable, ...rowData); + } + + // Initialize DataTable for cases, but don't add to filterable tables + new DataTable(".casetable", { + select: false // This table should not be selectable + }); + } + + let sets = xmlDoc.getElementsByTagName("Set"); if (sets != null && sets.length > 0) { $('#filterby').append($('').prop('value', 'Sets').text('Sets')); @@ -487,7 +565,7 @@ function parseData2(data) { let codeId = member.getAttribute('targetGUID'); let code = codeMap.get(codeId); if (code != null) { - codeNames = codeNames + ' ' + code.getAttribute("name"); + codeNames = codeNames + '; ' + code.getAttribute("name"); } matches += codeId; }