Skip to content

Commit

Permalink
Merge pull request #24 from digital-land/realignWithPrototype
Browse files Browse the repository at this point in the history
Realign with prototype
  • Loading branch information
GeorgeGoodall authored Dec 1, 2023
2 parents 92c0544 + a0eface commit 34a1cb6
Show file tree
Hide file tree
Showing 12 changed files with 208 additions and 308 deletions.
46 changes: 6 additions & 40 deletions src/controllers/datasetController.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,17 @@ import MyController from './MyController.js'

// ToDo: we shouldn't hardcode these values here, should we get them from the API
// maybe take from specification
const datasetOptions = {
'Article 4': [
{
value: 'article-4-direction',
text: 'Article 4 direction dataset'
},
{
value: 'article-4-direction area',
text: 'Article 4 direction area dataset'
}
],
'Conservation area': [
{
value: 'conservation-area',
text: 'Conservation area dataset'
},
{
value: 'conservation-area-document',
text: 'Conservation area document dataset'
}
],
'Tree preservation order': [
{
value: 'tree-preservation-order',
text: 'Tree preservation order dataset'
},
{
value: 'tree-preservation-zone',
text: 'Tree preservation zone dataset'
},
{
value: 'tree',
text: 'Tree dataset'
}
],
'Listed building': false
}
import { dataSubjects } from '../utils/utils.js'

class DatasetController extends MyController {
get (req, res, next) {
const dataset = req.sessionModel.get('data-subject')
const options = datasetOptions[dataset]
// const dataset = req.sessionModel.get('data-subject')
// const options = datasetOptions[dataset]

const options = [dataSubjects['Article 4'].dataSets[0], dataSubjects['Conservation area'].dataSets[0]]

if (options) {
this.availableDatasets = options
this.availableDatasets = options.filter(option => option.available)
req.form.options.datasetItems = options
super.get(req, res, next)
} else {
Expand Down
16 changes: 13 additions & 3 deletions src/controllers/errorsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import MyController from './MyController.js'

import { severityLevels } from '../utils/utils.js'
import { severityLevels, dataSubjects } from '../utils/utils.js'

class ErrorsController extends MyController {
get (req, res, next) {
Expand All @@ -15,8 +15,18 @@ class ErrorsController extends MyController {
req.form.options.rows = rows
req.form.options.issueCounts = issueCounts
req.form.options.columnNames = Object.keys(rows[0])
// ToDo: should the api return the columns here?
// or should we get them from the specification?

const dataSetValue = req.sessionModel.get('dataset')

// ToDo: optimise this
for (const [key, value] of Object.entries(dataSubjects)) {
for (const dataset of value.dataSets) {
if (dataset.value === dataSetValue) {
req.form.options.dataSubject = key
req.form.options.dataset = dataset.text
}
}
}

super.get(req, res, next)
}
Expand Down
50 changes: 25 additions & 25 deletions src/routes/form-wizard/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ export default {
'/': {
entryPoint: true,
resetJourney: true,
next: 'data-subject',
next: 'dataset',
template: '../views/start.html'
},
'/data-subject': {
...baseSettings,
fields: ['data-subject'],
next: 'dataset'
},
// '/data-subject': {
// ...baseSettings,
// fields: ['data-subject'],
// next: 'dataset'
// },
'/dataset': {
...baseSettings,
controller: datasetController,
Expand All @@ -42,28 +42,28 @@ export default {
next: 'no-errors'
},
'/no-errors': {
...baseSettings,
next: 'email-address'
},
'/email-address': {
...baseSettings,
fields: ['email-address'],
next: 'name'
},
'/name': {
...baseSettings,
fields: ['first-name', 'last-name'],
next: 'lpa'
},
'/lpa': {
...baseSettings,
fields: ['lpa'],
next: 'check'
},
'/check': {
...baseSettings,
next: 'confirmation'
},
// '/email-address': {
// ...baseSettings,
// fields: ['email-address'],
// next: 'name'
// },
// '/name': {
// ...baseSettings,
// fields: ['first-name', 'last-name'],
// next: 'lpa'
// },
// '/lpa': {
// ...baseSettings,
// fields: ['lpa'],
// next: 'check'
// },
// '/check': {
// ...baseSettings,
// next: 'confirmation'
// },
'/confirmation': {
...baseSettings,
noPost: true
Expand Down
57 changes: 57 additions & 0 deletions src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,60 @@ export const severityLevels = {
warning: 'warning',
error: 'error'
}

export const dataSubjects = {
'Article 4': {
available: true,
dataSets: [
{
value: 'article-4-direction',
text: 'Article 4 direction dataset',
available: true
},
{
value: 'article-4-direction area',
text: 'Article 4 direction area dataset',
available: false
}
]
},
'Conservation area': {
available: true,
dataSets: [
{
value: 'conservation-area',
text: 'Conservation area dataset',
available: true
},
{
value: 'conservation-area-document',
text: 'Conservation area document dataset',
available: false
}
]
},
'Tree preservation order': {
available: false,
dataSets: [
{
value: 'tree-preservation-order',
text: 'Tree preservation order dataset',
available: false
},
{
value: 'tree-preservation-zone',
text: 'Tree preservation zone dataset',
available: false
},
{
value: 'tree',
text: 'Tree dataset',
available: false
}
]
},
'Listed building': {
available: false,
dataSets: []
}
}
64 changes: 51 additions & 13 deletions src/views/confirmation.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,65 @@
{% from 'govuk/components/panel/macro.njk' import govukPanel %}
{% from "govuk/components/details/macro.njk" import govukDetails %}

{% extends "layouts/main.html" %}

{% from 'govuk/components/panel/macro.njk' import govukPanel %}

{% set pageName = "Data sent" %}
{% set pageName = "Send your data for us to publish" %}

{% block content %}

{% set example %}

## About the data

This dataset shows the locations of conservation areas. Conservation areas are designated to safeguard areas of special architectural and historic interest, the character and appearance of which it is desirable to preserve or enhance. Within these areas special planning controls operate which need to be considered when undertaking development.

## Data

[Southwark conservations areas (CSV, 188KB)](#)

## Licensing

The data is provided under the [Open Government Licence](#).

{% endset %}

{% set content %}

## What you need to do next

You need to send an email to [[email protected]](mailto:[email protected]).

The email must include:

- your full name
- the name of your local planning authority (LPA)
- a link to a webpage containing the data on your LPA website

The webpage must include:

- a link to the data
- a summary of what the data is about
- a statement that the data is provided under the Open Government Licence

{{ govukDetails({
summaryText: "Example webpage",
text: example | govukMarkdown(headingsStartWith="m") | safe
}) }}

## Give feedback

[Give feedback about this service](/feedback) (takes 30 seconds).

{% endset %}

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
{{ govukPanel({
titleHtml: pageName
}) }}

<p>We’ve sent you a confirmation email.</p>

<h2 class="govuk-heading-m">What happens next</h2>

<p>We’ll send you an email once we publish the data. This usually happens within 5 working days.</p>

<h2 class="govuk-heading-m">
Give feedback
</h2>

<p><a href="#">Give feedback about this service</a> (takes 30 seconds).</p>
{{content | govukMarkdown(headingsStartWith="l") | safe}}

</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/views/errors.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<span class="govuk-caption-l">
{{values.dataset}}
{{options.dataset}}
</span>
<h1 class="govuk-heading-l">
{{pageName}}
Your data has errors
</h1>

<ul class="govuk-list govuk-list--bullet">
Expand All @@ -27,7 +27,7 @@ <h1 class="govuk-heading-l">
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<h2 class="govuk-heading-m">
Errors
Check your errors
</h2>
<div class="app-scrollable-container">
<table class="govuk-table">
Expand Down
4 changes: 2 additions & 2 deletions src/views/start.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

- article 4 direction data
- conservation area data
- listed building data
- tree preservation order data
{# - listed building data #}
{# - tree preservation order data #}

## Before you start

Expand Down
15 changes: 2 additions & 13 deletions test/acceptance/back_buttons.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,17 @@ import { test, expect } from '@playwright/test'
test.use({ javaScriptEnabled: false })

test.describe('Back buttons work as expected without js for', () => {
test('data subject page', async ({ page, baseURL }) => {
test('data set page', async ({ page, baseURL }) => {
await page.goto('/')
await page.click('text=Start now')
await page.getByRole('link', { name: 'Back', exact: true }).click()
expect(page.url()).toBe(baseURL + '/')
})

test('dataset page', async ({ page, baseURL }) => {
await page.goto('/')
await page.click('text=Start now')
await page.getByLabel('Conservation area').check()
await page.getByRole('button', { name: 'Continue' }).click()
await page.getByRole('link', { name: 'Back', exact: true }).click()
expect(page.url()).toBe(baseURL + '/data-subject')
})

test('upload page', async ({ page, baseURL }) => {
await page.goto('/')
await page.click('text=Start now')
await page.getByLabel('Conservation area').check()
await page.getByRole('button', { name: 'Continue' }).click()
await page.getByLabel('Conservation area dataset').check()
await page.getByLabel('Article 4 direction dataset').check()
await page.getByRole('button', { name: 'Continue' }).click()
await page.getByRole('link', { name: 'Back', exact: true }).click()
expect(page.url()).toBe(baseURL + '/dataset')
Expand Down
6 changes: 3 additions & 3 deletions test/acceptance/pages_load_ok.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ test('/ loads ok', async ({ page }) => {
})

test.describe('without a valid session, the user can not access the later pages', () => {
test('/data-subject', async ({ page }) => {
await checkSessionExpired(page, '/data-subject')
})
// test('/data-subject', async ({ page }) => {
// await checkSessionExpired(page, '/data-subject')
// })

test('/dataset', async ({ page }) => {
await checkSessionExpired(page, '/dataset')
Expand Down
Loading

0 comments on commit 34a1cb6

Please sign in to comment.