Files
InventoryTraker-Box/InventoryTraker.Web/js/inventory/InventoryAddDirective.js
T
2016-10-18 11:10:01 -04:00

56 lines
1.0 KiB
JavaScript

(function() {
"use strict";
window.app.directive('inventoryAdd',
function() {
return {
templateUrl: '/inventory/template/inventoryAdd.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
});
controller.$inject = ['$scope', 'inventorySvc'];
function controller($scope, inventorySvc) {
var vm = this;
vm.add = add;
vm.inventory = { };
vm.programNames = [
"Admin",
"Aging",
"CC",
"CCFP",
"CIS",
"CSBG",
"Homemaker",
"HUD",
"Misdemeanor",
"Nutrition",
"Title V",
"Transportation",
"WAP",
"Workforce"
];
vm.saving = false;
vm.statusMessage = "Enter details for the inventory addition below.";
vm.errorMessages = [];
function add() {
vm.statusMessage = null;
vm.saving = true;
inventorySvc.add(vm.inventory)
.success(function () {
//Close the modal
$scope.$close();
})
.error(function(data) {
vm.errorMessages = angular.copy(data.errorMessages, vm.errorMessages);
})
.finally(function() {
vm.saving = false;
});
}
}
})();