Inventory Type editing
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.Linq;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using InventoryTraker.Web.ActionResults;
|
using InventoryTraker.Web.ActionResults;
|
||||||
|
|
||||||
@@ -11,14 +12,22 @@ namespace InventoryTraker.Web.Controllers
|
|||||||
return new BetterJsonResult<T> {Data = model};
|
return new BetterJsonResult<T> {Data = model};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JsonResult PackageModelStateErrors()
|
protected IEnumerable<string> GetModelStateErrorList()
|
||||||
|
{
|
||||||
|
var errorList =
|
||||||
|
from kvp in ModelState
|
||||||
|
where kvp.Value.Errors.Any()
|
||||||
|
let errors = string.Join(", ", kvp.Value.Errors.Select(e => e.ErrorMessage))
|
||||||
|
let msg = kvp.Key + ": " + errors
|
||||||
|
select msg;
|
||||||
|
return errorList;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected JsonResult GetModelStateErrorListJson()
|
||||||
{
|
{
|
||||||
var betterJsonResult = new BetterJsonResult();
|
var betterJsonResult = new BetterJsonResult();
|
||||||
foreach (var err in ModelState.Where(ms => ms.Value.Errors.Any()))
|
foreach (var err in GetModelStateErrorList())
|
||||||
{
|
betterJsonResult.AddError(err);
|
||||||
betterJsonResult.AddError(
|
|
||||||
err.Key + ": " + string.Join(", ", err.Value.Errors.Select(e => e.ErrorMessage)));
|
|
||||||
}
|
|
||||||
return betterJsonResult;
|
return betterJsonResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace InventoryTraker.Web.Controllers
|
|||||||
public JsonResult Add(InventoryAddForm form)
|
public JsonResult Add(InventoryAddForm form)
|
||||||
{
|
{
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return PackageModelStateErrors();
|
return GetModelStateErrorListJson();
|
||||||
|
|
||||||
var inventory = Mapper.Map<Inventory>(form);
|
var inventory = Mapper.Map<Inventory>(form);
|
||||||
inventory.InventoryType = _context.InventoryTypes.Find(form.InventoryTypeId);
|
inventory.InventoryType = _context.InventoryTypes.Find(form.InventoryTypeId);
|
||||||
@@ -71,7 +71,7 @@ namespace InventoryTraker.Web.Controllers
|
|||||||
public JsonResult Distribute(InventoryDistributeForm form)
|
public JsonResult Distribute(InventoryDistributeForm form)
|
||||||
{
|
{
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return PackageModelStateErrors();
|
return GetModelStateErrorListJson();
|
||||||
|
|
||||||
foreach (var quantityForm in form.InventoryQuantities)
|
foreach (var quantityForm in form.InventoryQuantities)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
|
using AutoMapper;
|
||||||
using AutoMapper.QueryableExtensions;
|
using AutoMapper.QueryableExtensions;
|
||||||
|
using InventoryTraker.Web.Core;
|
||||||
using InventoryTraker.Web.Data;
|
using InventoryTraker.Web.Data;
|
||||||
using InventoryTraker.Web.Models;
|
using InventoryTraker.Web.Models;
|
||||||
|
|
||||||
@@ -15,6 +19,11 @@ namespace InventoryTraker.Web.Controllers
|
|||||||
_context = context;
|
_context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ActionResult Index()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
public JsonResult All()
|
public JsonResult All()
|
||||||
{
|
{
|
||||||
var viewModels = _context.InventoryTypes
|
var viewModels = _context.InventoryTypes
|
||||||
@@ -23,5 +32,32 @@ namespace InventoryTraker.Web.Controllers
|
|||||||
|
|
||||||
return BetterJson(viewModels.ToArray());
|
return BetterJson(viewModels.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JsonResult Add(InventoryTypeViewModel form)
|
||||||
|
{
|
||||||
|
if (!ModelState.IsValid)
|
||||||
|
return GetModelStateErrorListJson();
|
||||||
|
|
||||||
|
var inventoryType = Mapper.Map<InventoryType>(form);
|
||||||
|
_context.InventoryTypes.Add(inventoryType);
|
||||||
|
_context.SaveChanges();
|
||||||
|
|
||||||
|
var model = Mapper.Map<InventoryTypeViewModel>(inventoryType);
|
||||||
|
return BetterJson(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsonResult Update(InventoryTypeViewModel form)
|
||||||
|
{
|
||||||
|
if (!ModelState.IsValid)
|
||||||
|
return GetModelStateErrorListJson();
|
||||||
|
|
||||||
|
var inventoryType = _context.InventoryTypes.Find(form.Id);
|
||||||
|
Mapper.Map(form, inventoryType);
|
||||||
|
|
||||||
|
_context.SaveChanges();
|
||||||
|
|
||||||
|
var model = Mapper.Map<InventoryTypeViewModel>(inventoryType);
|
||||||
|
return BetterJson(model);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,10 +224,14 @@
|
|||||||
<Content Include="Global.asax" />
|
<Content Include="Global.asax" />
|
||||||
<Content Include="js\app.js" />
|
<Content Include="js\app.js" />
|
||||||
<Content Include="js\authentication\LoginController.js" />
|
<Content Include="js\authentication\LoginController.js" />
|
||||||
|
<Content Include="js\inventoryType\InventoryTypeAddDirective.js" />
|
||||||
|
<Content Include="js\inventoryType\InventoryTypeListDirective.js" />
|
||||||
|
<Content Include="js\inventoryType\InventoryTypeEditDirective.js" />
|
||||||
|
<Content Include="js\inventoryType\InventoryTypeController.js" />
|
||||||
<Content Include="js\inventory\InventoryAddDirective.js" />
|
<Content Include="js\inventory\InventoryAddDirective.js" />
|
||||||
<Content Include="js\inventory\InventoryDetailsDirective.js" />
|
<Content Include="js\inventory\InventoryDetailsDirective.js" />
|
||||||
<Content Include="js\inventory\InventoryListController.js" />
|
<Content Include="js\inventory\InventoryListController.js" />
|
||||||
<Content Include="js\inventory\inventoryTypeSvc.js" />
|
<Content Include="js\inventoryType\inventoryTypeSvc.js" />
|
||||||
<Content Include="js\inventory\inventorySvc.js" />
|
<Content Include="js\inventory\inventorySvc.js" />
|
||||||
<Content Include="js\inventory\InventoryEditDirective.js" />
|
<Content Include="js\inventory\InventoryEditDirective.js" />
|
||||||
<Content Include="js\inventory\InventoryDistributeDirective.js" />
|
<Content Include="js\inventory\InventoryDistributeDirective.js" />
|
||||||
@@ -270,6 +274,9 @@
|
|||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="js\inventory\templates\inventoryDistribute.tmpl.cshtml" />
|
<Content Include="js\inventory\templates\inventoryDistribute.tmpl.cshtml" />
|
||||||
|
<Content Include="js\inventoryType\templates\inventoryTypeEdit.tmpl.cshtml" />
|
||||||
|
<Content Include="js\inventoryType\templates\inventoryTypeAdd.tmpl.cshtml" />
|
||||||
|
<Content Include="js\inventoryType\templates\inventoryTypeList.tmpl.cshtml" />
|
||||||
<None Include="Properties\PublishProfiles\ETHRA.pubxml" />
|
<None Include="Properties\PublishProfiles\ETHRA.pubxml" />
|
||||||
<None Include="Scripts\jquery-1.9.1.intellisense.js" />
|
<None Include="Scripts\jquery-1.9.1.intellisense.js" />
|
||||||
<Content Include="Scripts\bootstrap.js" />
|
<Content Include="Scripts\bootstrap.js" />
|
||||||
@@ -319,6 +326,7 @@
|
|||||||
<Compile Include="Migrations\Configuration.cs" />
|
<Compile Include="Migrations\Configuration.cs" />
|
||||||
<Compile Include="Models\InventoryDistributeForm.cs" />
|
<Compile Include="Models\InventoryDistributeForm.cs" />
|
||||||
<Compile Include="Models\InventoryAddForm.cs" />
|
<Compile Include="Models\InventoryAddForm.cs" />
|
||||||
|
<Compile Include="Models\InventoryQuantityForm.cs" />
|
||||||
<Compile Include="Models\InventoryTypeViewModel.cs" />
|
<Compile Include="Models\InventoryTypeViewModel.cs" />
|
||||||
<Compile Include="Models\InventoryViewModel.cs" />
|
<Compile Include="Models\InventoryViewModel.cs" />
|
||||||
<Compile Include="Models\LoginForm.cs" />
|
<Compile Include="Models\LoginForm.cs" />
|
||||||
@@ -349,6 +357,7 @@
|
|||||||
<Content Include="Views\Shared\_Navigation.cshtml" />
|
<Content Include="Views\Shared\_Navigation.cshtml" />
|
||||||
<Content Include="Views\_ViewStart.cshtml" />
|
<Content Include="Views\_ViewStart.cshtml" />
|
||||||
<Content Include="Views\Transaction\Index.cshtml" />
|
<Content Include="Views\Transaction\Index.cshtml" />
|
||||||
|
<Content Include="Views\InventoryType\Index.cshtml" />
|
||||||
<None Include="Web.Debug.config">
|
<None Include="Web.Debug.config">
|
||||||
<DependentUpon>Web.config</DependentUpon>
|
<DependentUpon>Web.config</DependentUpon>
|
||||||
</None>
|
</None>
|
||||||
|
|||||||
@@ -4,15 +4,6 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
|
|
||||||
namespace InventoryTraker.Web.Models
|
namespace InventoryTraker.Web.Models
|
||||||
{
|
{
|
||||||
public class InventoryQuantityForm
|
|
||||||
{
|
|
||||||
[Required]
|
|
||||||
public int InventoryId { get; set; }
|
|
||||||
|
|
||||||
[Required, Range(1, int.MaxValue, ErrorMessage = "Quantity must be greater than 0")]
|
|
||||||
public int Quantity { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class InventoryDistributeForm
|
public class InventoryDistributeForm
|
||||||
{
|
{
|
||||||
public IList<InventoryQuantityForm> InventoryQuantities { get; set; }
|
public IList<InventoryQuantityForm> InventoryQuantities { get; set; }
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace InventoryTraker.Web.Models
|
||||||
|
{
|
||||||
|
public class InventoryQuantityForm
|
||||||
|
{
|
||||||
|
[Required]
|
||||||
|
public int InventoryId { get; set; }
|
||||||
|
|
||||||
|
[Required, Range(1, int.MaxValue, ErrorMessage = "Quantity must be greater than 0")]
|
||||||
|
public int Quantity { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,22 +1,31 @@
|
|||||||
using Heroic.AutoMapper;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using Heroic.AutoMapper;
|
||||||
using InventoryTraker.Web.Core;
|
using InventoryTraker.Web.Core;
|
||||||
|
|
||||||
namespace InventoryTraker.Web.Models
|
namespace InventoryTraker.Web.Models
|
||||||
{
|
{
|
||||||
public class InventoryTypeViewModel : IMapFrom<InventoryType>
|
public class InventoryTypeViewModel : IMapFrom<InventoryType>, IMapTo<InventoryType>
|
||||||
{
|
{
|
||||||
|
[HiddenInput]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
public string Identifier { get; set; }
|
public string Identifier { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
public int UnitsPerCase { get; set; }
|
public int UnitsPerCase { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
public string ContainerType { get; set; }
|
public string ContainerType { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
public double WeightPerCase { get; set; }
|
public double WeightPerCase { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
public decimal PricePerCase { get; set; }
|
public decimal PricePerCase { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,14 @@
|
|||||||
@model dynamic
|
<div ng-controller="InventoryListController as vm">
|
||||||
|
|
||||||
@{
|
|
||||||
ViewBag.Title = "Inventory";
|
|
||||||
}
|
|
||||||
|
|
||||||
<div ng-controller="InventoryListController as vm">
|
|
||||||
<h1 class="page-header">
|
<h1 class="page-header">
|
||||||
<i class="fa fa-cubes"></i> Inventory
|
<i class="fa fa-cubes"></i> Inventory
|
||||||
</h1>
|
</h1>
|
||||||
<div class="pull-right">
|
<div class="pull-left">
|
||||||
<a class="btn btn-default" href="" ng-click="vm.add()"><i class="fa fa-plus-circle"></i> Arrival</a>
|
<a class="btn btn-default" href="" ng-click="vm.add()"><i class="fa fa-plus-circle"></i> Arrival</a>
|
||||||
<a class="btn btn-default" href="" ng-click="vm.distribute()"><i class="fa fa-share-square"></i> Distribute</a>
|
<a class="btn btn-default" href="" ng-click="vm.distribute()"><i class="fa fa-share-square"></i> Distribute</a>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="pull-right">
|
||||||
|
<a class="btn btn-default" href="/InventoryType"><i class="fa fa-cube"></i> Commodity Types</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<inventory-details inventories="vm.inventories"></inventory-details>
|
<inventory-details inventories="vm.inventories"></inventory-details>
|
||||||
</div>
|
</div>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
@model dynamic
|
||||||
|
|
||||||
|
@{
|
||||||
|
ViewBag.Title = "Inventory";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div ng-controller="InventoryTypeController as vm">
|
||||||
|
<h1 class="page-header">
|
||||||
|
<i class="fa fa-cube"></i> Commodity Types
|
||||||
|
</h1>
|
||||||
|
<div class="pull-left">
|
||||||
|
<a class="btn btn-default" href="" ng-click="vm.add()"><i class="fa fa-plus-circle"></i> Add</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<inventory-type-list inventory-types="vm.inventoryTypes"></inventory-type-list>
|
||||||
|
</div>
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
<a href="@(Html.BuildUrlFromExpression<InventoryController>(c => c.Index()))"><i class="fa fa-fw fa-cubes"></i> Inventory</a>
|
<a href="@(Html.BuildUrlFromExpression<InventoryController>(c => c.Index()))"><i class="fa fa-fw fa-cubes"></i> Inventory</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="@(Html.BuildUrlFromExpression<TransactionController>(c => c.Index()))"><i class="fa fa-fw fa-list"></i> Transactions</a>
|
<a href="@(Html.BuildUrlFromExpression<TransactionController>(c => c.Index()))"><i class="fa fa-fw fa-list"></i> Transaction History</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,13 +8,10 @@
|
|||||||
|
|
||||||
<div ng-controller="TransactionController as vm">
|
<div ng-controller="TransactionController as vm">
|
||||||
<h1 class="page-header">
|
<h1 class="page-header">
|
||||||
Transactions
|
Transaction History
|
||||||
</h1>
|
</h1>
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
@*<a class="btn btn-default" href="" ng-click="vm.add()"><i class="fa fa-plus-circle"></i> Arrival</a>
|
|
||||||
<a class="btn btn-default" href="" ng-click="vm.distribute()"><i class="fa fa-share-square"></i> Distribute</a>*@
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid-fullpage" ui-grid-pagination ui-grid="vm.gridOptions"></div>
|
<div class="grid-fullpage" ui-grid-pagination ui-grid="vm.gridOptions"></div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
$scope.$parent.$close();
|
$scope.$parent.$close();
|
||||||
})
|
})
|
||||||
.error(function(data) {
|
.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() {
|
.finally(function() {
|
||||||
vm.saving = false;
|
vm.saving = false;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<fieldset ng-disabled="vm.saving">
|
<fieldset ng-disabled="vm.saving">
|
||||||
|
|
||||||
<div class="modal-header">
|
<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>
|
||||||
|
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="inventory in vm.inventories" inventory="inventory">
|
<tr ng-repeat="inventory in vm.inventories">
|
||||||
<td><strong>@inventory.BindingFor(x => x.Name)</strong> <a href="" ng-click="vm.edit()"><i class="fa fa-edit"></i></a></td>
|
<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.UnitsPerCase) / @inventory.BindingFor(x => x.ContainerType)</td>
|
||||||
<td>@inventory.BindingFor(x => x.Quantity)</td>
|
<td>@inventory.BindingFor(x => x.Quantity)</td>
|
||||||
<td>{{inventory.quantity * inventory.unitsPerCase}}</td>
|
<td>{{inventory.quantity * inventory.unitsPerCase}}</td>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<fieldset ng-disabled="vm.saving">
|
<fieldset ng-disabled="vm.saving">
|
||||||
|
|
||||||
<div class="modal-header">
|
<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>
|
||||||
|
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<fieldset ng-disabled="vm.saving">
|
<fieldset ng-disabled="vm.saving">
|
||||||
|
|
||||||
<div class="modal-header">
|
<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>
|
||||||
|
|
||||||
<div class="modal-body">
|
<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 })
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
||||||
+5
-14
@@ -10,8 +10,7 @@
|
|||||||
var svc = {
|
var svc = {
|
||||||
add: add,
|
add: add,
|
||||||
update: update,
|
update: update,
|
||||||
inventoryTypes: inventoryTypes,
|
inventoryTypes: inventoryTypes
|
||||||
getInventoryType: getInventoryType
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return svc;
|
return svc;
|
||||||
@@ -30,19 +29,11 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function update(existingInventory, updatedInventory) {
|
function update(existingInventoryType, updatedInventoryType) {
|
||||||
return $http.post('/InventoryType/Update', updatedInventory)
|
return $http.post('/InventoryType/Update', updatedInventoryType)
|
||||||
.success(function (inventory) {
|
.success(function (inventoryType) {
|
||||||
angular.extend(existingInventory, inventory);
|
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}}' +
|
'\r{{row.entity.unitsPerCase}} / {{row.entity.containerType}}' +
|
||||||
'\rExp Date: {{row.entity.expirationDate | date:shortDate}}' +
|
'\rExp Date: {{row.entity.expirationDate | date:shortDate}}' +
|
||||||
'\rAdd Date: {{row.entity.addedDate | 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: 'memo', cellTooltip: true },
|
||||||
{ field: 'transactionDate', name: 'Transaction Date', cellFilter: "date:MM/dd/yyyy", width: "15%" },
|
{ field: 'transactionDate', name: 'Transaction Date', cellFilter: "date:MM/dd/yyyy", width: "15%" },
|
||||||
@@ -61,19 +62,12 @@
|
|||||||
var updateData = function () {
|
var updateData = function () {
|
||||||
transactionSvc
|
transactionSvc
|
||||||
.getTransactions(paginationOptions.pageNumber, paginationOptions.pageSize)
|
.getTransactions(paginationOptions.pageNumber, paginationOptions.pageSize)
|
||||||
.then(function(data) {
|
.success(function(data) {
|
||||||
vm.gridOptions.totalItems = data.totalItems;
|
vm.gridOptions.totalItems = data.totalItems;
|
||||||
vm.gridOptions.data = data.transactions;
|
vm.gridOptions.data = data.transactions;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
updateData();
|
updateData();
|
||||||
|
|
||||||
function del() {
|
|
||||||
$uibModal.open({
|
|
||||||
template: '<inventory-distribute />',
|
|
||||||
backdrop: 'static'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
@@ -14,10 +14,10 @@
|
|||||||
|
|
||||||
function getTransactions(pageNumber, pageSize) {
|
function getTransactions(pageNumber, pageSize) {
|
||||||
var url = '/Transaction/GetTransactions';
|
var url = '/Transaction/GetTransactions';
|
||||||
return $http.post(url, {pageNumber: pageNumber, pageSize: pageSize})
|
return $http.post(url, { pageNumber: pageNumber, pageSize: pageSize });
|
||||||
.then(function(data) {
|
//.success(function(data) {
|
||||||
return data.data;
|
// return data.data;
|
||||||
});
|
//});
|
||||||
}
|
}
|
||||||
|
|
||||||
function update(existingTransaction, updatedTransaction) {
|
function update(existingTransaction, updatedTransaction) {
|
||||||
|
|||||||
Reference in New Issue
Block a user