Box modifications
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
(function() {
|
||||
window.app.factory("inventorySvc",
|
||||
[
|
||||
"$http", "$filter",
|
||||
function($http, $filter) {
|
||||
"$http", "$filter", 'Upload',
|
||||
function($http, $filter, Upload) {
|
||||
var inventories = [];
|
||||
|
||||
loadInventories();
|
||||
@@ -15,8 +15,10 @@
|
||||
inventories: inventories,
|
||||
get: get,
|
||||
refresh: refresh,
|
||||
find: find,
|
||||
exportInventory: exportInventory
|
||||
load: load,
|
||||
exportInventory: exportInventory,
|
||||
isShredReady: isShredReady,
|
||||
importFile: importFile
|
||||
};
|
||||
|
||||
return svc;
|
||||
@@ -73,15 +75,34 @@
|
||||
function refresh(id) {
|
||||
var existingInventory = get(id);
|
||||
if (existingInventory) {
|
||||
find(id)
|
||||
load(id)
|
||||
.success(function(inventory) {
|
||||
angular.copy(inventory, existingInventory);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function find(id) {
|
||||
return $http.post("/Inventory/Find", { id: id });
|
||||
function load(id) {
|
||||
return $http.post("/Inventory/Find", { id: id })
|
||||
.success(function (inventory) {
|
||||
var existingInventory = get(id);
|
||||
if (existingInventory != null)
|
||||
angular.copy(inventory, existingInventory);
|
||||
else
|
||||
inventories.unshift(inventory);
|
||||
});
|
||||
}
|
||||
|
||||
function importFile(file) {
|
||||
return Upload.upload({
|
||||
url: "/api/Import",
|
||||
method: 'POST',
|
||||
data: { file: file}
|
||||
});
|
||||
}
|
||||
|
||||
function isShredReady(inventory) {
|
||||
return new Date(inventory.shredReadyDate) <= new Date();
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user