-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HOFF-737-session-timeout-continue-form
- configure session timeout warning in frontend/themes/gov-uk/client-js/session-timeout-dialog.js - add frontend/template-partials/partials/session-timeout-warning.html - amend frontend/template-partials/partials/page.html to include session timeout warning in pages with forms. - add styling for session timeout warning - add leave form button in dialog box which resets session and goes to exit page informing user info has not been saved. This is for non save and return forms. - create session timeout component exit page customisable and session timeout warning dialog content customisable - add session timeout warning component readme - amend confirmation page so it doesn't show popup - amend pr template name so it is picked up - add tests - update change log
- Loading branch information
1 parent
4a9d0d9
commit 17b17b4
Showing
25 changed files
with
1,196 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Session Timeout Warning Behaviour | ||
|
||
## What this does | ||
Makes the content related to the session timeout warning behaviour customisable. This includes the content in the session timeout warning dialog and on the exit page after the user clicks to exit the form from the session timeout warning dialog. | ||
|
||
The component should be set in the project's hof.settings.json | ||
``` | ||
"behaviours": [ | ||
"hof/components/session-timeout-warning" | ||
] | ||
``` | ||
|
||
It will then pick the default content from hof. | ||
|
||
If you require customised content at a project level, the following variables must be set to false in hof.settings.json | ||
|
||
``` | ||
behaviours: [ | ||
require('../').components.sessionTimeoutWarning | ||
], | ||
sessionTimeoutWarningContent: false, | ||
exitFormContent: false | ||
``` | ||
|
||
You can then set the content in the project's pages.json | ||
|
||
``` | ||
"exit": { | ||
"message": "We have cleared your information to keep it secure. Your information has not been saved." | ||
}, | ||
"session-timeout-warning": { | ||
"dialog-title": "Your application will close soon", | ||
"dialog-text": "If that happens, your progress will not be saved.", | ||
"timeout-continue-button": "Stay on this page", | ||
"dialog-exit-link": "Exit this form" | ||
} | ||
``` | ||
|
||
To customise the exit page's header and title, you can create an exit.json file and set the content: | ||
``` | ||
{ | ||
"header": "You have left this application", | ||
"title": "You have left this application" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
'use strict'; | ||
const config = require('../../config/hof-defaults'); | ||
|
||
module.exports = superclass => class extends superclass { | ||
configure(req, res, next) { | ||
// reset the session if user chooses to exit on session timeout warning | ||
if (req.form.options.route === '/exit') { | ||
req.sessionModel.reset(); | ||
} | ||
return super.configure(req, res, next); | ||
} | ||
|
||
locals(req, res) { | ||
// set the default session dialog message | ||
const superLocals = super.locals(req, res); | ||
if (res.locals.sessionTimeoutWarningContent === true) { | ||
superLocals.dialogTitle = true; | ||
superLocals.dialogText = true; | ||
superLocals.timeoutContinueButton = true; | ||
superLocals.dialogExitLink = true; | ||
} | ||
// set the default content on /exit page | ||
if (req.form.options.route === '/exit' && config.exitFormContent === true) { | ||
superLocals.header = req.translate('exit.header'); | ||
superLocals.title = req.translate('exit.title'); | ||
superLocals.message = req.translate('exit.message'); | ||
return superLocals; | ||
} | ||
return superLocals; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"header": "You have left this form", | ||
"title": "You have left this form", | ||
"message": "We have cleared your information to keep it secure. Your information has not been saved." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
{{<partials-page}} | ||
{{$page-content}} | ||
{{<layout}} | ||
{{$journeyHeader}} | ||
{{#t}}journey.header{{/t}} | ||
{{/journeyHeader}} | ||
|
||
{{$propositionHeader}} | ||
{{> partials-navigation}} | ||
{{/propositionHeader}} | ||
|
||
{{$header}} | ||
{{header}} | ||
{{/header}} | ||
|
||
{{$content}} | ||
{{>partials-confirmation-alert}} | ||
{{#markdown}}what-happens-next{{/markdown}} | ||
{{/page-content}} | ||
{{/partials-page}} | ||
{{/content}} | ||
{{/layout}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{{<layout}} | ||
{{$header}} | ||
{{header}} | ||
{{/header}} | ||
{{$content}} | ||
<h2 class="govuk-heading-m">{{#exitFormContent}}{{message}}{{/exitFormContent}}{{^exitFormContent}}{{#t}}pages.exit.message{{/t}}{{/exitFormContent}}</h2> | ||
<a href="/" class="govuk-button" role="button">{{#t}}buttons.start-again{{/t}}</a> | ||
{{/content}} | ||
{{/layout}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
frontend/template-partials/views/partials/session-timeout-warning.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<div class="govuk-timeout-warning-fallback"> | ||
<p>We will reset your application if you do not complete the page and press continue | ||
in 5 minutes.</p> | ||
<p>We do this to keep your information secure.</p> | ||
</div> | ||
|
||
<dialog id="js-modal-dialog" data-session-timeout="{{sessionTimeOut}}" data-session-timeout-warning="{{sessionTimeOutWarning}}" | ||
data-url-redirect="/session-timeout" class="modal-dialog dialog" role="dialog" | ||
aria-live="polite" aria-labelledby="dialog-title" aria-describedby="at-timer"> | ||
<div class="modal-dialog__inner"> | ||
<h1 id="dialog-title" class="govuk-heading-l"> | ||
{{#dialogTitle}}Your page will time out soon {{/dialogTitle}}{{^dialogTitle}}{{#t}}pages.session-timeout-warning.dialog-title{{/t}}{{/dialogTitle}} | ||
</h1> | ||
<div class="modal-dialog__inner__text govuk-body"> | ||
<div id="timer" class="timer" aria-hidden="true" aria-relevant="additions"></div> | ||
<div id="at-timer" class="at-timer govuk-visually-hidden" role="status"></div> | ||
<p class="dialog-text visually-hidden">{{#dialogText}}If that happens, your progress will not be saved.{{/dialogText}}{{^dialogText}}{{#t}}pages.session-timeout-warning.dialog-text{{/t}}{{/dialogText}}</p> | ||
</div> | ||
<button class="govuk-button dialog-button modal-dialog__inner__button js-dialog-close" id="timeout-continue-button" data-module="govuk-button">{{#timeoutContinueButton}}Stay on this page{{/timeoutContinueButton}}{{^timeoutContinueButton}}{{#t}}pages.session-timeout-warning.timeout-continue-button{{/t}}{{/timeoutContinueButton}}</button> | ||
<a href="/exit" class="govuk-link dialog-exit-link" role="button">{{#dialogExitLink}}Exit this form{{/dialogExitLink}}{{^dialogExitLink}}{{#t}}pages.session-timeout-warning.dialog-exit-link{{/t}}{{/dialogExitLink}}</a> | ||
</div> | ||
</dialog> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.