This commit is contained in:
2016-08-08 14:47:35 -04:00
commit 0b0cb7c73a
156 changed files with 114318 additions and 0 deletions
@@ -0,0 +1,38 @@
(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;
});
}
}
})();
@@ -0,0 +1,31 @@
(function() {
'use strict';
window.app.directive('inventoryDetails', inventoryDetails);
function inventoryDetails() {
return {
scope: {
inventory: '='
},
templateUrl: '/inventory/template/inventoryDetails.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
controller.$inject = ['$scope', '$uibModal'];
function controller($scope, $uibModal) {
var vm = this;
vm.inventory = $scope.inventory;
vm.edit = edit;
vm.inventory = $scope.inventory;
function edit() {
$uibModal.open({
template: '<editInventory inventory="inventory" />',
scope: angular.extend($scope.$new(true), { inventory: vm.inventory })
});
}
}
})();
@@ -0,0 +1,41 @@
(function() {
"use strict";
window.app.directive('editInventory', editInventory);
function editInventory() {
return {
scope: {
inventory: "="
},
templateUrl: '/inventory/template/inventoryEdit.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
controller.$inject = ['$scope', 'inventorySvc'];
function controller($scope, inventorySvc) {
var vm = this;
vm.save = save;
vm.saving = false;
vm.inventory = angular.copy($scope.inventory);
vm.errorMessage = null;
function save() {
vm.saving = true;
inventorySvc.update($scope.inventory, vm.inventory)
.success(function () {
//Close the modal
$scope.$parent.$close();
})
.error(function(data) {
vm.errorMessage = 'There was a problem saving changes to the inventory: ' + data;
})
.finally(function() {
vm.saving = false;
});
}
}
})();
@@ -0,0 +1,18 @@
(function() {
'use strict';
window.app.controller('InventoryListController', InventoryListController);
InventoryListController.$inject = ['$uibModal', 'inventorySvc'];
function InventoryListController($uibModal, inventorySvc) {
var vm = this;
vm.add = add;
vm.inventories = inventorySvc.inventories;
function add() {
$uibModal.open({
template: '<inventory-add />'
});
}
}
})();
@@ -0,0 +1,48 @@
(function() {
window.app.factory('inventorySvc', inventorySvc);
inventorySvc.$inject = ['$http'];
function inventorySvc($http) {
var inventories = [];
loadInventories();
var svc = {
add: add,
update: update,
inventories: inventories,
getInventory: getInventory
};
return svc;
function loadInventories() {
$http.post('/Inventory/All')
.success(function(data) {
inventories.addRange(data);
});
}
function add(inventory) {
return $http.post('/Inventory/Add', inventory)
.success(function(inventory) {
inventories.unshift(inventory);
});
}
function update(existingInventory, updatedInventory) {
return $http.post('/Inventory/Update', updatedInventory)
.success(function(inventory) {
angular.extend(existingInventory, inventory);
});
}
function getInventory(id) {
for (var i = 0; i < inventories.length; i++) {
if (inventories[i].Id == id) return inventories[i];
}
return null;
}
}
})();
@@ -0,0 +1,36 @@
@using InventoryTraker.Web.Helpers
@model InventoryTraker.Web.Models.InventoryAddForm
@{
var inventory = Html.Angular().ModelFor("vm.inventory");
}
<form novalidate
name="vm.form"
ng-submit="vm.form.$valid && vm.add()">
<fieldset ng-disabled="vm.saving">
<div class="modal-header">
<h3 class="modal-title">Inventory Arrival</h3>
</div>
<div class="modal-body">
<div class="alert alert-info" ng-hide="vm.errorMessage != null">
Enter details for the inventory arrival below.
</div>
<div class="alert alert-danger" ng-show="vm.errorMessage != null">
{{vm.errorMessage}}
</div>
@inventory.FormGroupFor(m => m.ExpirationDate)
@inventory.FormGroupFor(m => m.AddedDate)
@inventory.FormGroupFor(m => m.Memo)
</div>
<div class="modal-footer">
<button class="btn btn-success">Add</button>
<button type="button" class="btn" ng-click="$dismiss()">Cancel</button>
</div>
</fieldset>
</form>
@@ -0,0 +1,12 @@
@using InventoryTraker.Web.Helpers
@model InventoryTraker.Web.Models.InventoryViewModel
@{
var inventory = Html.Angular().ModelFor("vm.inventory");
}
<div class="panel panel-default">
<div class="panel-heading">
@inventory.BindingFor(x => x.Name) <a href="" ng-click="vm.edit()"><i class="fa fa-edit"></i></a>
</div>
Quantity
@inventory.BindingFor(x => x.Quantity)
</div>
@@ -0,0 +1,31 @@
@using InventoryTraker.Web.Helpers
@model InventoryTraker.Web.Models.InventoryAddForm
<form novalidate
name="vm.form"
ng-submit="vm.form.$valid && vm.save()">
<fieldset ng-disabled="vm.saving">
<div class="modal-header">
<h3 class="modal-title">Edit Inventory</h3>
</div>
<div class="modal-body">
<div class="alert alert-info" ng-hide="vm.errorMessage != null">
Make changes to the inventory below.
</div>
<div class="alert alert-danger" ng-show="vm.errorMessage != null">
{{vm.errorMessage}}
</div>
@Html.Angular().FormForModel("vm.inventory")
</div>
<div class="modal-footer">
<button class="btn btn-success">Save</button>
<button type="button" class="btn btn-warning" ng-click="$parent.$dismiss()">Cancel</button>
</div>
</fieldset>
</form>