38 lines
778 B
JavaScript
38 lines
778 B
JavaScript
(function() {
|
|
"use strict";
|
|
|
|
window.app.directive('inventoryAdd', inventoryAdd);
|
|
|
|
function inventoryAdd() {
|
|
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.saving = false;
|
|
vm.inventory = {};
|
|
vm.errorMessage = null;
|
|
|
|
function add() {
|
|
vm.saving = true;
|
|
inventorySvc.add(vm.inventory)
|
|
.success(function () {
|
|
//Close the modal
|
|
$scope.$close();
|
|
})
|
|
.error(function(data) {
|
|
vm.errorMessage = 'There was a problem adding the inventory: ' + data;
|
|
})
|
|
.finally(function() {
|
|
vm.saving = false;
|
|
});
|
|
}
|
|
}
|
|
})(); |