Skip to content

Commit 86f890a

Browse files
dmundramgiffordpre-commit
authored
Changing conformance criteria roll up count from a list to a table (#354)
* Drupal upgrade NextGen (#18) * Just the new drupal files * delete old acr * delete old acr * pre-commit fixes --------- Co-authored-by: pre-commit <pre-commit@example.com> * Updated html (#19) * Update drupal-10-16.yaml Changing the path to CivicActions. * Update drupal-10-16.html Using the CLI * Moving the 16 Simple * Adding Drupal 10 16 Simple * pre-commit fixes * Updated Drupal 10 yaml version. --------- Co-authored-by: pre-commit <pre-commit@example.com> Co-authored-by: Daniel Mundra <daniel.mundra@civicactions.com> * Criteria counts as table (#20) * Redoing progressPerChapter to output counts as a table. * Removed skipping of none label. * Adjusted table counts per row display. * Added functions to get level and component labels to use in the progress table. * Updating markdown examples after testing. Reset output functions. * Changed any column header to all and added margin to simple table. * Removed un-needed conditional check. * Added check for undefined and updated all examples. * Added test when first criteria has missing components. Updated output logic and regenerated examples. * Updated tests. * Updated version and ran JS build. --------- Co-authored-by: Mike Gifford <mike.gifford@civicactions.com> Co-authored-by: pre-commit <pre-commit@example.com>
1 parent 76250c2 commit 86f890a

26 files changed

Lines changed: 2845 additions & 1244 deletions

dist/createOutput.js

Lines changed: 86 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,20 @@ function createOutput(data, catalogData, templateType, templateString) {
4545
}
4646
}
4747
});
48+
const getCatalogComponentLabel = (componentId) => {
49+
if (catalogData.components) {
50+
for (const component of catalogData.components) {
51+
if (component.id === componentId) {
52+
if (component.label != "") {
53+
return component.label;
54+
}
55+
else {
56+
return "All";
57+
}
58+
}
59+
}
60+
}
61+
};
4862
handlebars_1.default.registerHelper("catalogComponentLabel", function (componentId) {
4963
if (catalogData.components) {
5064
for (const component of catalogData.components) {
@@ -61,7 +75,7 @@ function createOutput(data, catalogData, templateType, templateString) {
6175
}
6276
}
6377
});
64-
handlebars_1.default.registerHelper("levelLabel", function (level) {
78+
const getLevelLabel = (level) => {
6579
if (catalogData.terms) {
6680
for (const terms of catalogData.terms) {
6781
if (terms.id === level) {
@@ -71,7 +85,8 @@ function createOutput(data, catalogData, templateType, templateString) {
7185
}
7286
// If a level is provided but has no matching terms, provide a default.
7387
return "Not Applicable";
74-
});
88+
};
89+
handlebars_1.default.registerHelper("levelLabel", getLevelLabel);
7590
handlebars_1.default.registerHelper("standardsIncluded", function (standardChapters) {
7691
const result = [];
7792
for (const standardChapter of standardChapters) {
@@ -145,42 +160,88 @@ function createOutput(data, catalogData, templateType, templateString) {
145160
return levelCount;
146161
});
147162
handlebars_1.default.registerHelper("progressPerChapter", function (criterias) {
148-
let supportCount = 0;
149-
let partiallySupportCount = 0;
150-
let doesNotSupportCount = 0;
151-
let notApplicableCount = 0;
163+
let tableHeader = "";
164+
let tableHeaderMarkdownUnderline = "";
165+
const tableCounts = [];
166+
for (const component of criterias[0].components) {
167+
if (templateType === "html") {
168+
tableHeader += `<th>${getCatalogComponentLabel(component.name)}</th>`;
169+
}
170+
else {
171+
tableHeader += ` | ${getCatalogComponentLabel(component.name)}`;
172+
tableHeaderMarkdownUnderline += " | ---";
173+
}
174+
tableCounts[component.name] = [];
175+
}
152176
for (const criteria of criterias) {
153177
if (criteria.components) {
154178
for (const component of criteria.components) {
155-
if (component.adherence && component.adherence.level === "supports") {
156-
supportCount = supportCount + 1;
179+
if (component.adherence) {
180+
if (tableCounts[component.name] === undefined) {
181+
if (templateType === "html") {
182+
tableHeader += `<th>${getCatalogComponentLabel(component.name)}</th>`;
183+
}
184+
else {
185+
tableHeader += ` | ${getCatalogComponentLabel(component.name)}`;
186+
tableHeaderMarkdownUnderline += " | ---";
187+
}
188+
tableCounts[component.name] = [];
189+
}
190+
if (tableCounts[component.name][component.adherence.level]) {
191+
tableCounts[component.name][component.adherence.level] += 1;
192+
}
193+
else {
194+
tableCounts[component.name][component.adherence.level] = 1;
195+
}
157196
}
158-
else if (component.adherence &&
159-
component.adherence.level === "partially-supports") {
160-
partiallySupportCount = partiallySupportCount + 1;
197+
}
198+
}
199+
}
200+
let tableBody = "";
201+
if (catalogData.terms) {
202+
for (const term of catalogData.terms) {
203+
if (term.label != "" && term.id != "not-evaluated") {
204+
if (templateType === "html") {
205+
tableBody += `<tr><td>${getLevelLabel(term.id)}</td>`;
206+
}
207+
else {
208+
tableBody += `| ${getLevelLabel(term.id)}`;
209+
}
210+
for (const component in tableCounts) {
211+
if (templateType === "html") {
212+
if (tableCounts[component] && tableCounts[component][term.id]) {
213+
tableBody += `<td>${tableCounts[component][term.id]}</td>`;
214+
}
215+
else {
216+
tableBody += "<td>0</td>";
217+
}
218+
}
219+
else {
220+
if (tableCounts[component] && tableCounts[component][term.id]) {
221+
tableBody += ` | ${tableCounts[component][term.id]}`;
222+
}
223+
else {
224+
tableBody += " | 0";
225+
}
226+
}
161227
}
162-
else if (component.adherence &&
163-
component.adherence.level === "does-not-support") {
164-
doesNotSupportCount = doesNotSupportCount + 1;
228+
if (templateType === "html") {
229+
tableBody += "</tr>";
165230
}
166-
else if (component.adherence &&
167-
component.adherence.level === "not-applicable") {
168-
notApplicableCount = notApplicableCount + 1;
231+
else {
232+
tableBody += ` |
233+
`;
169234
}
170235
}
171236
}
172237
}
173238
if (templateType === "html") {
174-
return new handlebars_1.default.SafeString(`<li>${supportCount} supported</li>
175-
<li>${partiallySupportCount} partially supported</li>
176-
<li>${doesNotSupportCount} not supported</li>
177-
<li>${notApplicableCount} not applicable</li>`);
239+
return new handlebars_1.default.SafeString(`<thead><tr><th>Conformance Level</th>${tableHeader}</tr></thead>${tableBody}`);
178240
}
179241
else {
180-
return `- ${supportCount} supported
181-
- ${partiallySupportCount} partially supported
182-
- ${doesNotSupportCount} not supported
183-
- ${notApplicableCount} not applicable`;
242+
return `| Conformance Level${tableHeader} |
243+
| ---${tableHeaderMarkdownUnderline} |
244+
${tableBody}`;
184245
}
185246
});
186247
handlebars_1.default.registerHelper("sanitizeMarkdown", function (text) {

docs/CLI.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ Current example OpenACRs that are tracked in this repository are in the `openacr
170170

171171
OpenACRs:
172172

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

182182
```bash
183-
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
183+
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
184184
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
185185
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
186186
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

0 commit comments

Comments
 (0)