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

Add issue specification guidance to issueTable page #818

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@
- 📗 Update any related documentation and include any relevant screenshots.
-->

## Preview Link

<!--
Replace [PR_NUMBER] with the actual PR number to generate the preview URL.
For example, for PR #818, the preview link would be:
https://submit-pr-818.herokuapp.com/
-->

https://submit-pr-[PR_NUMBER].herokuapp.com/

## What type of PR is this? (check all applicable)

- [ ] Refactor
Expand Down
10 changes: 10 additions & 0 deletions src/middleware/common.middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,16 @@ export function getErrorSummaryItems (req, res, next) {
next()
}

export function getIssueSpecification (req, res, next) {
const { issue_field: issueField } = req.params
const { specification } = req

const fieldSpecification = specification.fields.find(f => f.field === issueField)
req.issueSpecification = fieldSpecification ?? undefined

next()
}

export const prepareIssueDetailsTemplateParams = (req, res, next) => {
const { entry, pagination, dataRange, errorSummary, dataset, orgInfo } = req
const { issue_type: issueType, issue_field: issueField, pageNumber } = req.parsedParams
Expand Down
8 changes: 5 additions & 3 deletions src/middleware/issueTable.middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import config from '../../config/index.js'
import { createPaginationTemplateParams, fetchDatasetInfo, fetchOrgInfo, fetchResources, filterOutEntitiesWithoutIssues, getErrorSummaryItems, getSetBaseSubPath, getSetDataRange, logPageError, processEntitiesMiddlewares, processRelevantIssuesMiddlewares, processSpecificationMiddlewares, show404IfPageNumberNotInRange, validateQueryParams } from './common.middleware.js'
import { createPaginationTemplateParams, fetchDatasetInfo, fetchOrgInfo, fetchResources, filterOutEntitiesWithoutIssues, getErrorSummaryItems, getIssueSpecification, getSetBaseSubPath, getSetDataRange, logPageError, processEntitiesMiddlewares, processRelevantIssuesMiddlewares, processSpecificationMiddlewares, show404IfPageNumberNotInRange, validateQueryParams } from './common.middleware.js'
import { onlyIf, renderTemplate } from './middleware.builders.js'
import * as v from 'valibot'
import { entryIssueGroups } from '../utils/utils.js'
Expand Down Expand Up @@ -74,7 +74,7 @@ export const prepareTableParams = (req, res, next) => {
}

export const prepareTemplateParams = (req, res, next) => {
const { tableParams, orgInfo, dataset, errorSummary, pagination, dataRange } = req
const { tableParams, orgInfo, dataset, errorSummary, pagination, dataRange, issueSpecification } = req
const { issue_type: issueType } = req.params

req.templateParams = {
Expand All @@ -84,7 +84,8 @@ export const prepareTemplateParams = (req, res, next) => {
errorSummary,
issueType,
pagination,
dataRange
dataRange,
issueSpecification
}
next()
}
Expand Down Expand Up @@ -122,6 +123,7 @@ export default [
show404IfPageNumberNotInRange,
getSetBaseSubPath(),
getErrorSummaryItems,
getIssueSpecification,
createPaginationTemplateParams,
prepareTableParams,
prepareTemplateParams,
Expand Down
6 changes: 6 additions & 0 deletions src/routes/schemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ export const OrgIssueTable = v.strictObject({
dataset: DatasetNameField,
errorSummary: errorSummaryParams,
issueType: v.string(),
issueSpecification: v.optional(v.strictObject({
datasetField: NonEmptyString,
field: NonEmptyString,
description: v.optional(NonEmptyString),
dataset: v.optional(NonEmptyString)
})),
tableParams,
pagination: PaginationParams,
dataRange: dataRangeParams
Expand Down
31 changes: 31 additions & 0 deletions src/views/organisations/issueTable.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{% from "govuk/components/summary-list/macro.njk" import govukSummaryList %}
{% from "govuk/components/pagination/macro.njk" import govukPagination %}
{% from "govuk/components/breadcrumbs/macro.njk" import govukBreadcrumbs %}
{% from "govuk/components/inset-text/macro.njk" import govukInsetText %}

{% from "../components/table.html" import table %}

Expand Down Expand Up @@ -96,6 +97,36 @@
</div>
{% endif %}

{% if issueSpecification %}
{% set issueSpecificationInsetHtml %}
<div>
<h3 class="govuk-heading-m">{{ issueSpecification.field }}</h3>

{% if issueSpecification.description %}
{{ issueSpecification.description | govukMarkdown | safe }}
{% endif %}

{% if issueSpecification.guidance %}
{{ issueSpecification.guidance | govukMarkdown | safe }}
{% endif %}
</div>
{% endset %}

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-l">
How to fix this issue
</h2>

<p class="govuk-body">Your dataset is missing the <strong>{{ issueSpecification.field }}</strong> column.</p>
<p class="govuk-body">The <a href="{{ dataset.dataset | getDatasetGuidanceUrl }}" target="_blank">{{ dataset.name }}</a> guidance explains how to fix the issue:</p>
{{ govukInsetText({
html: issueSpecificationInsetHtml
}) }}
</div>
</div>
{% endif %}

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h3 class="govuk-heading-m">
Expand Down
Loading