From c809dce86546f3649b4f49a7531fdb48efe5f665 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Mon, 6 Dec 2021 23:56:25 -0700 Subject: [PATCH] Improve UX for map calibration prompt. Close #62, close #63. --- www/assets/js/packages.js | 71 +++++++++++++++++++++++++-------------- www/assets/js/settings.js | 5 +++ www/routes.js | 8 +++++ 3 files changed, 58 insertions(+), 26 deletions(-) diff --git a/www/assets/js/packages.js b/www/assets/js/packages.js index a6427dc..da5a79b 100644 --- a/www/assets/js/packages.js +++ b/www/assets/js/packages.js @@ -220,7 +220,7 @@ function importPackageList(newlist) { function mapCalibrate(item, packagesentry) { // Determine if the delivery location isn't near the map pin - if (userPosition.coords.accuracy < 20 && timeDiff(userPosition.updated) < 10) { + if (getStorage("mapcalibrate") !== "false" && userPosition.coords.accuracy < 20 && timeDiff(userPosition.updated) < 10) { // User location is accurate, check distance var distance = getDistance(packagesentry.coords[0], packagesentry.coords[1], userPosition.coords.latitude, userPosition.coords.longitude); var lat = userPosition.coords.latitude; @@ -262,43 +262,62 @@ function mapCalibrate(item, packagesentry) { }; app.dialog.create({ - title: 'Map Calibration', - text: "Your actual location doesn't match the map location for the " + SETTINGS.itemtypes[item.type].name + " at " + item.address + ". Where are you?", + title: 'Question', + text: "Are you currently at the correct delivery location for the " + SETTINGS.itemtypes[item.type].name + " at " + item.address + "?", buttons: [ { - text: 'Address', + text: "No", close: true }, { - text: 'Mailbox/CBU', - close: true - }, - { - text: 'Parcel Locker', - close: true - }, - { - text: "Other/Cancel", + text: "Yes", close: true } ], - verticalButtons: true, onClick: function (dialog, index) { - switch (index) { - case 0: - fixmap(item, lat, lon, "address", packagesentry); - break; - case 1: - fixmap(item, lat, lon, "mailbox", packagesentry); - break; - case 2: - fixmap(item, lat, lon, "locker", packagesentry); - break; - default: - return; + if (index == 1) { + app.dialog.create({ + title: 'Map Calibration', + text: "Your actual location doesn't match the expected location for the " + SETTINGS.itemtypes[item.type].name + " at " + item.address + ". Where are you?", + buttons: [ + { + text: 'Address', + close: true + }, + { + text: 'Mailbox/CBU', + close: true + }, + { + text: 'Parcel Locker', + close: true + }, + { + text: "Other/Cancel", + close: true + } + ], + verticalButtons: true, + onClick: function (dialog, index) { + switch (index) { + case 0: + fixmap(item, lat, lon, "address", packagesentry); + break; + case 1: + fixmap(item, lat, lon, "mailbox", packagesentry); + break; + case 2: + fixmap(item, lat, lon, "locker", packagesentry); + break; + default: + return; + } + } + }).open(); } } }).open(); + } } } diff --git a/www/assets/js/settings.js b/www/assets/js/settings.js index c6d9eac..e0c9f44 100644 --- a/www/assets/js/settings.js +++ b/www/assets/js/settings.js @@ -138,6 +138,11 @@ $('.item-content[data-setting=alertinterval] .range-slider').on('range:changed', setStorage("alertinterval", val); }); +$('.item-content[data-setting=mapcalibrate] .toggle input').on("change", function () { + var checked = $(this).prop('checked'); + setStorage("mapcalibrate", checked ? "true" : "false"); +}); + $('.item-link[data-setting=mapsource] select').on("change", function () { setStorage("mapsource", $('.item-link[data-setting=mapsource] select').val()); diff --git a/www/routes.js b/www/routes.js index 8fd3520..6d46fd3 100644 --- a/www/routes.js +++ b/www/routes.js @@ -702,6 +702,14 @@ var routes = [ } ] }, + { + setting: "mapcalibrate", + title: "Map Calibration", + text: "Ask where you are when delivering a package if the map is wrong.", + toggle: true, + checked: getStorage("mapcalibrate") !== "false", + onclick: "" + }, { setting: "mapscale", title: "Map Scale Ruler",