Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing conformance criteria roll up count from a list to a table #354

Merged
merged 3 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 86 additions & 25 deletions dist/createOutput.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ function createOutput(data, catalogData, templateType, templateString) {
}
}
});
const getCatalogComponentLabel = (componentId) => {
if (catalogData.components) {
for (const component of catalogData.components) {
if (component.id === componentId) {
if (component.label != "") {
return component.label;
}
else {
return "All";
}
}
}
}
};
handlebars_1.default.registerHelper("catalogComponentLabel", function (componentId) {
if (catalogData.components) {
for (const component of catalogData.components) {
Expand All @@ -61,7 +75,7 @@ function createOutput(data, catalogData, templateType, templateString) {
}
}
});
handlebars_1.default.registerHelper("levelLabel", function (level) {
const getLevelLabel = (level) => {
if (catalogData.terms) {
for (const terms of catalogData.terms) {
if (terms.id === level) {
Expand All @@ -71,7 +85,8 @@ function createOutput(data, catalogData, templateType, templateString) {
}
// If a level is provided but has no matching terms, provide a default.
return "Not Applicable";
});
};
handlebars_1.default.registerHelper("levelLabel", getLevelLabel);
handlebars_1.default.registerHelper("standardsIncluded", function (standardChapters) {
const result = [];
for (const standardChapter of standardChapters) {
Expand Down Expand Up @@ -145,42 +160,88 @@ function createOutput(data, catalogData, templateType, templateString) {
return levelCount;
});
handlebars_1.default.registerHelper("progressPerChapter", function (criterias) {
let supportCount = 0;
let partiallySupportCount = 0;
let doesNotSupportCount = 0;
let notApplicableCount = 0;
let tableHeader = "";
let tableHeaderMarkdownUnderline = "";
const tableCounts = [];
for (const component of criterias[0].components) {
if (templateType === "html") {
tableHeader += `<th>${getCatalogComponentLabel(component.name)}</th>`;
}
else {
tableHeader += ` | ${getCatalogComponentLabel(component.name)}`;
tableHeaderMarkdownUnderline += " | ---";
}
tableCounts[component.name] = [];
}
for (const criteria of criterias) {
if (criteria.components) {
for (const component of criteria.components) {
if (component.adherence && component.adherence.level === "supports") {
supportCount = supportCount + 1;
if (component.adherence) {
if (tableCounts[component.name] === undefined) {
if (templateType === "html") {
tableHeader += `<th>${getCatalogComponentLabel(component.name)}</th>`;
}
else {
tableHeader += ` | ${getCatalogComponentLabel(component.name)}`;
tableHeaderMarkdownUnderline += " | ---";
}
tableCounts[component.name] = [];
}
if (tableCounts[component.name][component.adherence.level]) {
tableCounts[component.name][component.adherence.level] += 1;
}
else {
tableCounts[component.name][component.adherence.level] = 1;
}
}
else if (component.adherence &&
component.adherence.level === "partially-supports") {
partiallySupportCount = partiallySupportCount + 1;
}
}
}
let tableBody = "";
if (catalogData.terms) {
for (const term of catalogData.terms) {
if (term.label != "" && term.id != "not-evaluated") {
if (templateType === "html") {
tableBody += `<tr><td>${getLevelLabel(term.id)}</td>`;
}
else {
tableBody += `| ${getLevelLabel(term.id)}`;
}
for (const component in tableCounts) {
if (templateType === "html") {
if (tableCounts[component] && tableCounts[component][term.id]) {
tableBody += `<td>${tableCounts[component][term.id]}</td>`;
}
else {
tableBody += "<td>0</td>";
}
}
else {
if (tableCounts[component] && tableCounts[component][term.id]) {
tableBody += ` | ${tableCounts[component][term.id]}`;
}
else {
tableBody += " | 0";
}
}
}
else if (component.adherence &&
component.adherence.level === "does-not-support") {
doesNotSupportCount = doesNotSupportCount + 1;
if (templateType === "html") {
tableBody += "</tr>";
}
else if (component.adherence &&
component.adherence.level === "not-applicable") {
notApplicableCount = notApplicableCount + 1;
else {
tableBody += ` |
`;
}
}
}
}
if (templateType === "html") {
return new handlebars_1.default.SafeString(`<li>${supportCount} supported</li>
<li>${partiallySupportCount} partially supported</li>
<li>${doesNotSupportCount} not supported</li>
<li>${notApplicableCount} not applicable</li>`);
return new handlebars_1.default.SafeString(`<thead><tr><th>Conformance Level</th>${tableHeader}</tr></thead>${tableBody}`);
}
else {
return `- ${supportCount} supported
- ${partiallySupportCount} partially supported
- ${doesNotSupportCount} not supported
- ${notApplicableCount} not applicable`;
return `| Conformance Level${tableHeader} |
| ---${tableHeaderMarkdownUnderline} |
${tableBody}`;
}
});
handlebars_1.default.registerHelper("sanitizeMarkdown", function (text) {
Expand Down
4 changes: 2 additions & 2 deletions docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Current example OpenACRs that are tracked in this repository are in the `openacr

OpenACRs:

- drupal-10-15.yaml: Drupal 10 OpenACR.
- drupal-10-16.yaml: Drupal 10 OpenACR.
- drupal-9.yaml: Drupal 9 OpenACR.
- govready-0.9.yaml
- Moodle-3.yaml
Expand All @@ -180,7 +180,7 @@ OpenACRs:
To regenerate the above OpenACR markdown and HTML reports run the following commands:

```bash
npx ts-node src/openacr.ts output -f openacr/drupal-10-15.yaml -c catalog/2.4-edition-wcag-2.1-en.yaml -o openacr/drupal-10-15.html
npx ts-node src/openacr.ts output -f openacr/drupal-10-16.yaml -c catalog/2.4-edition-wcag-2.1-en.yaml -o openacr/drupal-10-16.html
npx ts-node src/openacr.ts output -f openacr/drupal-9.yaml -c catalog/2.4-edition-wcag-2.1-508-en.yaml -o openacr/drupal-9.html
npx ts-node src/openacr.ts output -f openacr/drupal-9.yaml -c catalog/2.4-edition-wcag-2.1-508-en.yaml -o openacr/drupal-9.markdown
npx ts-node src/openacr.ts output -f openacr/govready-0.9.yaml -c catalog/2.4-edition-wcag-2.0-508-en.yaml -o openacr/govready-0.9.html
Expand Down
Loading
Loading