diff --git a/src/content/statusPage.js b/src/content/statusPage.js index 3288b011..81dffbee 100644 --- a/src/content/statusPage.js +++ b/src/content/statusPage.js @@ -1,6 +1,6 @@ export const headingTexts = { checking: 'Checking your data', - checked: 'Data Checked' + checked: 'Data checked' } export const messageTexts = { diff --git a/src/controllers/resultsController.js b/src/controllers/resultsController.js index bc84c94a..aee6192e 100644 --- a/src/controllers/resultsController.js +++ b/src/controllers/resultsController.js @@ -65,11 +65,17 @@ class ResultsController extends PageController { fields: responseDetails.getFields() } - req.form.options.errorSummary = requestData.getErrorSummary() + req.form.options.errorSummary = requestData.getErrorSummary().map(message => { + return { + text: message, + href: '' + } + }) req.form.options.mappings = responseDetails.getFieldMappings() req.form.options.geometries = responseDetails.getGeometries() req.form.options.pagination = responseDetails.getPagination(req.params.pageNumber) req.form.options.id = req.params.id + req.form.options.lastPage = `/check/status/${req.params.id}` } else { req.form.options.error = requestData.getError() } diff --git a/src/controllers/statusController.js b/src/controllers/statusController.js index afbd8216..9afcae2e 100644 --- a/src/controllers/statusController.js +++ b/src/controllers/statusController.js @@ -3,6 +3,22 @@ import { getRequestData } from '../services/asyncRequestApi.js' import { finishedProcessingStatuses } from '../utils/utils.js' import { headingTexts, messageTexts } from '../content/statusPage.js' +/** + * Attempts to infer how we ended up on this page. + * + * @param req + * @returns {string?} + */ +function getLastPage (req) { + let lastPage + if ('url' in req.form.options.data.params) { + lastPage = '/check/url' + } else if ('original_filename' in req.form.options.data.params) { + lastPage = '/check/upload' + } + return lastPage +} + class StatusController extends PageController { async locals (req, res, next) { try { @@ -11,6 +27,10 @@ class StatusController extends PageController { req.form.options.headingTexts = headingTexts req.form.options.messageTexts = messageTexts req.form.options.pollingEndpoint = `/api/status/${req.form.options.data.id}` + const lastPage = getLastPage(req) + if (lastPage) { + req.form.options.lastPage = lastPage + } super.locals(req, res, next) } catch (error) { next(error, req, res, next) diff --git a/src/models/requestData.js b/src/models/requestData.js index badac124..74458e31 100644 --- a/src/models/requestData.js +++ b/src/models/requestData.js @@ -32,6 +32,10 @@ export default class ResultData { return new ResponseDetails(this.id, response.data, pagination, this.getColumnFieldLog()) } + /** + * + * @returns {string[]} + */ getErrorSummary () { if (!this.response || !this.response.data || !this.response.data['error-summary']) { logger.warn('trying to get error summary when there is none', { requestId: this.id }) diff --git a/src/views/check/confirmation.html b/src/views/check/confirmation.html index c72c3db0..6ff79bd7 100644 --- a/src/views/check/confirmation.html +++ b/src/views/check/confirmation.html @@ -1,4 +1,4 @@ - +{% from 'govuk/components/back-link/macro.njk' import govukBackLink %} {% from 'govuk/components/panel/macro.njk' import govukPanel %} {% from "govuk/components/details/macro.njk" import govukDetails %} @@ -7,6 +7,14 @@ {% set serviceType = 'Check' %} {% set pageName = "You can now publish your data" %} +{% block beforeContent %} + {{ govukBackLink({ + text: "Back", + href: "javascript:window.history.back()" + }) }} +{% endblock %} + + {% set content %} # What to do next @@ -31,7 +39,7 @@ Details about what to do next are also available [in the guidance](/guidance) {% if options.deepLink %} -
Return to {{ options.deepLink.dataset }} overview
+Return to {{ options.deepLink.dataset | datasetSlugToReadableName }} overview
{% else %} {% endif %} diff --git a/src/views/check/results/errors.html b/src/views/check/results/errors.html index c83a1bfb..1edc23c2 100644 --- a/src/views/check/results/errors.html +++ b/src/views/check/results/errors.html @@ -4,9 +4,9 @@ {% from 'govuk/components/radios/macro.njk' import govukRadios %} {% from 'govuk/components/inset-text/macro.njk' import govukInsetText %} {% from "govuk/components/pagination/macro.njk" import govukPagination %} - -{% from 'components/dataset-banner.html' import datasetBanner %} -{% from 'components/table.html' import table %} +{% from 'govuk/components/error-summary/macro.njk' import govukErrorSummary %} +{% from "../../components/table.html" import table %} +{% from '../../components/dataset-banner.html' import datasetBanner %} {% set serviceType = 'Check' %} {% set pageName = 'Your data has errors' %} @@ -36,23 +36,22 @@Here’s your data on a map:
- - {% endif %} - -