diff --git a/assets/js/add-another-detail.js b/assets/js/add-another-detail.js new file mode 100644 index 00000000..355e8e44 --- /dev/null +++ b/assets/js/add-another-detail.js @@ -0,0 +1 @@ +new AddAnother($('.add-another-body-worn-camera'), '.remove-button-container') diff --git a/assets/js/add-another-evidence.js b/assets/js/add-another-evidence.js index 7723d5e8..013ffe04 100644 --- a/assets/js/add-another-evidence.js +++ b/assets/js/add-another-evidence.js @@ -1,2 +1 @@ new AddAnother($('.add-another-evidence'), '.remove-button-container') -new AddAnother($('.add-another-input'), '.remove-button-container') diff --git a/integration-tests/pages/createReport/useOfForceDetailsPage.js b/integration-tests/pages/createReport/useOfForceDetailsPage.js index 8e12ce99..d271b8d7 100644 --- a/integration-tests/pages/createReport/useOfForceDetailsPage.js +++ b/integration-tests/pages/createReport/useOfForceDetailsPage.js @@ -7,8 +7,9 @@ const useOfForceDetailsPage = () => bodyWornCamera: () => cy.get('[name="bodyWornCamera"]'), bodyWornCameraNumber: index => cy.get(`[name="bodyWornCameraNumbers[${index}][cameraNum]"]`), - addAnotherBodyWornCamera: () => cy.get('[data-qa-add-another-input = true]').click(), - removeBodyWornCamera: index => cy.get('.add-another-input .add-another__remove-button').eq(index).click(), + addAnotherBodyWornCamera: () => cy.get('[dataqa=add-another-body-worn-camera]').click(), + removeBodyWornCamera: index => + cy.get('.add-another-body-worn-camera .add-another__remove-button').eq(index).click(), personalProtectionTechniques: () => cy.get('[name="personalProtectionTechniques"]'), batonDrawn: () => cy.get('[name="batonDrawn"]'), diff --git a/server/config/forms/useOfForceDetailsForm.js b/server/config/forms/useOfForceDetailsForm.js index d3d11617..c89044c5 100644 --- a/server/config/forms/useOfForceDetailsForm.js +++ b/server/config/forms/useOfForceDetailsForm.js @@ -19,8 +19,7 @@ const completeSchema = joi.object({ bodyWornCamera: requiredOneOfMsg( 'YES', - 'NO', - 'NOT_KNOWN' + 'NO' )('Select yes if any part of the incident was captured on a body-worn camera').alter(optionalForPartialValidation), bodyWornCameraNumbers: joi diff --git a/server/views/formPages/incident/useOfForceDetails.html b/server/views/formPages/incident/useOfForceDetails.html index 1d103f7c..cef31ec0 100644 --- a/server/views/formPages/incident/useOfForceDetails.html +++ b/server/views/formPages/incident/useOfForceDetails.html @@ -32,13 +32,13 @@

{{ pageTitle }}

})}} - {{ incidentMacro.radioWithMultipleNestedTextBox({ + {{ incidentMacro.radiosWithAddAnotherTextBox({ primaryQuestion:{ text: "Was any part of the incident captured on a body-worn camera?", name: "bodyWornCamera", value: data.bodyWornCamera, errorMessage: errors | findError('bodyWornCamera'), - includeNotKnown: false + questionSubject: 'body-worn-camera' }, followUpQuestion:{ name: "bodyWornCameraNumbers", @@ -184,4 +184,5 @@

{{ pageTitle }}

{% block script %} + {% endblock %} \ No newline at end of file diff --git a/server/views/formPages/incidentMacros.njk b/server/views/formPages/incidentMacros.njk index 518dfd9b..6fad99bb 100644 --- a/server/views/formPages/incidentMacros.njk +++ b/server/views/formPages/incidentMacros.njk @@ -51,94 +51,6 @@ {% endmacro %} - -{% macro radioWithMultipleNestedTextBox(question) %} - - {% if question.primaryQuestion.errorMessage %} - {% set govukFormGroupErrorOuter = 'govuk-form-group--error' %} - {% set primaryErrorMessageText = question.primaryQuestion.errorMessage.text %} - {% endif %} - -
-
- - {{question.primaryQuestion.text}} - - - Error: - {{ primaryErrorMessageText}} - - -
-
-
- - -
- -
- - -
- {% for item in question.followUpQuestion.value %} - - {{ addAnother( - question.followUpQuestion.otherIds, - question.followUpQuestion.name, - question.followUpQuestion.errorMessage, - index = loop.index0, - value = item[question.followUpQuestion.otherIds[0]], - showRemove = loop.length != 1) - }} - {% else %} - {{ addAnother( - question.followUpQuestion.otherIds, - question.followUpQuestion.name, - question.followUpQuestion.errorMessage, - index = 0, - value = null, - showRemove = false) }} - {% endfor %} - -
- {{ - govukButton({ - text: 'Add another', - classes: 'govuk-button--secondary add-another__add-button govuk-!-margin-bottom-4', - attributes: { 'data-qa-add-another-input': true } - }) - }} -
-
- -
- - -
- - -
- {% if question.primaryQuestion.includeNotKnown %} -
- - -
- {% endif %} -
-
- -
-
-{% endmacro %} - {% macro addAnother(otherIds, name, errors, index, value, showRemove) %} {% call govukFieldset({ classes: 'add-another__item' }) %}
@@ -170,6 +82,80 @@ {% endcall %} {% endmacro%} +{% macro radiosWithAddAnotherTextBox(question) %} + + {% if question.primaryQuestion.errorMessage %} + {% set govukFormGroupErrorOuter = 'govuk-form-group--error' %} + {% set primaryErrorMessageText = question.primaryQuestion.errorMessage.text %} + {% endif %} + +
+
+ + {{question.primaryQuestion.text}} + + + Error: + {{ primaryErrorMessageText}} + + +
+
+ + +
+
+ + +
+
+
+ {% set dataqa = ["add-another-", question.primaryQuestion.questionSubject ] | join %} + + {% for item in question.followUpQuestion.value %} + + {{ addAnother( + question.followUpQuestion.otherIds, + question.followUpQuestion.name, + question.followUpQuestion.errorMessage, + index = loop.index0, + value = item[question.followUpQuestion.otherIds[0]], + showRemove = loop.length != 1) + }} + {% else %} + {{ addAnother( + question.followUpQuestion.otherIds, + question.followUpQuestion.name, + question.followUpQuestion.errorMessage, + index = 0, + value = null, + showRemove = false) }} + {% endfor %} + +
+ {{ + govukButton({ + text: 'Add another', + classes: 'govuk-button--secondary add-another__add-button govuk-!-margin-bottom-4', + attributes: {dataqa: dataqa} + }) + }} +
+
+
+
+
+
+{% endmacro %} + {% macro radiosWithNestedRadios(question) %} {% set radio_button_orientation = 'govuk-radios--inline' if question.orientation === 'inline' else 'govuk-radios'%}