Skip to content
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

feat: add response ID to thank you page #1855

Merged
merged 15 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/public/modules/forms/base/componentViews/end-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
<div id="end-page-main-container" class="{{ vm.colorTheme }}-bg">
<div class="row">
<p id="end-page-header">
Form submitted <span id="end-page-timestamp"> {{ vm.timestamp }} </span>
<span id="end-page-responseid">
Response ID: <span id="end-page-id"> {{ vm.responseId }} </span>
</span>
<br />
<span>
Form submitted
<span id="end-page-timestamp"> {{ vm.timestamp }} </span>
</span>
</p>
<h2 id="end-page-title">{{ vm.title }}</h2>
<div class="end-page-follow-up end-page-instructions">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ angular.module('forms').component('endPageComponent', {
authType: '@',
isAdminPreview: '<',
colorTheme: '@',
responseId: '@',
},
controller: ['SpcpSession', '$window', 'moment', endPageController],
controllerAs: 'vm',
Expand Down
8 changes: 8 additions & 0 deletions src/public/modules/forms/base/css/end-page.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@
#end-page-header #end-page-timestamp {
font-weight: bold;
}

#end-page-header #end-page-responseid {
font-size: 12px;
}

#end-page-header #end-page-responseid #end-page-id {
text-transform: lowercase;
}
seaerchin marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
auth-type="{{ form.authType }}"
is-admin-preview="false"
color-theme="{{ form.startPage.colorTheme }}"
response-id="{{ responseId }}"
>
</end-page-component>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ function submitFormDirective(
* Returns a callback for form submission success, which updates UI
* state and Google Analytics.
*/
const handleSubmitSuccess = () => {
const handleSubmitSuccess = (response) => {
scope.responseId = response.submissionId
chowyiyin marked this conversation as resolved.
Show resolved Hide resolved
setFormState(FORM_STATES.SUBMITTED)
GTag.submitFormSuccess(scope.form, startDate, Date.now())
if (shouldTrackPersistentLoginUse()) {
Expand Down
34 changes: 19 additions & 15 deletions src/public/modules/forms/services/submissions.client.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,24 @@ function SubmissionsFactory(
xhr.send(fd)
// On Response
xhr.onreadystatechange = function () {
// 4 DONE The operation is complete.
const OPERATION_DONE = 4
if (xhr.readyState === OPERATION_DONE) {
// waterfall is successful
mantariksh marked this conversation as resolved.
Show resolved Hide resolved
if (xhr.status === HttpStatus.OK) {
deferred.resolve('Submission has finished.')
} else {
let response = {}
try {
response = JSON.parse(xhr.responseText)
// eslint-disable-next-line no-empty
} catch (e) {}
let response = {}
try {
response = JSON.parse(xhr.responseText)
if (xhr.status === HttpStatus.OK) {
deferred.resolve({
message: 'Submission has finished.',
submissionId: response.submissionId,
})
} else {
deferred.reject(`${response.message}`)
chowyiyin marked this conversation as resolved.
Show resolved Hide resolved
}
// eslint-disable-next-line no-empty
chowyiyin marked this conversation as resolved.
Show resolved Hide resolved
} catch (e) {
chowyiyin marked this conversation as resolved.
Show resolved Hide resolved
deferred.reject(
`${
response.message ||
"Please refresh and try again. If this doesn't work, try switching devices or networks."
}`,
"Please refresh and try again. If this doesn't work, try switching devices or networks.",
)
}
}
Expand All @@ -133,8 +134,11 @@ function SubmissionsFactory(
version: body.version,
})
.then(
function () {
deferred.resolve('Submission has finished.')
function (response) {
deferred.resolve({
message: 'Submission has finished.',
submissionId: response.submissionId,
})
},
function (error) {
deferred.reject(
Expand Down