Skip to content

Commit

Permalink
fix: error viewing summary reports (#452)
Browse files Browse the repository at this point in the history
* fix: ignore other keys added in scanItems which are not categories

* Bump package version

---------

Co-authored-by: younglim <[email protected]>
  • Loading branch information
shioju and younglim authored Feb 5, 2025
1 parent 3fe89df commit 6765616
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@govtechsg/oobee",
"main": "dist/npmIndex.js",
"version": "0.10.26",
"version": "0.10.27",
"type": "module",
"author": "Government Technology Agency <[email protected]>",
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions src/static/ejs/partials/scripts/reportSearch.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@
function resetIssueOccurrence(filteredItems) {
for (let category in filteredItems) {
if (!["mustFix", "goodToFix", "needsReview", "passed"].includes(category)) continue; // skip other props like pagesScanned, etc
const issueLabel = filteredItems[category].rules.length === 1 ? 'issue' : 'issues';
const occurrenceLabel =
filteredItems[category].totalItems === 1 ? 'occurrence' : 'occurrences';
Expand Down
17 changes: 7 additions & 10 deletions src/static/ejs/report.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
const scategoryList = document.getElementById('categorySelector');
Object.keys(scanItems).forEach(category => {
if (category !== 'passed') {
if (["mustFix", "goodToFix", "needsReview"].includes(category)) { // skip other keys like pagesScanned, etc
const categoryData = scanItems[category];
const listItem = document.createElement('div');
listItem.className = 'col-md-4 px-2';
Expand Down Expand Up @@ -170,12 +170,10 @@
spanInfo.id = `${category}ItemsInformation`;
spanInfo.className = 'category-information';
if (category !== 'passed' && categoryData.totalItems !== 0) {
if (categoryData.totalItems !== 0) {
spanInfo.textContent = `${categoryData.rules.length} ${categoryData.rules.length === 1 ? 'issue' : 'issues'} / ${categoryData.totalItems} ${categoryData.totalItems === 1 ? 'occurrence' : 'occurrences'}`;
} else if (category !== 'passed' && categoryData.totalItems === 0) {
} else if (categoryData.totalItems === 0) {
spanInfo.textContent = `0 issues`;
} else {
spanInfo.textContent = `${categoryData.totalItems} ${categoryData.totalItems === 1 ? 'occurrence' : 'occurrences'}`;
}
button.appendChild(divFlex);
Expand All @@ -188,7 +186,8 @@
const categoryList = document.getElementById('issueTypeListbox');
Object.keys(scanItems).forEach(category => {
if (category !== 'passed') {
if (["mustFix", "goodToFix", "needsReview"].includes(category)) { // skip other keys like pagesScanned, etc
const categoryData = scanItems[category];
const rulesLength = categoryData.rules ? categoryData.rules.length : 0;
Expand All @@ -207,12 +206,10 @@
spanInfo.id = `${category}ItemsInformation`;
spanInfo.className = 'category-information';
if (category !== 'passed' && categoryData.totalItems !== 0) {
if (categoryData.totalItems !== 0) {
spanInfo.textContent = `(${categoryData.rules.length} ${categoryData.rules.length === 1 ? 'issue' : 'issues'})`;
} else if (category !== 'passed' && categoryData.totalItems === 0) {
} else if (categoryData.totalItems === 0) {
spanInfo.textContent = `(0 issues)`;
} else {
spanInfo.textContent = `(${categoryData.totalItems} ${categoryData.totalItems === 1 ? 'occurrence' : 'occurrences'})`;
}
listItem.appendChild(spanTitle);
Expand Down

0 comments on commit 6765616

Please sign in to comment.