Inventory Type editing

This commit is contained in:
2016-08-31 10:30:27 -04:00
parent 016f031664
commit c86d7fb1ed
26 changed files with 358 additions and 67 deletions
@@ -31,7 +31,7 @@
$scope.$parent.$close();
})
.error(function(data) {
vm.errorMessage = 'There was a problem saving changes to the inventory: ' + data;
vm.errorMessage = 'There was a problem saving changes to the inventory: ' + data.errorMessage;
})
.finally(function() {
vm.saving = false;
@@ -9,7 +9,7 @@
<fieldset ng-disabled="vm.saving">
<div class="modal-header">
<h3 class="modal-title">Inventory Arrival</h3>
<h3 class="modal-title"><i class="fa fa-cubes"></i> Inventory Arrival</h3>
</div>
<div class="modal-body">
@@ -17,8 +17,8 @@
</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>
<tr ng-repeat="inventory in vm.inventories">
<td><a href="" ng-click="vm.edit()"><i class="fa fa-edit"></i></a> @inventory.BindingFor(x => x.Name) </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>
@@ -9,7 +9,7 @@
<fieldset ng-disabled="vm.saving">
<div class="modal-header">
<h3 class="modal-title">Inventory Distribution</h3>
<h3 class="modal-title"><i class="fa fa-cubes"></i> Inventory Distribution</h3>
</div>
<div class="modal-body">
@@ -6,7 +6,7 @@
<fieldset ng-disabled="vm.saving">
<div class="modal-header">
<h3 class="modal-title">Edit Inventory</h3>
<h3 class="modal-title"><i class="fa fa-cubes"></i> Edit Inventory</h3>
</div>
<div class="modal-body">
@@ -0,0 +1,41 @@
(function() {
"use strict";
window.app.directive('inventoryTypeAdd', inventoryTypeAdd);
function inventoryTypeAdd() {
return {
templateUrl: '/inventoryType/template/inventoryTypeAdd.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
controller.$inject = ['$scope', 'inventoryTypeSvc'];
function controller($scope, inventoryTypeSvc) {
var vm = this;
vm.add = add;
vm.saving = false;
vm.inventoryType = {};
vm.errorMessage = null;
function add() {
vm.saving = true;
inventoryTypeSvc.add(vm.inventoryType)
.success(function () {
//Close the modal
$scope.$close();
})
.error(function(data) {
vm.errorMessage =
'There was a problem adding the commodity type: ' + data.errorMessage;
})
.finally(function() {
vm.saving = false;
});
}
}
})();
@@ -0,0 +1,28 @@
(function() {
'use strict';
window.app.controller('InventoryTypeController', InventoryTypeController);
InventoryTypeController.$inject = ['$uibModal', 'inventoryTypeSvc'];
function InventoryTypeController($uibModal, inventoryTypeSvc) {
var vm = this;
vm.add = add;
vm.edit = edit;
vm.inventoryTypes = inventoryTypeSvc.inventoryTypes;
function add() {
$uibModal.open({
template: '<inventory-type-add />',
backdrop: 'static'
});
}
function edit() {
$uibModal.open({
template: '<inventory-type-edit />',
backdrop: 'static'
});
}
}
})();
@@ -0,0 +1,42 @@
(function() {
"use strict";
window.app.directive('editInventoryType', editInventory);
function editInventory() {
return {
scope: {
inventoryType: "="
},
templateUrl: '/inventoryType/template/inventoryTypeEdit.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
controller.$inject = ['$scope', 'inventoryTypeSvc'];
function controller($scope, inventoryTypeSvc) {
var vm = this;
vm.inventoryType = angular.copy($scope.inventoryType);
vm.save = save;
vm.saving = false;
vm.inventoryTypeSvc = inventoryTypeSvc;
vm.errorMessage = null;
function save() {
vm.saving = true;
inventoryTypeSvc.update($scope.inventoryType, vm.inventoryType)
.success(function () {
//Close the modal
$scope.$parent.$close();
})
.error(function(data) {
vm.errorMessage = 'There was a problem saving changes to the commodity type: ' + data.errorMessage;
})
.finally(function() {
vm.saving = false;
});
}
}
})();
@@ -0,0 +1,28 @@
(function() {
'use strict';
window.app.directive('inventoryTypeList', inventoryTypeList);
function inventoryTypeList() {
return {
scope: { "inventoryTypes": "=" },
templateUrl: '/inventoryType/template/inventoryTypeList.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
controller.$inject = ['$scope', '$uibModal'];
function controller($scope, $uibModal) {
var vm = this;
vm.inventoryTypes = $scope.inventoryTypes;
vm.edit = edit;
function edit(inventoryType) {
$uibModal.open({
template: '<edit-inventory-type inventory-type="inventoryType" />',
scope: angular.extend($scope.$new(true), { inventoryType: inventoryType })
});
}
}
})();
@@ -10,8 +10,7 @@
var svc = {
add: add,
update: update,
inventoryTypes: inventoryTypes,
getInventoryType: getInventoryType
inventoryTypes: inventoryTypes
};
return svc;
@@ -30,19 +29,11 @@
});
}
function update(existingInventory, updatedInventory) {
return $http.post('/InventoryType/Update', updatedInventory)
.success(function (inventory) {
angular.extend(existingInventory, inventory);
function update(existingInventoryType, updatedInventoryType) {
return $http.post('/InventoryType/Update', updatedInventoryType)
.success(function (inventoryType) {
angular.extend(existingInventoryType, inventoryType);
});
}
function getInventoryType(id) {
for (var i = 0; i < inventoryTypes.length; i++) {
if (inventoryTypes[i].Id == id) return inventoryTypes[i];
}
return null;
}
}
})();
@@ -0,0 +1,34 @@
@using InventoryTraker.Web.Helpers
@model InventoryTraker.Web.Models.InventoryTypeViewModel
@{
var inventoryType = Html.Angular().ModelFor("vm.inventoryType");
}
<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"><i class="fa fa-cube"></i> Add Commodity Type</h3>
</div>
<div class="modal-body">
<div class="alert alert-info" ng-hide="vm.errorMessage != null">
Enter details for the commodity type below.
</div>
<div class="alert alert-danger" ng-show="vm.errorMessage != null">
{{vm.errorMessage}}
</div>
@Html.Angular().FormForModel("vm.inventoryType")
</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,31 @@
@using InventoryTraker.Web.Helpers
@model InventoryTraker.Web.Models.InventoryTypeViewModel
<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"><i class="fa fa-cube"></i> Edit Commodity Type</h3>
</div>
<div class="modal-body">
<div class="alert alert-info" ng-hide="vm.errorMessage != null">
Make changes to the commodity type below.
</div>
<div class="alert alert-danger" ng-show="vm.errorMessage != null">
{{vm.errorMessage}}
</div>
@Html.Angular().FormForModel("vm.inventoryType")
</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>
@@ -0,0 +1,25 @@
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Units per Case</th>
<th>Container Type</th>
<th>Weight Per Case</th>
<th>Price Per Case</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="inventoryType in vm.inventoryTypes | orderBy:'name'">
<td>
<a href="" ng-click="vm.edit(inventoryType)"><i class="fa fa-edit"></i></a>
{{inventoryType.identifier}}
</td>
<td>{{inventoryType.name}}</td>
<td>{{inventoryType.unitsPerCase}}</td>
<td>{{inventoryType.containerType}}</td>
<td>{{inventoryType.weightPerCase}} lbs</td>
<td>{{inventoryType.pricePerCase | currency}}</td>
</tr>
</tbody>
</table>
@@ -30,7 +30,8 @@
'\r{{row.entity.unitsPerCase}} / {{row.entity.containerType}}' +
'\rExp Date: {{row.entity.expirationDate | date:shortDate}}' +
'\rAdd Date: {{row.entity.addedDate | date:shortDate}}">' +
'<a href="#">{{row.entity.name}}</a></div>'
'<a href="" ng-click="vm.edit()"><i class="fa fa-edit"></i></a> ' +
'{{row.entity.name}}</div>'
},
{ field: 'memo', cellTooltip: true },
{ field: 'transactionDate', name: 'Transaction Date', cellFilter: "date:MM/dd/yyyy", width: "15%" },
@@ -61,19 +62,12 @@
var updateData = function () {
transactionSvc
.getTransactions(paginationOptions.pageNumber, paginationOptions.pageSize)
.then(function(data) {
.success(function(data) {
vm.gridOptions.totalItems = data.totalItems;
vm.gridOptions.data = data.transactions;
});
};
updateData();
function del() {
$uibModal.open({
template: '<inventory-distribute />',
backdrop: 'static'
});
}
}
})();
@@ -14,10 +14,10 @@
function getTransactions(pageNumber, pageSize) {
var url = '/Transaction/GetTransactions';
return $http.post(url, {pageNumber: pageNumber, pageSize: pageSize})
.then(function(data) {
return data.data;
});
return $http.post(url, { pageNumber: pageNumber, pageSize: pageSize });
//.success(function(data) {
// return data.data;
//});
}
function update(existingTransaction, updatedTransaction) {