Warn user when adding an address noted as vacant/on hold/etc, close #22
This commit is contained in:
parent
af5edd83ec
commit
7f215b850c
@ -11,6 +11,44 @@ if (inStorage("notes")) {
|
|||||||
setStorage("notes", "[]");
|
setStorage("notes", "[]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function findNote(number, street) {
|
||||||
|
for (i in notes) {
|
||||||
|
if (notes[i].number == number && notes[i].street.toUpperCase() == street.toUpperCase()) {
|
||||||
|
return notes[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isDeliverable(number, street) {
|
||||||
|
var note = findNote(number, street);
|
||||||
|
|
||||||
|
var ok = true;
|
||||||
|
var reason = "";
|
||||||
|
|
||||||
|
if (note != null) {
|
||||||
|
for (t in note.toggles) {
|
||||||
|
if (!note.toggles.hasOwnProperty(t)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (tt in SETTINGS.routenotetoggles) {
|
||||||
|
if (SETTINGS.routenotetoggles[tt].id == t) {
|
||||||
|
if (SETTINGS.routenotetoggles[tt].preventsDelivery == true && note.toggles[t] == true) {
|
||||||
|
ok = false;
|
||||||
|
reason = SETTINGS.routenotetoggles[tt].reason;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
ok: ok,
|
||||||
|
reason: reason
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function saveNote(id) {
|
function saveNote(id) {
|
||||||
var exists = false;
|
var exists = false;
|
||||||
var index = -1;
|
var index = -1;
|
||||||
|
@ -376,6 +376,7 @@ function addPackageByAddress(number, street, citystate, type, callback) {
|
|||||||
}, 750);
|
}, 750);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var prelookup = function () {
|
||||||
if (type == "express") {
|
if (type == "express") {
|
||||||
if (getStorage("deadlinealarm_minutes") == null) {
|
if (getStorage("deadlinealarm_minutes") == null) {
|
||||||
setStorage("deadlinealarm_minutes", 20);
|
setStorage("deadlinealarm_minutes", 20);
|
||||||
@ -436,6 +437,24 @@ function addPackageByAddress(number, street, citystate, type, callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var deliverable = isDeliverable(number, street);
|
||||||
|
|
||||||
|
if (deliverable.ok) {
|
||||||
|
prelookup();
|
||||||
|
} else {
|
||||||
|
app.dialog.confirm(
|
||||||
|
"A route note says this address is " + deliverable.reason + ". Add item anyways?",
|
||||||
|
"Confirm",
|
||||||
|
function () {
|
||||||
|
prelookup();
|
||||||
|
},
|
||||||
|
function () {
|
||||||
|
// cancel
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function checkDeadlines() {
|
function checkDeadlines() {
|
||||||
if (getStorage("deadlinealarm_minutes") == null) {
|
if (getStorage("deadlinealarm_minutes") == null) {
|
||||||
setStorage("deadlinealarm_minutes", 20);
|
setStorage("deadlinealarm_minutes", 20);
|
||||||
|
@ -305,15 +305,21 @@ var SETTINGS = {
|
|||||||
routenotetoggles: [
|
routenotetoggles: [
|
||||||
{
|
{
|
||||||
name: "Vacant",
|
name: "Vacant",
|
||||||
id: "vacant"
|
id: "vacant",
|
||||||
|
preventsDelivery: true,
|
||||||
|
reason: "vacant"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Outside delivery radius",
|
name: "Outside delivery radius",
|
||||||
id: "undeliverable"
|
id: "undeliverable",
|
||||||
|
preventsDelivery: true,
|
||||||
|
reason: "too far from the route"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "On hold",
|
name: "On hold",
|
||||||
id: "hold"
|
id: "hold",
|
||||||
|
preventsDelivery: true,
|
||||||
|
reason: "on hold"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
synckeyblacklist: [
|
synckeyblacklist: [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user