-
Notifications
You must be signed in to change notification settings - Fork 5
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
PUB-2588 Add List Type For Court Subscription #1348
base: master
Are you sure you want to change the base?
Changes from 20 commits
3adbb37
34fb44e
210b670
c436add
a10be37
71ded04
757b086
557f851
2e7e908
3f1c621
ceccc5c
f0b81a6
67013e7
3e1fedf
e845da0
6f6eaec
1115ed7
4bfb81d
621ffb6
a31b391
9d25e2f
ca9fe3a
d8816e7
1377e35
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Response } from 'express'; | ||
import { cloneDeep } from 'lodash'; | ||
import { PipRequest } from '../models/request/PipRequest'; | ||
import { SubscriptionService } from '../service/SubscriptionService'; | ||
|
||
const subscriptionService = new SubscriptionService(); | ||
|
||
export default class SubscriptionAddListController { | ||
public async get(req: PipRequest, res: Response): Promise<void> { | ||
const listTypes = await subscriptionService.generateListTypeForCourts( | ||
req.user['userProvenance'], | ||
req.lng, | ||
req.user['userId'] | ||
); | ||
|
||
if (req.query.error === 'true') { | ||
res.render('subscription-add-list', { | ||
...cloneDeep(req.i18n.getDataByLanguage(req.lng)['subscription-add-list']), | ||
listTypes: listTypes, | ||
noSelectionError: true, | ||
}); | ||
} else { | ||
res.render('subscription-add-list', { | ||
...cloneDeep(req.i18n.getDataByLanguage(req.lng)['subscription-add-list']), | ||
listTypes: listTypes, | ||
noSelectionError: false, | ||
}); | ||
} | ||
} | ||
|
||
public async post(req: PipRequest, res: Response): Promise<void> { | ||
const result = await subscriptionService.createListTypeSubscriptionPayload(req.body['list-selections[]']); | ||
|
||
if (Object.values(result).length == 0) { | ||
const listTypes = await subscriptionService.generateListTypeForCourts( | ||
req.user['userProvenance'], | ||
req.lng, | ||
req.user['userId'] | ||
); | ||
|
||
res.render('subscription-add-list', { | ||
...cloneDeep(req.i18n.getDataByLanguage(req.lng)['subscription-add-list']), | ||
listTypes: listTypes, | ||
noSelectionError: true, | ||
}); | ||
} else { | ||
await subscriptionService.handleNewSubscription(req.body, req.user); | ||
res.redirect('subscription-add-list-language'); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { PipRequest } from '../models/request/PipRequest'; | ||
import { Response } from 'express'; | ||
import { cloneDeep } from 'lodash'; | ||
|
||
export default class SubscriptionAddListLanguageController { | ||
public async get(req: PipRequest, res: Response): Promise<void> { | ||
if (req.query.error === 'true') { | ||
res.render('subscription-add-list-language', { | ||
...cloneDeep(req.i18n.getDataByLanguage(req.lng)['subscription-add-list-language']), | ||
noSelectionError: true, | ||
}); | ||
} else { | ||
res.render('subscription-add-list-language', { | ||
...cloneDeep(req.i18n.getDataByLanguage(req.lng)['subscription-add-list-language']), | ||
noSelectionError: false, | ||
}); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"title": "Pa fersiwn o'r rhestr ydych chi am ei derbyn?", | ||
"radio1": "Saesneg", | ||
"radio2": "Cymraeg", | ||
"radio3": "Cymraeg a Saesneg", | ||
"buttonText": "Cadarnhau tanysgrifiadau", | ||
"backButton": "Yn ôl", | ||
"error": { | ||
"noSelection": "Dewiswch fersiwn math o restr i barhau", | ||
"title": "Mae yna broblem" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"title": "Dewis Mathau o Restri", | ||
"descriptionText": "Dewiswch y rhestri y byddwch yn eu cael ar gyfer y llysoedd a’r tribiwnlysoedd yr ydych wedi’u dethol. Ni fydd hyn yn effeithio ar unrhyw achosion penodol yr ydych efallai wedi tanysgrifio iddynt. Hefyd, peidiwch ag anghofio dychwelyd yn rheolaidd i weld mathau newydd o restri wrth i ni ychwanegu mwy.", | ||
"userSelections": "Cyfanswm a ddewiswyd", | ||
"selected": "Wedi’i ddewis", | ||
"backButton": "Yn ôl", | ||
"error": { | ||
"nothingSelected": "Dewiswch fath o restr i barhau", | ||
"title": "Mae yna broblem" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"title": "What version of the list do you want to receive?", | ||
"radio1": "English", | ||
"radio2": "Welsh", | ||
"radio3": "English and Welsh", | ||
"buttonText": "Confirm Subscriptions", | ||
"backButton": "Back", | ||
"error": { | ||
"noSelection": "Please select version of the list type to continue", | ||
"title": "There is a problem" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"title": "Select List Types", | ||
"descriptionText": "Choose the lists you will receive for your selected courts and tribunals. This will not affect any specific cases you may have subscribed to. Also don't forget to come back regularly to see new list types as we add more.", | ||
"userSelections": "Total selected", | ||
"selected": "selected", | ||
"backButton": "Back", | ||
"error": { | ||
"nothingSelected": "Please select a list type to continue", | ||
"title": "There is a problem" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -282,6 +282,17 @@ export default function (app: Application): void { | |
isPermittedMedia, | ||
app.locals.container.cradle.subscriptionManagementController.get | ||
); | ||
app.get('/subscription-add-list', isPermittedMedia, app.locals.container.cradle.subscriptionAddListController.get); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to add new a11y tests for the new routes too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added. |
||
app.post( | ||
'/subscription-add-list', | ||
isPermittedMedia, | ||
app.locals.container.cradle.subscriptionAddListController.post | ||
); | ||
app.get( | ||
'/subscription-add-list-language', | ||
isPermittedMedia, | ||
app.locals.container.cradle.subscriptionAddListLanguageController.get | ||
); | ||
app.get( | ||
'/subscription-configure-list', | ||
isPermittedMedia, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,4 +99,14 @@ export class LocationService { | |
public async deleteLocationById(locationId: number, requester: string): Promise<object> { | ||
return await locationRequest.deleteCourt(locationId, requester); | ||
} | ||
|
||
public async findCourtsJurisdiction(locations): Promise<object> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we change the returned type to Promise<string[]> and not object? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done, thanks, good catch :) |
||
const courtJurisdictions = []; | ||
for (const location of locations) { | ||
const returnedLocation = await this.getLocationById(location['locationId']); | ||
returnedLocation.jurisdiction.forEach(jurisdiction => courtJurisdictions.push(jurisdiction)); | ||
} | ||
|
||
return courtJurisdictions; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
title_court_subscription and buttonText_court_subscription need to be added to the welsh language resource too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added