aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2020-04-01 17:34:44 +0100
committerMatthew Somerville <matthew@mysociety.org>2020-04-01 18:29:11 +0100
commit2b8794c9026fc4ec23d4ff795105ecfcaa759772 (patch)
treefba7e76dd894b64b6061876a98761d7478d63a3d
parente02aa900af86f9323aa390b8e8f6f37aa1c49255 (diff)
[UK] Fix client side HE category submission.
Once a location is fixed, we never want to regenerate the Highways England question, as that can lose the selected category. Store the location regardless of the HE question answer, so any category change, as opposed to a location change, does not do anything. We also do not want to clear category_meta, as that is where the extra data fields appear.
-rw-r--r--.cypress/cypress/integration/highways.js2
-rw-r--r--web/cobrands/highways/assets.js13
2 files changed, 8 insertions, 7 deletions
diff --git a/.cypress/cypress/integration/highways.js b/.cypress/cypress/integration/highways.js
index 7f7214ae8..4c66e074e 100644
--- a/.cypress/cypress/integration/highways.js
+++ b/.cypress/cypress/integration/highways.js
@@ -24,5 +24,7 @@ describe('Highways England tests', function() {
cy.get('#js-councils_text').should('contain', 'Highways England');
cy.get('#single_body_only').should('have.value', 'Highways England');
cy.get('#form_category').should('contain', 'Sign issue');
+ cy.get('#category_group').select('Sign issue');
+ cy.get('#form_category').should('have.value', 'Sign issue');
});
});
diff --git a/web/cobrands/highways/assets.js b/web/cobrands/highways/assets.js
index 2f00834d2..1607bc193 100644
--- a/web/cobrands/highways/assets.js
+++ b/web/cobrands/highways/assets.js
@@ -66,7 +66,6 @@ fixmystreet.assets.add(defaults, {
$('#highways').remove();
if ( !fixmystreet.assets.selectedFeature() ) {
add_highways_warning(feature.attributes.ROA_NUMBER);
- $('#category_meta').empty();
}
},
not_found: function(layer) {
@@ -83,6 +82,11 @@ fixmystreet.assets.add(defaults, {
function regenerate_category(he_flag) {
if (!fixmystreet.reporting_data) return;
+ fixmystreet.body_overrides.location = {
+ latitude: $('#fixmystreet\\.latitude').val(),
+ longitude: $('#fixmystreet\\.longitude').val()
+ };
+
// Restart the category dropdown from the original data (not all of it as
// we keep subcategories the same)
var select = $(fixmystreet.reporting_data.category).filter('select');
@@ -103,7 +107,6 @@ function regenerate_category(he_flag) {
}
function he_selected() {
- fixmystreet.body_overrides.location = null;
fixmystreet.body_overrides.only_send('Highways England');
fixmystreet.body_overrides.allow_send('Highways England');
regenerate_category(true);
@@ -111,14 +114,10 @@ function he_selected() {
}
function non_he_selected() {
- fixmystreet.body_overrides.location = {
- latitude: $('#fixmystreet\\.latitude').val(),
- longitude: $('#fixmystreet\\.longitude').val()
- };
fixmystreet.body_overrides.remove_only_send();
fixmystreet.body_overrides.do_not_send('Highways England');
- $(fixmystreet).trigger('report_new:highways_change');
regenerate_category(false);
+ $(fixmystreet).trigger('report_new:highways_change');
}
function add_highways_warning(road_name) {