Skip to content

Commit

Permalink
sort the incident page's lists of handles and incident types
Browse files Browse the repository at this point in the history
These currently show up in the order they're returned from the API,
which is effectively random, due to this issue:
#1348

We might as well do client-side sorting even if we also do something
on the server-side too.
  • Loading branch information
srabraham committed Nov 12, 2024
1 parent f26f806 commit 74c2231
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/ims/element/static/ims.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,11 @@ function shortDescribeLocation(location) {
// DataTables rendering
//

function renderSorted(strings) {
const copy = strings.toSorted((a, b) => a.localeCompare(b));
return copy.join(", ")
}

function renderIncidentNumber(incidentNumber, type, incident) {
switch (type) {
case "display":
Expand Down
4 changes: 2 additions & 2 deletions src/ims/element/static/incidents.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ function initDataTables() {
"className": "incident_ranger_handles",
"data": "ranger_handles",
"defaultContent": "",
"render": "[, ]", // Join array with ", "
"render": renderSorted,
"width": "6em",
},
{ // 5
Expand All @@ -226,7 +226,7 @@ function initDataTables() {
"className": "incident_types",
"data": "incident_types",
"defaultContent": "",
"render": "[, ]", // Join array with ", "
"render": renderSorted,
"width": "5em",
},
{ // 7
Expand Down

0 comments on commit 74c2231

Please sign in to comment.