Chalmers.ILL/Scripts/chalmers.ill.js
// Load OrderItem Summary (first row in list)
Load OrderItem Summary (first row in list)
Load OrderItem Summary ( first row in list )
function loadOrderItemSummary(id)
{
    $.getJSON("/umbraco/surface/OrderItemSurface/GetOrderItem?nodeId=" + id, function (json) {
        if (json.NodeId && $("#" + json.NodeId).length > 0) {
            var purchaseLibraries = ['HB', 'ACE'];
            var followUpDate = new Date(parseInt(json.FollowUpDate.toString().match(/Date\(([0-9]*)\)/)[1]));
            $("#" + json.NodeId + " div[data-column='createDate']").text(followUpDate.getFullYear() + "-" + ("00" + (followUpDate.getMonth() + 1)).substr(-2) + "-" + ("00" + followUpDate.getDate()).substr(-2));
            $("#" + json.NodeId + " div[data-column='type']").text((json.Type.toString().toLowerCase().indexOf('inköpsförslag') > -1 ? purchaseLibraries[json.PurchaseLibrary] + ' ' + json.Type : json.Type));
            var delLibDiv = $("#" + json.NodeId + " div[data-column='deliveryLibrary']");
            delLibDiv.text(getSigelFromLibraryName(json.DeliveryLibrary));
            delLibDiv.removeClass("Huvudbiblioteket");
            delLibDiv.removeClass("Arkitekturbiblioteket");
            delLibDiv.removeClass("Lindholmenbiblioteket");
            delLibDiv.addClass(json.DeliveryLibrary);
            var isOpen = $("#" + json.NodeId).hasClass("open");
            var statusClassAttr = $("#" + json.NodeId + " .order-item-status").attr("class");
            var statusClass = "";           
            if (statusClassAttr != null) {
                var match = statusClassAttr.match(/chillin-status-[0-9]{2}/)
                if (match) {
                    statusClass = statusClassAttr.match()[0];
                } else {
                    statusClass = "-1";
                }
            }
            if (!$("#" + json.NodeId).hasClass("open") || statusClass === "") {
                statusClass = "chillin-status-" + json.Status.substring(0, 2);
            }
            if (json.Status.indexOf("01") == 0) {
                $("#" + json.NodeId + " div[data-column='status']").html("<span class=\"order-item-status label label-success status-" + json.Status.substring(0, 2) + " " + statusClass + "\">" + json.StatusString + "</span>");
            }
            else if (json.Status.indexOf("05") == 0 || 
                     json.Status.indexOf("06") == 0 || 
                     json.Status.indexOf("07") == 0 || 
                     json.Status.indexOf("08") == 0 ||
                     json.Status.indexOf("10") == 0 ||
                     json.Status.indexOf("16") == 0) {
                $("#" + json.NodeId + " div[data-column='status']").html("<span class=\"order-item-status label label-info status-" + json.Status.substring(0, 2) + " " + statusClass + "\">" + json.StatusString + "</span>");
            }
            else {
                $("#" + json.NodeId + " div[data-column='status']").html("<span class=\"order-item-status label label-danger status-" + json.Status.substring(0, 2) + " " + statusClass + "\">" + json.StatusString + "</span>");
            }
            $("#" + json.NodeId + " div[data-column='reference']").html(replaceURLWithHTMLLinks(json.Reference.replace(/\n/g, "<br />")));
            if (json.EditedBy != "" && json.EditedByCurrentMember == false) {
                $("#" + json.NodeId).addClass("locked");
            }
            else if (json.EditedBy == "" && $("#" + json.NodeId).hasClass("locked")) {
                $("#" + json.NodeId).removeClass("locked");
            }
            reapplyFiltersAndUpdateCounters();
        }
    });
}
function loadOrderItemSummary ( id ) { $ . getJSON ( "/umbraco/surface/OrderItemSurface/GetOrderItem?nodeId=" + id , function ( json ) { if ( json . NodeId && $ ( "#" + json . NodeId ) . length > 0 ) { var purchaseLibraries = [ 'HB' , 'ACE' ] ; var followUpDate = new Date ( parseInt ( json . FollowUpDate . toString ( ) . match ( / Date\(([0-9]*)\) / ) [ 1 ] ) ) ; $ ( "#" + json . NodeId + " div[data-column='createDate']" ) . text ( followUpDate . getFullYear ( ) + "-" + ( "00" + ( followUpDate . getMonth ( ) + 1 ) ) . substr ( - 2 ) + "-" + ( "00" + followUpDate . getDate ( ) ) . substr ( - 2 ) ) ; $ ( "#" + json . NodeId + " div[data-column='type']" ) . text ( ( json . Type . toString ( ) . toLowerCase ( ) . indexOf ( 'inköpsförslag')  > - ? p rchaseLibraries[j s on.P u rchaseLibrary]  + ' ' + j on.T y pe : j on.T y pe)) ; var delLibDiv = $ ( "#" + json . NodeId + " div[data-column='deliveryLibrary']" ) ; delLibDiv . text ( getSigelFromLibraryName ( json . DeliveryLibrary ) ) ; delLibDiv . removeClass ( "Huvudbiblioteket" ) ; delLibDiv . removeClass ( "Arkitekturbiblioteket" ) ; delLibDiv . removeClass ( "Lindholmenbiblioteket" ) ; delLibDiv . addClass ( json . DeliveryLibrary ) ; var isOpen = $ ( "#" + json . NodeId ) . hasClass ( "open" ) ; var statusClassAttr = $ ( "#" + json . NodeId + " .order-item-status" ) . attr ( "class" ) ; var statusClass = "" ; if ( statusClassAttr != null ) { var match = statusClassAttr . match ( / chillin-status-[0-9]{2} / ) if ( match ) { statusClass = statusClassAttr . match ( ) [ 0 ] ; } else { statusClass = "-1" ; } } if ( ! $ ( "#" + json . NodeId ) . hasClass ( "open" ) || statusClass === "" ) { statusClass = "chillin-status-" + json . Status . substring ( 0 , 2 ) ; } if ( json . Status . indexOf ( "01" ) == 0 ) { $ ( "#" + json . NodeId + " div[data-column='status']" ) . html ( "<span class=\"order-item-status label label-success status-" + json . Status . substring ( 0 , 2 ) + " " + statusClass + "\">" + json . StatusString + "</span>" ) ; } else if ( json . Status . indexOf ( "05" ) == 0 || json . Status . indexOf ( "06" ) == 0 || json . Status . indexOf ( "07" ) == 0 || json . Status . indexOf ( "08" ) == 0 || json . Status . indexOf ( "10" ) == 0 || json . Status . indexOf ( "16" ) == 0 ) { $ ( "#" + json . NodeId + " div[data-column='status']" ) . html ( "<span class=\"order-item-status label label-info status-" + json . Status . substring ( 0 , 2 ) + " " + statusClass + "\">" + json . StatusString + "</span>" ) ; } else { $ ( "#" + json . NodeId + " div[data-column='status']" ) . html ( "<span class=\"order-item-status label label-danger status-" + json . Status . substring ( 0 , 2 ) + " " + statusClass + "\">" + json . StatusString + "</span>" ) ; } $ ( "#" + json . NodeId + " div[data-column='reference']" ) . html ( replaceURLWithHTMLLinks ( json . Reference . replace ( / \n / g , "<br />" ) ) ) ; if ( json . EditedBy != "" && json . EditedByCurrentMember == false ) { $ ( "#" + json . NodeId ) . addClass ( "locked" ) ; } else if ( json . EditedBy == "" && $ ( "#" + json . NodeId ) . hasClass ( "locked" ) ) { $ ( "#" + json . NodeId ) . removeClass ( "locked" ) ; } reapplyFiltersAndUpdateCounters ( ) ; } } ) ; }
Load OrderItem Summary (first row in list)
Load OrderItem Summary ( first row in list )
// Move this somewhere else... // Update follow up date. // TODO: Fix culture sensitive date string creation. // Update type // Update delivery library // TODO: Should solve this in some less hard coded way. // Update status // Reference with links // Mark as locked if being edited by other member // Remove locked mark if noone is editing