Subversion Repositories SmartDukaan

Rev

Rev 37564 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37564 Rev 37823
Line 1097... Line 1097...
1097
        autoSelect: true,
1097
        autoSelect: true,
1098
        afterSelect: callback
1098
        afterSelect: callback
1099
    });
1099
    });
1100
}
1100
}
1101
 
1101
 
-
 
1102
// getWarehouseId (optional): when given, only suppliers mapped to that warehouse are offered, and none until one is picked.
1102
function getVendorAheadOptions(jqElement, callback) {
1103
function getVendorAheadOptions(jqElement, callback, getWarehouseId) {
1103
    jqElement.typeahead('destroy').typeahead({
1104
    jqElement.typeahead('destroy').typeahead({
1104
        source: function (q, process) {
1105
        source: function (q, process) {
1105
            if (q.length >= 3) {
1106
            if (q.length >= 3) {
-
 
1107
                var data = {query: q};
-
 
1108
                if (getWarehouseId) {
-
 
1109
                    var warehouseId = getWarehouseId();
-
 
1110
                    if (!warehouseId) {
-
 
1111
                        return process([]);
-
 
1112
                    }
-
 
1113
                    data.warehouseId = warehouseId;
-
 
1114
                }
1106
                return $.ajax(context + "/vendors", {
1115
                return $.ajax(context + "/vendors", {
1107
                    global: false,
1116
                    global: false,
1108
                    data: {
1117
                    data: data,
1109
                        query: q
-
 
1110
                    },
-
 
1111
                    headers: {
1118
                    headers: {
1112
                        'IdempotencyKey': IdempotencyKey
1119
                        'IdempotencyKey': IdempotencyKey
1113
                    },
1120
                    },
1114
                    success: function (data) {
1121
                    success: function (data) {
1115
                        //IdempotencyKey = uuidv4();
1122
                        //IdempotencyKey = uuidv4();