Skip to content

Commit

Permalink
Config page accessibility update (#648)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleygyngell committed Jun 19, 2024
1 parent 62f31d5 commit ef1bc35
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 27 deletions.
16 changes: 3 additions & 13 deletions app/routes/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,9 @@ module.exports = function (router) {
})
}

const generateRulesDisabled = function (rulesEnabled) {
const rules = []

for (const rule in autoApprovalRulesEnum) {
rules.push(autoApprovalRulesEnum[rule].value)
}
const rulesDisabled = []

rules.forEach(function (rule) {
if (rulesEnabled.indexOf(rule) === -1) {
rulesDisabled.push(rule)
}
})
const generateRulesDisabled = (rulesEnabled) => {
const rules = Object.values(autoApprovalRulesEnum).map(rule => rule.value)
const rulesDisabled = rules.filter(rule => !rulesEnabled.includes(rule))

return rulesDisabled
}
31 changes: 17 additions & 14 deletions app/views/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
{ name:"AutoApprovalEnabled", value: "true", text: "On", checked: autoApprovalConfig.AutoApprovalEnabled },
{ name:"AutoApprovalEnabled", value: "false", text: "Off", checked: not autoApprovalConfig.AutoApprovalEnabled }
],
errorMessage: { text: '' } if errors['auto-approval-enabled']
errorMessage: errors['auto-approval-enabled']
}) }
],
[
Expand All @@ -48,7 +48,7 @@
value: autoApprovalConfig.CostVariancePercentage,
prefix: { text: "%" },
spellcheck: false,
errorMessage: { text: '' } if errors['cost-variance-percentage']
errorMessage: errors['cost-variance-percentage']
}) }
],
[
Expand All @@ -62,7 +62,7 @@
value: autoApprovalConfig.MaxClaimTotal,
prefix: { text: "£" },
spellcheck: false,
errorMessage: { text: '' } if errors['max-claim-total']
errorMessage: errors['max-claim-total']
}) }
],
[
Expand All @@ -76,7 +76,7 @@
value: autoApprovalConfig.MaxDaysAfterAPVUVisit,
suffix: { text: "days" },
spellcheck: false,
errorMessage: { text: '' } if errors['max-days-after-apvu-visit']
errorMessage: errors['max-days-after-apvu-visit']
}) }
],
[
Expand All @@ -90,7 +90,7 @@
value: autoApprovalConfig.MaxNumberOfClaimsPerYear,
suffix: { text: "claims" },
spellcheck: false,
errorMessage: { text: '' } if errors['max-number-of-claims-per-year']
errorMessage: errors['max-number-of-claims-per-year']
}) }
],
[
Expand All @@ -104,7 +104,7 @@
value: autoApprovalConfig.MaxNumberOfClaimsPerMonth,
suffix: { text: "claims" },
spellcheck: false,
errorMessage: { text: '' } if errors['max-number-of-claims-per-month']
errorMessage: errors['max-number-of-claims-per-month']
}) }
],
[
Expand All @@ -118,7 +118,7 @@
value: autoApprovalConfig.NumberOfConsecutiveAutoApprovals,
suffix: { text: "approvals" },
spellcheck: false,
errorMessage: { text: '' } if errors['number-of-consecutive-auto-approvalss']
errorMessage: errors['number-of-consecutive-auto-approvals']
}) }
]
]
Expand All @@ -132,13 +132,18 @@
{% for key, rule in autoApprovalRulesEnum %}
{% set row = [
{ text: rule.displayName, classes: "govuk-!-width-one-quarter" },
{ text: rule.description, classes: "config-description "},
{ text: rule.description, classes: "config-description"},
{ html: govukCheckboxes({
formGroup: { classes: 'govuk-!-margin-0' },
name: "rulesEnabled",
classes: "config-rule-checkbox",
items: [
{ value: rule.value, text: " ", checked: rule.value not in rulesDisabled }
{ label: {
attributes: {
for: rule.displayName
}
}
, value: rule.value, text: " ", checked: rule.value not in rulesDisabled }
]
}) }
] %}
Expand Down Expand Up @@ -168,11 +173,10 @@
label: { text: "The minimum claim amount that will be included in audit report ", classes: "govuk-visually-hidden govuk-!-margin-bottom-0" },
formGroup: { classes: 'govuk-!-margin-0 ' },
id: "audit-threshold",
name: "ThresholdAmount",
name: "AuditThreshold",
value: auditConfig.ThresholdAmount,
prefix: { text: "£" },
spellcheck: false,
errorMessage: { text: '' } if errors['audit-threshold']
errorMessage: errors['audit-threshold']
}) }
],
[
Expand All @@ -185,8 +189,7 @@
name: "VerificationPercentage",
value: auditConfig.VerificationPercent,
prefix: { text: "%" },
spellcheck: false,
errorMessage: { text: '' } if errors['audit-verification-percentage']
errorMessage: errors['audit-verification-percentage']
}) }
]
]
Expand Down

0 comments on commit ef1bc35

Please sign in to comment.