diff options
-rw-r--r-- | .cypress/cypress/integration/category_tests.js | 4 | ||||
-rw-r--r-- | web/cobrands/fixmystreet/fixmystreet.js | 11 |
2 files changed, 13 insertions, 2 deletions
diff --git a/.cypress/cypress/integration/category_tests.js b/.cypress/cypress/integration/category_tests.js index 5135ef842..a40ec3fcd 100644 --- a/.cypress/cypress/integration/category_tests.js +++ b/.cypress/cypress/integration/category_tests.js @@ -13,7 +13,7 @@ describe('Basic categories', function() { cy.get('#map_box').click(210, 200); cy.wait('@report-ajax'); cy.get('[name=category]').should('not.be.visible'); - var categories = ['-- Pick a category --', 'Graffiti', 'Potholes', 'Street lighting', 'Other', 'Bins' ]; + var categories = ['-- Pick a category --', 'Bins', 'Graffiti', 'Potholes', 'Street lighting', 'Other' ]; cy.get('select:eq(3) option').each(function (obj, i) { expect(obj[0].value).to.equal(categories[i]); }); @@ -29,7 +29,7 @@ describe('Basic categories', function() { cy.route('/report/new/ajax*').as('report-ajax'); cy.visit('/report/new?latitude=51.496194&longitude=-2.603482'); cy.get('[name=category]').should('not.be.visible'); - var categories = ['-- Pick a category --', 'Graffiti', 'Potholes', 'Street lighting', 'Other', 'Bins' ]; + var categories = ['-- Pick a category --', 'Bins', 'Graffiti', 'Potholes', 'Street lighting', 'Other' ]; cy.get('select:eq(1) option').each(function (obj, i) { expect(obj[0].value).to.equal(categories[i]); }); diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js index af69a536e..97d53dd01 100644 --- a/web/cobrands/fixmystreet/fixmystreet.js +++ b/web/cobrands/fixmystreet/fixmystreet.js @@ -504,6 +504,17 @@ $.extend(fixmystreet.set_up, { add_option(this); } }); + // Sort elements in place, but leave the first 'pick a category' option alone + $group_select.find("option").slice(1).sort(function(a, b) { + // 'Other' should always be at the end. + if (a.label === 'Other') { + return 1; + } + if (b.label === 'Other') { + return -1; + } + return a.label > b.label ? 1 : -1; + }).appendTo($group_select); $group_select.change(); }, |