aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.cypress/cypress/integration/around_filters.js12
-rw-r--r--CHANGELOG.md1
-rw-r--r--web/js/map-OpenLayers.js26
3 files changed, 30 insertions, 9 deletions
diff --git a/.cypress/cypress/integration/around_filters.js b/.cypress/cypress/integration/around_filters.js
index 18a086e29..3facf9e8c 100644
--- a/.cypress/cypress/integration/around_filters.js
+++ b/.cypress/cypress/integration/around_filters.js
@@ -27,6 +27,12 @@ describe('Around page filtering and push state', function() {
cy.should('not.contain', 'Street light not working');
cy.url().should('not.include', 'fixed');
cy.get('#status_2').should('not.be.checked');
+ cy.go('forward');
+ cy.wait('@update-results');
+ cy.contains('1 to 6 of 6');
+ cy.contains('Street light not working');
+ cy.url().should('include', 'status=closed%2Cfixed');
+ cy.get('#status_2').should('be.checked');
});
it('allows me to filter by report category', function() {
@@ -47,6 +53,12 @@ describe('Around page filtering and push state', function() {
cy.contains('1 to 4 of 4');
cy.contains('Loose drain cover');
cy.should('not.contain', 'Large pothole');
+ cy.go('back');
+ cy.go('back');
+ cy.wait('@update-results');
+ cy.url().should('include', 'filter_category=Potholes');
+ cy.contains('1 to 4 of 4');
+ cy.contains('Large pothole');
});
it('allows me to sort', function() {
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 642facde6..53a9752c0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,7 @@
- Do not scan through all problems to show /_dev pages.
- Say “Set password”, not Change, if no password set.
- Do not lose from_body field when edited by non-superuser admin.
+ - Fix history API bug with category/state selection.
- Development improvements:
- Cobrand hook for disabling updates on individual problems.
- Cobrand hook for disallowing title moderation. #2228
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js
index efa457928..30223d21d 100644
--- a/web/js/map-OpenLayers.js
+++ b/web/js/map-OpenLayers.js
@@ -412,17 +412,25 @@ $.extend(fixmystreet.utils, {
}
function replace_query_parameter(qs, id, key) {
- var value = $('#' + id).val();
- if ( $('#' + id).prop('type') == 'checkbox' ) {
- value = $('#' + id).prop('checked') ? '1' : '';
- } else if (value) {
- value = (typeof value === 'string') ? value : fixmystreet.utils.array_to_csv_line(value);
+ var value,
+ $el = $('#' + id);
+ if (!$el[0]) {
+ return;
}
-
- if (value) {
- qs[key] = value;
+ if ( $el[0].type === 'checkbox' ) {
+ value = $el[0].checked ? '1' : '';
+ if (value) {
+ qs[key] = value;
+ } else {
+ delete qs[key];
+ }
} else {
- delete qs[key];
+ value = $el.val();
+ if (value) {
+ qs[key] = (typeof value === 'string') ? value : fixmystreet.utils.array_to_csv_line(value);
+ } else {
+ delete qs[key];
+ }
}
return value;
}