Template
Add EDDM size, income, businesses and USPS map link (#13)
## Summary Closes #13. - Mirror Monica: join USPS EDDM GIS stats onto the carrier-route picker and link to the official EDDM map. - GIS miss stays a dash and does not block Find routes; PCM households/cost unchanged.
This commit is contained in:
1 parent
f2eb4b7152
commit
5d6b3a9d7d
6 files changed
+254
-3
No files matched your search
@@ -6,6 +6,27 @@
|
||||
return "$" + v.toFixed(2);
|
||||
}
|
||||
|
||||
function hhSize(n) {
|
||||
if (n === null || n === undefined || n === "") return "—";
|
||||
var v = Number(n);
|
||||
if (Number.isNaN(v)) return "—";
|
||||
return v.toFixed(1);
|
||||
}
|
||||
|
||||
function income(n) {
|
||||
if (n === null || n === undefined || n === "") return "—";
|
||||
var v = Number(n);
|
||||
if (Number.isNaN(v)) return "—";
|
||||
return "$" + Math.round(v).toLocaleString("en-US");
|
||||
}
|
||||
|
||||
function count(n) {
|
||||
if (n === null || n === undefined || n === "") return "—";
|
||||
var v = Number(n);
|
||||
if (Number.isNaN(v)) return "—";
|
||||
return String(v);
|
||||
}
|
||||
|
||||
function initPostcardRoutes(opts) {
|
||||
var form = document.getElementById("campaign-compose");
|
||||
if (!form) return;
|
||||
@@ -18,6 +39,7 @@
|
||||
var tableWrap = document.getElementById("route-table-wrap");
|
||||
var tbody = document.getElementById("route-table-body");
|
||||
var selectedBox = document.getElementById("route-selected-cost");
|
||||
var eddmLink = document.getElementById("eddm-map-link");
|
||||
var quoteUrl = opts.quoteUrl;
|
||||
var csrfToken = opts.csrfToken;
|
||||
var maxRoutes = 2;
|
||||
@@ -173,6 +195,9 @@
|
||||
String(row.code) + "</label></td>" +
|
||||
"<td>" + String(row.text || "") + "</td>" +
|
||||
"<td>" + String(row.total) + "</td>" +
|
||||
"<td>" + hhSize(row.household_size) + "</td>" +
|
||||
"<td>" + income(row.median_income) + "</td>" +
|
||||
"<td>" + count(row.businesses) + "</td>" +
|
||||
"<td>" + money(row.cost) + "</td></tr>";
|
||||
}).join("");
|
||||
tbody.querySelectorAll('input[name="route_code"]').forEach(function (box) {
|
||||
@@ -207,6 +232,9 @@
|
||||
radius: radius
|
||||
}).then(function (data) {
|
||||
renderRoutes(data.routes || []);
|
||||
if (eddmLink && data.eddm_map_url) {
|
||||
eddmLink.href = data.eddm_map_url;
|
||||
}
|
||||
if (!(data.routes || []).length) {
|
||||
setStatus("No carrier routes for that search.", true);
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user