Skip to content

Commit

Permalink
Add requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
the-nathan-smith committed Oct 21, 2020
1 parent 0775ef1 commit 82b0298
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 29 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,13 @@ The latest javascript file can be found in github releases https://github.com/nh
...

<!-- where you want the form to appear -->
<div id="nhsuk-user-feedback-form" data-form-endpoint="https://example.com/endpoint/" data-enable-text-response="false"></div>
<div id="nhsuk-user-feedback-form" data-form-endpoint="https://example.com/endpoint/"></div>
```

#### Attributes

`data-form-endpoint` - (required) An HTTP data store endpoint to POST data to. Include the trailing slash
`data-enable-text-response` - (optional) If "true", text responses will be enabled. If "false" or left out,
text responses will not be disabled.
`data-enable-text-response` - (optional) Include to enable text responses on the feedback form.

## API

Expand Down
12 changes: 0 additions & 12 deletions local.settings.json

This file was deleted.

11 changes: 4 additions & 7 deletions src/confirmation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,16 @@ export default class ConfirmationScreen extends Screen {
}

render() {
const textResponseLabel = '<p>We do not check feedback every day and cannot respond to comments.</p>';
const blankLabel = '';

let label;
let message;

/* If data-enable-text-response attribute is "false" show a blank label */
if (this.getEnableTextResponse() === false) {
label = blankLabel;
message = '';
} else {
label = textResponseLabel;
message = '<p>We do not check feedback every day and cannot respond to comments.</p>';
}

const optionalHtml = html.replace('{{ label }}', label);
const optionalHtml = html.replace('{{ optionalTextResponseMessage }}', message);

const node = this.updateHtml(optionalHtml);
const header = node.querySelector('.nhsuk-user-feedback-form-header');
Expand Down
2 changes: 1 addition & 1 deletion src/confirmation/template.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="nhsuk-panel nhsuk-u-reading-width">
<h2 class="nhsuk-heading-s nhsuk-user-feedback-form-header">Thank you for your feedback.</h2>
{{ label }}
{{ optionalTextResponseMessage }}
<p>Find out how to <a href="/contact-us/">contact the NHS</a> if you need to speak to someone.</p>
</div>
5 changes: 1 addition & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import PostData from './post-data';
import './nhsuk-feedback-form.css';

function getEnableTextResponse(container) {
if (container.getAttribute('data-enable-text-response') === 'true') {
return true;
}
return false;
return container.hasAttribute('data-enable-text-response');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/example/disabled-text-response.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div class="nhsuk-width-container">
<main class="nhsuk-main-wrapper">
<h1>User feedback form:</h1>
<div id="nhsuk-user-feedback-form" data-form-endpoint="http://localhost:8080/my-endpoint/" data-enable-text-response="false"></div>
<div id="nhsuk-user-feedback-form" data-form-endpoint="http://localhost:8080/my-endpoint/"></div>

<!--
If you have the user-feedback-store running locally and want to test it, the endpoint setting should probably be this:
Expand Down
2 changes: 1 addition & 1 deletion tests/example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div class="nhsuk-width-container">
<main class="nhsuk-main-wrapper">
<h1>User feedback form:</h1>
<div id="nhsuk-user-feedback-form" data-form-endpoint="http://localhost:8080/my-endpoint/" data-enable-text-response="true"></div>
<div id="nhsuk-user-feedback-form" data-form-endpoint="http://localhost:8080/my-endpoint/"></div>

<!--
If you have the user-feedback-store running locally and want to test it, the endpoint setting should probably be this:
Expand Down

0 comments on commit 82b0298

Please sign in to comment.