forked from Netsyms/PackageHelper
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
3.3 KiB
JavaScript
91 lines
3.3 KiB
JavaScript
/*
|
|
* To change this license header, choose License Headers in Project Properties.
|
|
* To change this template file, choose Tools | Templates
|
|
* and open the template in the editor.
|
|
*/
|
|
|
|
$(".view-main").on("click", "#addresslist .package-list-item .item-content", function () {
|
|
var pid = $(this).data("packageid");
|
|
if (typeof packages[pid].delivered == "undefined" || packages[pid].delivered == false) {
|
|
packages[pid].delivered = true;
|
|
localStorage.setItem("packages", JSON.stringify(packages));
|
|
loadPackageList();
|
|
} else {
|
|
app.dialog.confirm(
|
|
packages[pid].address,
|
|
"Mark Undelivered",
|
|
function () {
|
|
// undeliver
|
|
packages[pid].delivered = false;
|
|
localStorage.setItem("packages", JSON.stringify(packages));
|
|
loadPackageList();
|
|
},
|
|
function () {
|
|
// cancel
|
|
}
|
|
);
|
|
}
|
|
});
|
|
|
|
$(".view-main").on("mousedown", "#addresslist .package-list-item .item-content", function (e) {
|
|
if (e.button == 2) {
|
|
confirmDeletePackage($(this).data("packageid"));
|
|
}
|
|
});
|
|
|
|
$(".view-main").on("swipeout:delete", "#addresslist .package-list-item", function () {
|
|
console.log("Deleting package", $(this).data("packageid"));
|
|
deletePackage($(this).data("packageid"));
|
|
});
|
|
|
|
function loadPackageList() {
|
|
$("#addresslist").html("");
|
|
|
|
for (var i = 0; i < packages.length; i++) {
|
|
var icon = "fas fa-box-open";
|
|
var classes = "";
|
|
if (packages[i].delivered == true) {
|
|
icon = "fas fa-check";
|
|
classes = "text-color-green";
|
|
}
|
|
$("#addresslist").append(
|
|
'<li class="swipeout package-list-item" data-packageid="' + i + '">'
|
|
+ '<div class="item-content swipeout-content ' + classes + '" data-packageid="' + i + '" data-latitude="' + packages[i].coords[0] + '" data-longitude="' + packages[i].coords[1] + '">'
|
|
+ ' <div class="item-media">'
|
|
+ ' <i class="icon ' + icon + '"></i>'
|
|
+ ' </div>'
|
|
+ ' <div class="item-inner">'
|
|
+ ' <div class="item-title">'
|
|
+ ' ' + packages[i].address
|
|
+ ' </div>'
|
|
+ ' <div class="item-footer">'
|
|
+ ' <span class="distance">... m</span>'
|
|
+ ' </div>'
|
|
+ ' </div>'
|
|
+ '</div>'
|
|
+ '<div class="swipeout-actions-right">'
|
|
+ ' <a href="#" class="swipeout-delete">Delete</a>'
|
|
+ '</div>'
|
|
+ '</li>'
|
|
);
|
|
}
|
|
}
|
|
|
|
function confirmDeleteAllPackages() {
|
|
app.dialog.confirm(
|
|
"Really delete all packages from list?",
|
|
"Clear Packages",
|
|
function () {
|
|
// clear
|
|
packages = [];
|
|
localStorage.setItem("packages", JSON.stringify(packages));
|
|
loadPackageList();
|
|
if (map != null) {
|
|
map.updatePackageLayer(packages);
|
|
}
|
|
},
|
|
function () {
|
|
// cancel
|
|
}
|
|
);
|
|
} |