Skip to content

Commit 64dc227

Browse files
committed
add Codes # of Uses column
1 parent 6c02edf commit 64dc227

1 file changed

Lines changed: 41 additions & 5 deletions

File tree

previewers/betatest/js/refiqdacore.js

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
var userMap = new Map();
23
var codeMap = new Map();
34
var sourceMap = new Map();
@@ -164,14 +165,24 @@ function createRefiqdaFilterFunction(dataTable) {
164165
}
165166
}
166167

168+
// Count code usage across all CodeRef elements
169+
let codeUsageMap = new Map();
170+
let allCodeRefs = xmlDoc.getElementsByTagName("CodeRef");
171+
for (let codeRef of allCodeRefs) {
172+
let targetGUID = codeRef.getAttribute("targetGUID");
173+
if (targetGUID) {
174+
codeUsageMap.set(targetGUID, (codeUsageMap.get(targetGUID) || 0) + 1);
175+
}
176+
}
177+
167178
let codeBlock = $('<div/>').width(tableWidth).appendTo($(".preview"));
168179
codeBlock.append($("<h2/>").html("Codes"));
169180
// Create table with or without Color column based on whether color attributes exist
170181
let codeTable;
171182
if (hasColorAttribute) {
172-
codeTable = createTable("Codes", "Code", "Description", "Color", "Codable").appendTo(codeBlock);
183+
codeTable = createTable("Codes", "Code", "Description", "Color", "Codable", "# of Uses").appendTo(codeBlock);
173184
} else {
174-
codeTable = createTable("Codes", "Code", "Description", "Codable").appendTo(codeBlock);
185+
codeTable = createTable("Codes", "Code", "Description", "Codable", "# of Uses").appendTo(codeBlock);
175186
}
176187
codeTable.addClass("codetable compact stripe");
177188

@@ -184,12 +195,17 @@ function createRefiqdaFilterFunction(dataTable) {
184195
desc = "";
185196
}
186197
console.log("adding code row");
198+
199+
// Get usage count for this code
200+
let codeGuid = code.getAttribute("guid");
201+
let usageCount = codeUsageMap.get(codeGuid) || 0;
202+
187203
// Add row with or without color based on whether color attributes exist
188204
let tr;
189205
if (hasColorAttribute) {
190-
tr = addRow(codeTable, code.getAttribute("name"), desc, code.getAttribute("color"), code.getAttribute("isCodable"));
206+
tr = addRow(codeTable, code.getAttribute("name"), desc, code.getAttribute("color"), code.getAttribute("isCodable"), usageCount);
191207
} else {
192-
tr = addRow(codeTable, code.getAttribute("name"), desc, code.getAttribute("isCodable"));
208+
tr = addRow(codeTable, code.getAttribute("name"), desc, code.getAttribute("isCodable"), usageCount);
193209
}
194210
tr.attr('data-guid', code.getAttribute("guid"));
195211
//Currently codes don't appear to have forward links to other data types, so no data-matches attribute
@@ -224,6 +240,11 @@ function createRefiqdaFilterFunction(dataTable) {
224240
},
225241
width: "20%",
226242
targets: 3
243+
},
244+
{
245+
// Right-align the usage count column
246+
className: "dt-right",
247+
targets: 4
227248
}
228249
];
229250
} else {
@@ -238,6 +259,11 @@ function createRefiqdaFilterFunction(dataTable) {
238259
},
239260
width: "20%",
240261
targets: 2
262+
},
263+
{
264+
// Right-align the usage count column
265+
className: "dt-right",
266+
targets: 3
241267
}
242268
];
243269
}
@@ -620,7 +646,7 @@ $("#filterby")
620646
}
621647
if ($(".codetable").length) {
622648
// Need to check if color column exists before recreating the table
623-
let hasColorColumn = $('.codetable thead th').length === 4; // 4 columns means Color is present
649+
let hasColorColumn = $('.codetable thead th').length === 5; // 5 columns means Color is present plus # of Uses
624650
let codeConfig = {
625651
select: $('#filterby').val() == 'Codes'
626652
};
@@ -645,6 +671,11 @@ $("#filterby")
645671
},
646672
"width": "20%",
647673
"targets": 3
674+
},
675+
{
676+
// Right-align the usage count column
677+
className: "dt-right",
678+
targets: 4
648679
}
649680
];
650681
} else {
@@ -659,6 +690,11 @@ $("#filterby")
659690
},
660691
"width": "20%",
661692
"targets": 2
693+
},
694+
{
695+
// Right-align the usage count column
696+
className: "dt-right",
697+
targets: 3
662698
}
663699
];
664700
}

0 commit comments

Comments
 (0)