Fix bugs
This commit is contained in:
		
							parent
							
								
									825565a9b1
								
							
						
					
					
						commit
						e6b561f944
					
				@ -45,40 +45,46 @@ $("#app").on("click", "#package-info-sheet .package-info-toggle-status", functio
 | 
			
		||||
            openPackageInfoSheet(packages[i], true);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
    } 
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
$("#app").on("click", "#package-info-sheet #package-info-get-directions", function () {
 | 
			
		||||
    window.open($(this).attr("href"), "_system");
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
function openPackageInfoSheet(package, refreshOnly) {
 | 
			
		||||
function openPackageInfoSheet(coordid, refreshOnly) {
 | 
			
		||||
    if (typeof refreshOnly == "undefined") {
 | 
			
		||||
        refreshOnly = false;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    $("#package-info-get-directions").attr("href", "geo:" + package.coords[0] + "," + package.coords[1]);
 | 
			
		||||
    $("#package-info-sheet-inner").html("");
 | 
			
		||||
 | 
			
		||||
    for (var i = 0; i < package.items.length; i++) {
 | 
			
		||||
        $("#package-info-sheet-inner").append(''
 | 
			
		||||
                + '<div class="block margin-top-half">'
 | 
			
		||||
                + '  <div>'
 | 
			
		||||
                + '    <span class="package-info-delivery-status">'
 | 
			
		||||
                + '      ' +  + (package.items[i].delivered ? '<span class="text-color-green"><i class="fas fa-check-circle"></i> Delivered</span>' : '<i class="fas fa-circle"></i> Not delivered')
 | 
			
		||||
                + '    </span>'
 | 
			
		||||
                + '  </div>'
 | 
			
		||||
                + '  <h3>'
 | 
			
		||||
                + '    <span class="package-info-address">' + package.items[i].address + '</span>'
 | 
			
		||||
                + '  </h3>'
 | 
			
		||||
                + '  <div class="button button-fill margin-top" class="package-info-toggle-status" data-id="' + package.items[i].id + '" data-coordid=' + package.id + '>'
 | 
			
		||||
                + '    ' + (package.items[i].delivered ? "Undeliver" : "Deliver")
 | 
			
		||||
                + '  </div>'
 | 
			
		||||
                + '</div>');
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    if (!refreshOnly) {
 | 
			
		||||
        app.sheet.create({el: "#package-info-sheet"}).open();
 | 
			
		||||
    for (var i = 0; i < packages.length; i++) {
 | 
			
		||||
        if (packages[i].id == coordid) {
 | 
			
		||||
            package = packages[i];
 | 
			
		||||
 | 
			
		||||
            $("#package-info-get-directions").attr("href", "geo:" + package.coords[0] + "," + package.coords[1]);
 | 
			
		||||
            $("#package-info-sheet-inner").html("");
 | 
			
		||||
 | 
			
		||||
            for (var i = 0; i < package.items.length; i++) {
 | 
			
		||||
                $("#package-info-sheet-inner").append(''
 | 
			
		||||
                        + '<div class="block margin-top-half">'
 | 
			
		||||
                        + '  <div>'
 | 
			
		||||
                        + '    <span class="package-info-delivery-status">'
 | 
			
		||||
                        + '      ' + +(package.items[i].delivered ? '<span class="text-color-green"><i class="fas fa-check-circle"></i> Delivered</span>' : '<i class="fas fa-circle"></i> Not delivered')
 | 
			
		||||
                        + '    </span>'
 | 
			
		||||
                        + '  </div>'
 | 
			
		||||
                        + '  <h3>'
 | 
			
		||||
                        + '    <span class="package-info-address">' + package.items[i].address + '</span>'
 | 
			
		||||
                        + '  </h3>'
 | 
			
		||||
                        + '  <div class="button button-fill margin-top" class="package-info-toggle-status" data-id="' + package.items[i].id + '" data-coordid=' + package.id + '>'
 | 
			
		||||
                        + '    ' + (package.items[i].delivered ? "Undeliver" : "Deliver")
 | 
			
		||||
                        + '  </div>'
 | 
			
		||||
                        + '</div>');
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (!refreshOnly) {
 | 
			
		||||
                app.sheet.create({el: "#package-info-sheet"}).open();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -78,7 +78,7 @@ function leafletMap() {
 | 
			
		||||
                        icon: icon
 | 
			
		||||
                    })
 | 
			
		||||
                    .on("click", function () {
 | 
			
		||||
                        openPackageInfoSheet(data[i]);
 | 
			
		||||
                        openPackageInfoSheet(data[i].id);
 | 
			
		||||
                    });
 | 
			
		||||
 | 
			
		||||
            map.packagelayer.addLayer(marker);
 | 
			
		||||
 | 
			
		||||
@ -17,7 +17,7 @@ if (localStorage.getItem("packages") != null) {
 | 
			
		||||
 */
 | 
			
		||||
function getUndeliveredCount(address) {
 | 
			
		||||
    var undelivered = 0;
 | 
			
		||||
    for (var i = 0; i < address.items.length; j++) {
 | 
			
		||||
    for (var i = 0; i < address.items.length; i++) {
 | 
			
		||||
        if (!address.items[i].delivered) {
 | 
			
		||||
            undelivered++;
 | 
			
		||||
        }
 | 
			
		||||
@ -28,7 +28,7 @@ function getUndeliveredCount(address) {
 | 
			
		||||
function addPackage(address, latitude, longitude) {
 | 
			
		||||
    var added = false;
 | 
			
		||||
    for (var i = 0; i < packages.length; i++) {
 | 
			
		||||
        if (packages[i].coords == [latitude, longitude] && packages[i].address == address) {
 | 
			
		||||
        if (packages[i].coords[0] == latitude && packages[i].coords[1] == longitude && packages[i].address == address) {
 | 
			
		||||
            packages[i].items.push({
 | 
			
		||||
                address: address,
 | 
			
		||||
                delivered: false,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user