Remove inventory, delete transactions
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
window.app.directive('inventoryRemove', inventoryRemove);
|
||||
|
||||
function inventoryRemove() {
|
||||
return {
|
||||
scope: { "inventory": "=" },
|
||||
templateUrl: '/inventory/template/inventoryRemove.tmpl.cshtml',
|
||||
controller: controller,
|
||||
controllerAs: 'vm'
|
||||
}
|
||||
}
|
||||
|
||||
controller.$inject = ['$scope', 'inventorySvc'];
|
||||
function controller($scope, inventorySvc) {
|
||||
var vm = this;
|
||||
vm.inventory = $scope.inventory;
|
||||
|
||||
vm.save = save;
|
||||
vm.saving = false;
|
||||
vm.removeForm = {
|
||||
inventoryId: vm.inventory.id,
|
||||
quantity: vm.inventory.quantity,
|
||||
transactionType: vm.inventory.isExpired ? "Expired" : null
|
||||
};
|
||||
|
||||
vm.errorMessages = [];
|
||||
|
||||
function save() {
|
||||
vm.saving = true;
|
||||
inventorySvc.remove(vm.removeForm)
|
||||
.success(function (data) {
|
||||
//Close the modal
|
||||
$scope.$parent.$close();
|
||||
})
|
||||
.error(function (data) {
|
||||
vm.errorMessages = angular.copy(data.errorMessages, vm.errorMessages);
|
||||
})
|
||||
.finally(function () {
|
||||
vm.saving = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user