Initiate InventoyTypes from a xlxs

Arrival mostly working
This commit is contained in:
2016-08-22 11:03:00 -04:00
parent 7e4d8a6d2a
commit 53ed1b3af9
40 changed files with 798 additions and 208 deletions
@@ -14,18 +14,25 @@
controller.$inject = ['$scope', 'inventorySvc', 'inventoryTypeSvc'];
function controller($scope, inventorySvc, inventoryTypeSvc) {
var vm = this;
vm.add = add;
vm.add = add;
vm.saving = false;
vm.inventory = {};
vm.inventoryTypes = inventoryTypeSvc.inventoryTypes;
vm.errorMessage = null;
vm.quantity = quantity;
function zeroNaN(v) {
return isNaN(v) ? 0 : v;
}
function quantity() {
vm.inventory.quantity =
$scope.palletCount * $scope.casesPerPallet + $scope.caseCount;
return vm.inventory.quantity;
zeroNaN($scope.palletCount)
* zeroNaN($scope.casesPerPallet)
+ zeroNaN($scope.caseCount);
return vm.inventory.quantity > 0 ? vm.inventory.quantity : "";
}
function add() {
@@ -36,14 +43,15 @@
$scope.$close();
})
.error(function(data) {
vm.errorMessage = 'There was a problem adding the inventory: ' + data;
vm.errorMessage =
'There was a problem adding the inventory: ' + data.errorMessage;
})
.finally(function() {
vm.saving = false;
});
}
$scope.$watch('commodity', function (newValue, oldValue) {
$scope.$watch('vm.commodity', function (newValue, oldValue) {
if (newValue)
vm.inventory.inventoryTypeId = newValue.id;
});
@@ -4,9 +4,7 @@
window.app.directive('inventoryDetails', inventoryDetails);
function inventoryDetails() {
return {
scope: {
inventory: '='
},
scope: {"inventories" : "="},
templateUrl: '/inventory/template/inventoryDetails.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
@@ -17,9 +15,9 @@
function controller($scope, $uibModal) {
var vm = this;
vm.inventory = $scope.inventory;
vm.inventories = $scope.inventories;
vm.edit = edit;
function edit() {
$uibModal.open({
template: '<editInventory inventory="inventory" />',
@@ -11,7 +11,8 @@
function add() {
$uibModal.open({
template: '<inventory-add />'
template: '<inventory-add />',
backdrop: 'static'
});
}
}
@@ -42,56 +42,6 @@
if (inventories[i].Id == id) return inventories[i];
}
return null;
}
}
})();
(function () {
window.app.factory('inventoryTypeSvc', inventoryTypeSvc);
inventoryTypeSvc.$inject = ['$http'];
function inventoryTypeSvc($http) {
var inventoryTypes = [];
loadInventoryTypes();
var svc = {
add: add,
update: update,
inventoryTypes: inventoryTypes,
getInventoryType: getInventoryType
};
return svc;
function loadInventoryTypes() {
$http.post('/InventoryType/All')
.success(function (data) {
inventoryTypes.addRange(data);
});
}
function add(inventoryType) {
return $http.post('/InventoryType/Add', inventoryType)
.success(function (inventoryType) {
inventoryTypes.unshift(inventoryType);
});
}
function update(existingInventory, updatedInventory) {
return $http.post('/InventoryType/Update', updatedInventory)
.success(function (inventory) {
angular.extend(existingInventory, inventory);
});
}
function getInventoryType(id) {
for (var i = 0; i < inventoryTypes.length; i++) {
if (inventoryTypes[i].Id == id) return inventoryTypes[i];
}
return null;
}
}
@@ -0,0 +1,48 @@
(function () {
window.app.factory('inventoryTypeSvc', inventoryTypeSvc);
inventoryTypeSvc.$inject = ['$http'];
function inventoryTypeSvc($http) {
var inventoryTypes = [];
loadInventoryTypes();
var svc = {
add: add,
update: update,
inventoryTypes: inventoryTypes,
getInventoryType: getInventoryType
};
return svc;
function loadInventoryTypes() {
$http.post('/InventoryType/All')
.success(function (data) {
inventoryTypes.addRange(data);
});
}
function add(inventoryType) {
return $http.post('/InventoryType/Add', inventoryType)
.success(function (inventoryType) {
inventoryTypes.unshift(inventoryType);
});
}
function update(existingInventory, updatedInventory) {
return $http.post('/InventoryType/Update', updatedInventory)
.success(function (inventory) {
angular.extend(existingInventory, inventory);
});
}
function getInventoryType(id) {
for (var i = 0; i < inventoryTypes.length; i++) {
if (inventoryTypes[i].Id == id) return inventoryTypes[i];
}
return null;
}
}
})();
@@ -30,22 +30,22 @@
<div class="form-group has-feedback" ng-class="vm.getValidationClass()" form-group-validation="Commodity">
<label for="Commodity" class="control-label">Commodity</label>
<input name="Commodity" type="text"
ng-model="commodity"
ng-model="vm.commodity"
required
uib-typeahead="inventoryType as inventoryType.name for inventoryType in vm.inventoryTypes | filter:{name:$viewValue} | limitTo:8"
uib-typeahead=
"inventoryType as inventoryType.name for inventoryType in vm.inventoryTypes
| filter:{name:$viewValue}
| limitTo:8"
typeahead-editable='false'
class="form-control">
<i class="fa fa-search form-control-feedback"></i>
<div class="panel panel-default" ng-show="commodity.id">
<div class="panel-heading">Selected Commodity</div>
<div class="panel panel-default" ng-show="vm.commodity.id">
<div class="panel-body">
<dl class="dl-horizontal">
<dt>Commodity ID</dt>
<dd>{{commodity.id}}</dd>
<dt>Name</dt>
<dd>{{commodity.name}}</dd>
<dd>{{vm.commodity.identifier}}</dd>
<dt>Units per Case</dt>
<dd>{{commodity.unitsPerCase}} / {{commodity.containerType}}</dd>
<dd>{{vm.commodity.unitsPerCase}} / {{vm.commodity.containerType}}</dd>
</dl>
</div>
</div>
@@ -57,28 +57,28 @@
<div class="panel-heading"><label>Quantity</label></div>
<div class="panel-body container-fluid">
<div class="row">
<div class="col-sm-5">Pallets</div>
<div class="col-sm-5"><label for="PalletCount">Pallets</label></div>
<div class="col-sm-3">
<input type="number" class="form-control" ng-model="palletCount" />
<input ng-model="palletCount" name="PalletCount" type="number" class="form-control" />
</div>
</div>
<div class="row">
<div class="col-sm-4 col-sm-offset-1">Cases per Pallet</div>
<div class="col-sm-4 col-sm-offset-1"><label for="CasesPerPallet">Cases per Pallet</label></div>
<div class="col-sm-3">
<input type="number" class="form-control" ng-model="casesPerPallet" />
<input ng-model="casesPerPallet" name="CasesPerPallet" type="number" class="form-control" />
</div>
</div>
<hr />
<div class="row">
<div class="col-sm-5">Individual Cases</div>
<div class="col-sm-5"><label for="CaseCount">Individual Cases</label></div>
<div class="col-sm-3">
<input type="number" class="form-control" ng-model="caseCount" />
<input ng-model="caseCount" name="CaseCount" type="number" class="form-control" />
</div>
</div>
<hr />
<div class="row">
<div class="col-sm-5">Total Units</div>
<div class="col-sm-3">{{vm.quantity()}}</div>
<div class="col-sm-5"><strong>Total Units</strong></div>
<div class="col-sm-3"><strong>{{vm.quantity()}}</strong></div>
</div>
</div>
</div>
@@ -1,12 +1,30 @@
@using InventoryTraker.Web.Helpers
@model InventoryTraker.Web.Models.InventoryViewModel
@{
var inventory = Html.Angular().ModelFor("vm.inventory");
var inventory = Html.Angular().ModelFor("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>
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Units per Case</th>
<th>Case Qty</th>
<th>Unit Qty</th>
<th>Exp Date</th>
<th>Added Date</th>
<th>Memo</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="inventory in vm.inventories" inventory="inventory">
<td><strong>@inventory.BindingFor(x => x.Name)</strong> <a href="" ng-click="vm.edit()"><i class="fa fa-edit"></i></a></td>
<td>@inventory.BindingFor(x => x.UnitsPerCase) / @inventory.BindingFor(x => x.ContainerType)</td>
<td>@inventory.BindingFor(x => x.Quantity)</td>
<td>{{inventory.quantity * inventory.unitsPerCase}}</td>
<td>@inventory.BindingFor(x => x.ExpirationDate, "date:'shortDate'")</td>
<td>@inventory.BindingFor(x => x.AddedDate, "date:'shortDate'")</td>
<td>@inventory.BindingFor(x => x.Memo)</td>
</tr>
</tbody>
</table>