diff --git a/InventoryTraker.Web.Tests/InventoryTraker.Web.Tests.csproj b/InventoryTraker.Web.Tests/InventoryTraker.Web.Tests.csproj index 7fb1dd8..826cfed 100644 --- a/InventoryTraker.Web.Tests/InventoryTraker.Web.Tests.csproj +++ b/InventoryTraker.Web.Tests/InventoryTraker.Web.Tests.csproj @@ -34,10 +34,6 @@ ..\packages\AutoMapper.5.1.1\lib\net45\AutoMapper.dll True - - ..\packages\Heroic.AutoMapper.2.0.0\lib\net45\Heroic.AutoMapper.dll - True - ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll True diff --git a/InventoryTraker.Web.Tests/Models/InventoryAddForm.cs b/InventoryTraker.Web.Tests/Models/InventoryAddForm.cs index e4a66a0..a7c64f2 100644 --- a/InventoryTraker.Web.Tests/Models/InventoryAddForm.cs +++ b/InventoryTraker.Web.Tests/Models/InventoryAddForm.cs @@ -1,6 +1,5 @@ using System; using AutoMapper; -using Heroic.AutoMapper; using InventoryTraker.Web.Core; using InventoryTraker.Web.Models; using NUnit.Framework; diff --git a/InventoryTraker.Web/Controllers/ProfileController.cs b/InventoryTraker.Web/Controllers/ProfileController.cs index c81fead..d3389ce 100644 --- a/InventoryTraker.Web/Controllers/ProfileController.cs +++ b/InventoryTraker.Web/Controllers/ProfileController.cs @@ -1,6 +1,8 @@ -using System.Web.Mvc; +using System.Linq; +using System.Threading.Tasks; +using System.Web.Mvc; using AutoMapper; -using InventoryTraker.Web.Core; +using InventoryTraker.Web.Attributes; using InventoryTraker.Web.Identity; using InventoryTraker.Web.Models; using Microsoft.AspNet.Identity; @@ -20,19 +22,44 @@ namespace InventoryTraker.Web.Controllers public ActionResult Index() { - var user = _userManager.FindById(User.Identity.GetUserId()); - var model = _mapper.Map(user); - return View(model); + return View(); } - public JsonResult Update(ProfileForm form) + public JsonResult Get() { var user = _userManager.FindById(User.Identity.GetUserId()); - user.Email = form.EmailAddress; - user.UserName = form.FullName; - _userManager.Update(user); + var model = _mapper.Map(user); + return BetterJson(model); + } - return Json(true); + [ActionLog] + public async Task Update(ProfileForm form) + { + if (!ModelState.IsValid) + return GetModelStateErrorListJson(); + + var user = _userManager.FindById(User.Identity.GetUserId()); + user.Email = form.Email; + user.UserName = form.UserName; + + if (!string.IsNullOrEmpty(form.NewPassword)) + { + if (string.IsNullOrEmpty(form.CurrentPassword)) + return GetErrorListJson("Current password required"); + + var result = + await _userManager.ChangePasswordAsync( + user.Id, form.CurrentPassword, form.NewPassword); + + if (!result.Succeeded) + return GetErrorListJson(result.Errors.ToArray()); + } + + var identityResult = _userManager.Update(user); + if (!identityResult.Succeeded) + return GetErrorListJson(identityResult.Errors.ToArray()); + + return BetterJson(_mapper.Map(user)); } } } \ No newline at end of file diff --git a/InventoryTraker.Web/Controllers/UserController.cs b/InventoryTraker.Web/Controllers/UserController.cs index 9ebebac..2e310bd 100644 --- a/InventoryTraker.Web/Controllers/UserController.cs +++ b/InventoryTraker.Web/Controllers/UserController.cs @@ -74,8 +74,7 @@ namespace InventoryTraker.Web.Controllers if (!string.IsNullOrEmpty(form.Password)) { - var resetToken = await _userManager.GeneratePasswordResetTokenAsync(user.Id); - var resetResult = await _userManager.ResetPasswordAsync(user.Id, resetToken, form.Password); + var resetResult = await _userManager.ChangePasswordAsync(user, form.Password); if (!resetResult.Succeeded) return GetErrorListJson(resetResult.Errors.ToArray()); } diff --git a/InventoryTraker.Web/Identity/ApplicationUserManager.cs b/InventoryTraker.Web/Identity/ApplicationUserManager.cs index a44ac14..c8eb325 100644 --- a/InventoryTraker.Web/Identity/ApplicationUserManager.cs +++ b/InventoryTraker.Web/Identity/ApplicationUserManager.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using InventoryTraker.Web.Core; using Microsoft.AspNet.Identity; using Microsoft.AspNet.Identity.Owin; @@ -26,5 +27,11 @@ namespace InventoryTraker.Web.Identity }; } } + + public async Task ChangePasswordAsync(User user, string newPassword) + { + var resetToken = await GeneratePasswordResetTokenAsync(user.Id); + return await ResetPasswordAsync(user.Id, resetToken, newPassword); + } } } \ No newline at end of file diff --git a/InventoryTraker.Web/InventoryTraker.Web.csproj b/InventoryTraker.Web/InventoryTraker.Web.csproj index 22547d7..b074285 100644 --- a/InventoryTraker.Web/InventoryTraker.Web.csproj +++ b/InventoryTraker.Web/InventoryTraker.Web.csproj @@ -228,6 +228,8 @@ + + @@ -246,7 +248,7 @@ - + @@ -313,6 +315,7 @@ + Designer diff --git a/InventoryTraker.Web/Models/ProfileForm.cs b/InventoryTraker.Web/Models/ProfileForm.cs index a6cff6b..a7bb843 100644 --- a/InventoryTraker.Web/Models/ProfileForm.cs +++ b/InventoryTraker.Web/Models/ProfileForm.cs @@ -6,19 +6,36 @@ namespace InventoryTraker.Web.Models { public class ProfileForm { - [Required, Display(Name = "Full Name", Prompt = "Full Name (ex: John Doe)...")] - public string FullName { get; set; } + [Required] + [StringLength(128)] + [RegularExpression(@"[A-Za-z().]+(\s+[A-Za-z().]+)+", ErrorMessage = "Need complete name")] + public string UserName { get; set; } - [Required, DataType(DataType.EmailAddress), Display(Prompt = "your@email.com...")] - public string EmailAddress { get; set; } + [Required] + [DataType(DataType.EmailAddress)] + [RegularExpression(@"[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}", ErrorMessage = "Must be an email address")] + public string Email { get; set; } + + [DataType(DataType.Password)] + public string CurrentPassword { get; set; } + + [DataType(DataType.Password)] + public string NewPassword { get; set; } + + [DataType(DataType.Password)] + [Compare("NewPassword")] + public string ConfirmPassword { get; set; } + + public override string ToString() + { + return $"UserName: {UserName}, email: {Email}"; + } public class AutoMapperProfile : Profile { public AutoMapperProfile() { - CreateMap() - .ForMember(d => d.FullName, opt => opt.MapFrom(s => s.UserName)) - .ForMember(d => d.EmailAddress, opt => opt.MapFrom(s => s.Email)); + CreateMap(); } } } diff --git a/InventoryTraker.Web/Views/Profile/Index.cshtml b/InventoryTraker.Web/Views/Profile/Index.cshtml index ae082e2..2c3be98 100644 --- a/InventoryTraker.Web/Views/Profile/Index.cshtml +++ b/InventoryTraker.Web/Views/Profile/Index.cshtml @@ -1,38 +1,13 @@ -@using InventoryTraker.Web.Helpers -@model InventoryTraker.Web.Models.ProfileForm +@model InventoryTraker.Web.Models.ProfileForm @{ ViewBag.Title = "Your Profile"; } Update @ViewBag.Title - - - - Make changes below. - - - Saving changes... - - - - Changes saved! - - - {{vm.errorMessage}} - - - @Html.Angular().FormForModel("vm.profile") - - - Save Changes - Cancel - - - - \ No newline at end of file + + + + + diff --git a/InventoryTraker.Web/Views/Shared/_Navigation.cshtml b/InventoryTraker.Web/Views/Shared/_Navigation.cshtml index a27efb4..35f4fd5 100644 --- a/InventoryTraker.Web/Views/Shared/_Navigation.cshtml +++ b/InventoryTraker.Web/Views/Shared/_Navigation.cshtml @@ -36,13 +36,13 @@ Transaction History - Reports + Reports - Distribution + Distribution - Monthly Inventory + Monthly Inventory diff --git a/InventoryTraker.Web/js/authentication/LoginController.js b/InventoryTraker.Web/js/authentication/LoginController.js index 3894abd..728a516 100644 --- a/InventoryTraker.Web/js/authentication/LoginController.js +++ b/InventoryTraker.Web/js/authentication/LoginController.js @@ -1,7 +1,9 @@ -(function () { - 'use strict'; +(function() { + "use strict"; - window.app.controller('LoginController', + window.app.controller("LoginController", + [ + "$window", "$http", function($window, $http) { var vm = this; vm.errorMessage = null; @@ -24,5 +26,6 @@ vm.loggingIn = false; }); } - }); + } + ]); })(); diff --git a/InventoryTraker.Web/js/inventory/InventoryAddDirective.js b/InventoryTraker.Web/js/inventory/InventoryAddDirective.js index 97da381..cb01a8e 100644 --- a/InventoryTraker.Web/js/inventory/InventoryAddDirective.js +++ b/InventoryTraker.Web/js/inventory/InventoryAddDirective.js @@ -11,7 +11,6 @@ }); controller.$inject = ['$scope', 'inventorySvc', 'inventoryTypeSvc']; - function controller($scope, inventorySvc, inventoryTypeSvc) { var vm = this; diff --git a/InventoryTraker.Web/js/inventory/InventoryListController.js b/InventoryTraker.Web/js/inventory/InventoryListController.js index 7c43323..5aeb493 100644 --- a/InventoryTraker.Web/js/inventory/InventoryListController.js +++ b/InventoryTraker.Web/js/inventory/InventoryListController.js @@ -1,7 +1,9 @@ (function() { - 'use strict'; + "use strict"; - window.app.controller('InventoryListController', + window.app.controller("InventoryListController", + [ + "$uibModal", "inventorySvc", "downloadSvc", function($uibModal, inventorySvc, downloadSvc) { var vm = this; @@ -9,15 +11,15 @@ vm.add = function() { $uibModal.open({ - template: '', - backdrop: 'static' + template: "", + backdrop: "static" }); }; vm.distribute = function() { $uibModal.open({ - template: '', - backdrop: 'static' + template: "", + backdrop: "static" }); }; @@ -25,5 +27,6 @@ inventorySvc.exportInventory() .success(downloadSvc.success); }; - }); + } + ]); })(); \ No newline at end of file diff --git a/InventoryTraker.Web/js/inventory/inventorySvc.js b/InventoryTraker.Web/js/inventory/inventorySvc.js index fad3d09..6127937 100644 --- a/InventoryTraker.Web/js/inventory/inventorySvc.js +++ b/InventoryTraker.Web/js/inventory/inventorySvc.js @@ -1,5 +1,7 @@ (function() { - window.app.factory('inventorySvc', + window.app.factory("inventorySvc", + [ + "$http", "$filter", function($http, $filter) { var inventories = []; @@ -20,32 +22,32 @@ return svc; function loadInventories() { - $http.post('/Inventory/All') + $http.post("/Inventory/All") .success(function(data) { angular.copy(data, inventories); }); } function exportInventory() { - return $http.post('/Inventory/Export', {}, { responseType: 'arraybuffer' }); + return $http.post("/Inventory/Export", {}, { responseType: "arraybuffer" }); } function add(inventory) { - return $http.post('/Inventory/Add', inventory) + return $http.post("/Inventory/Add", inventory) .success(function(inventory) { inventories.unshift(inventory); }); } function distribute(distribution) { - return $http.post('/Inventory/Distribute', distribution) + return $http.post("/Inventory/Distribute", distribution) .success(function(data) { angular.copy(data, inventories); }); } function update(existingInventory, updatedInventory) { - return $http.post('/Inventory/Update', updatedInventory) + return $http.post("/Inventory/Update", updatedInventory) .success(function(inventory) { angular.extend(existingInventory, inventory); }); @@ -54,14 +56,14 @@ // remove quantity from this inventory function remove(removeForm) { var existingInventory = get(removeForm.inventoryId); - return $http.post('/Inventory/Remove', removeForm) + return $http.post("/Inventory/Remove", removeForm) .success(function(data) { angular.copy(data, existingInventory); }); } function get(id) { - var results = $filter('filter')(inventories, { id: id }); + var results = $filter("filter")(inventories, { id: id }); if (results.length > 0) return results[0]; return null; @@ -79,7 +81,8 @@ } function find(id) { - return $http.post('/Inventory/Find', { id: id }); + return $http.post("/Inventory/Find", { id: id }); } - }); + } + ]); })(); \ No newline at end of file diff --git a/InventoryTraker.Web/js/inventory/templates/inventoryAdd.tmpl.cshtml b/InventoryTraker.Web/js/inventory/templates/inventoryAdd.tmpl.cshtml index 582fc39..89e4962 100644 --- a/InventoryTraker.Web/js/inventory/templates/inventoryAdd.tmpl.cshtml +++ b/InventoryTraker.Web/js/inventory/templates/inventoryAdd.tmpl.cshtml @@ -85,7 +85,7 @@ diff --git a/InventoryTraker.Web/js/inventory/templates/inventoryDistribute.tmpl.cshtml b/InventoryTraker.Web/js/inventory/templates/inventoryDistribute.tmpl.cshtml index 0c2dae9..2cb508e 100644 --- a/InventoryTraker.Web/js/inventory/templates/inventoryDistribute.tmpl.cshtml +++ b/InventoryTraker.Web/js/inventory/templates/inventoryDistribute.tmpl.cshtml @@ -55,7 +55,7 @@ diff --git a/InventoryTraker.Web/js/inventory/templates/inventoryEdit.tmpl.cshtml b/InventoryTraker.Web/js/inventory/templates/inventoryEdit.tmpl.cshtml index 15f707a..7b25f1a 100644 --- a/InventoryTraker.Web/js/inventory/templates/inventoryEdit.tmpl.cshtml +++ b/InventoryTraker.Web/js/inventory/templates/inventoryEdit.tmpl.cshtml @@ -15,7 +15,7 @@ diff --git a/InventoryTraker.Web/js/inventory/templates/inventoryList.tmpl.cshtml b/InventoryTraker.Web/js/inventory/templates/inventoryList.tmpl.cshtml index 0f91575..ddf5f8d 100644 --- a/InventoryTraker.Web/js/inventory/templates/inventoryList.tmpl.cshtml +++ b/InventoryTraker.Web/js/inventory/templates/inventoryList.tmpl.cshtml @@ -18,7 +18,7 @@ - + diff --git a/InventoryTraker.Web/js/inventory/templates/inventoryRemove.tmpl.cshtml b/InventoryTraker.Web/js/inventory/templates/inventoryRemove.tmpl.cshtml index 0e47108..7c2332a 100644 --- a/InventoryTraker.Web/js/inventory/templates/inventoryRemove.tmpl.cshtml +++ b/InventoryTraker.Web/js/inventory/templates/inventoryRemove.tmpl.cshtml @@ -47,7 +47,7 @@ diff --git a/InventoryTraker.Web/js/inventoryType/InventoryTypeAddDirective.js b/InventoryTraker.Web/js/inventoryType/InventoryTypeAddDirective.js index 8941803..f6dba5d 100644 --- a/InventoryTraker.Web/js/inventoryType/InventoryTypeAddDirective.js +++ b/InventoryTraker.Web/js/inventoryType/InventoryTypeAddDirective.js @@ -10,6 +10,7 @@ }; }); + controller.$inject = ['$scope', 'inventoryTypeSvc']; function controller($scope, inventoryTypeSvc){ var vm = this; diff --git a/InventoryTraker.Web/js/inventoryType/InventoryTypeController.js b/InventoryTraker.Web/js/inventoryType/InventoryTypeController.js index 7455732..13ce7f7 100644 --- a/InventoryTraker.Web/js/inventoryType/InventoryTypeController.js +++ b/InventoryTraker.Web/js/inventoryType/InventoryTypeController.js @@ -1,7 +1,9 @@ (function() { - 'use strict'; + "use strict"; - window.app.controller('InventoryTypeController', + window.app.controller("InventoryTypeController", + [ + "$uibModal", "inventoryTypeSvc", "downloadSvc", function($uibModal, inventoryTypeSvc, downloadSvc) { var vm = this; @@ -9,14 +11,14 @@ vm.add = function() { $uibModal.open({ - template: '', - backdrop: 'static' + template: "", + backdrop: "static" }); - } - + }; vm.export = function() { inventoryTypeSvc.exportInventoryTypes() .success(downloadSvc.success); - } - }); + }; + } + ]); })(); \ No newline at end of file diff --git a/InventoryTraker.Web/js/inventoryType/InventoryTypeEditDirective.js b/InventoryTraker.Web/js/inventoryType/InventoryTypeEditDirective.js index 35e341b..f7be05e 100644 --- a/InventoryTraker.Web/js/inventoryType/InventoryTypeEditDirective.js +++ b/InventoryTraker.Web/js/inventoryType/InventoryTypeEditDirective.js @@ -13,6 +13,7 @@ } }); + controller.$inject = ['$scope', 'inventoryTypeSvc']; function controller($scope, inventoryTypeSvc) { var vm = this; vm.inventoryType = angular.copy($scope.inventoryType); diff --git a/InventoryTraker.Web/js/inventoryType/InventoryTypeListDirective.js b/InventoryTraker.Web/js/inventoryType/InventoryTypeListDirective.js index ee7784b..878de27 100644 --- a/InventoryTraker.Web/js/inventoryType/InventoryTypeListDirective.js +++ b/InventoryTraker.Web/js/inventoryType/InventoryTypeListDirective.js @@ -11,6 +11,7 @@ } }); + controller.$inject = ['$scope', '$uibModal']; function controller($scope, $uibModal) { var vm = this; diff --git a/InventoryTraker.Web/js/inventoryType/inventoryTypeSvc.js b/InventoryTraker.Web/js/inventoryType/inventoryTypeSvc.js index d021543..88c360a 100644 --- a/InventoryTraker.Web/js/inventoryType/inventoryTypeSvc.js +++ b/InventoryTraker.Web/js/inventoryType/inventoryTypeSvc.js @@ -1,5 +1,7 @@ -(function () { - window.app.factory('inventoryTypeSvc', +(function() { + window.app.factory("inventoryTypeSvc", + [ + "$http", function($http) { var inventoryTypes = []; @@ -15,28 +17,29 @@ return svc; function loadInventoryTypes() { - $http.post('/InventoryType/All') + $http.post("/InventoryType/All") .success(function(data) { inventoryTypes.addRange(data); }); } function exportInventoryTypes() { - return $http.post('/InventoryType/Export', {}, { responseType: 'arraybuffer' }); + return $http.post("/InventoryType/Export", {}, { responseType: "arraybuffer" }); } function add(inventoryType) { - return $http.post('/InventoryType/Add', inventoryType) + return $http.post("/InventoryType/Add", inventoryType) .success(function(inventoryType) { inventoryTypes.unshift(inventoryType); }); } function update(existingInventoryType, updatedInventoryType) { - return $http.post('/InventoryType/Update', updatedInventoryType) + return $http.post("/InventoryType/Update", updatedInventoryType) .success(function(inventoryType) { angular.extend(existingInventoryType, inventoryType); }); } - }); + } + ]); })(); \ No newline at end of file diff --git a/InventoryTraker.Web/js/inventoryType/templates/inventoryTypeAdd.tmpl.cshtml b/InventoryTraker.Web/js/inventoryType/templates/inventoryTypeAdd.tmpl.cshtml index f51492d..a74b9b3 100644 --- a/InventoryTraker.Web/js/inventoryType/templates/inventoryTypeAdd.tmpl.cshtml +++ b/InventoryTraker.Web/js/inventoryType/templates/inventoryTypeAdd.tmpl.cshtml @@ -19,7 +19,7 @@ diff --git a/InventoryTraker.Web/js/inventoryType/templates/inventoryTypeEdit.tmpl.cshtml b/InventoryTraker.Web/js/inventoryType/templates/inventoryTypeEdit.tmpl.cshtml index 868632e..ef2c8a4 100644 --- a/InventoryTraker.Web/js/inventoryType/templates/inventoryTypeEdit.tmpl.cshtml +++ b/InventoryTraker.Web/js/inventoryType/templates/inventoryTypeEdit.tmpl.cshtml @@ -19,7 +19,7 @@ diff --git a/InventoryTraker.Web/js/profile/EditProfileController.js b/InventoryTraker.Web/js/profile/EditProfileController.js deleted file mode 100644 index f2ff269..0000000 --- a/InventoryTraker.Web/js/profile/EditProfileController.js +++ /dev/null @@ -1,28 +0,0 @@ -(function() { - 'use strict'; - - window.app.controller('EditProfileController', - function($http, model) { - var vm = this; - - vm.profile = model; - vm.save = save; - - function save() { - vm.saving = true; - vm.errorMessage = null; - vm.success = false; - - $http.post("/Profile/Update", vm.profile) - .success(function() { - vm.success = true; - }) - .error(function(msg) { - vm.errorMessage = msg; - }) - .finally(function() { - vm.saving = false; - }); - } - }); -})(); \ No newline at end of file diff --git a/InventoryTraker.Web/js/profile/ProfileController.js b/InventoryTraker.Web/js/profile/ProfileController.js new file mode 100644 index 0000000..712c9b7 --- /dev/null +++ b/InventoryTraker.Web/js/profile/ProfileController.js @@ -0,0 +1,13 @@ +(function() { + "use strict"; + + window.app.controller("ProfileController", + [ + '$scope', 'profileSvc', + function ($scope, profileSvc) { + var vm = this; + + vm.profile = profileSvc.profile; + } + ]); +})(); \ No newline at end of file diff --git a/InventoryTraker.Web/js/profile/ProfileEditDirective.js b/InventoryTraker.Web/js/profile/ProfileEditDirective.js new file mode 100644 index 0000000..5dd7c7b --- /dev/null +++ b/InventoryTraker.Web/js/profile/ProfileEditDirective.js @@ -0,0 +1,43 @@ +(function() { + "use strict"; + + window.app.directive('profileEdit', function (){ + return { + scope: { + profile: "=" + }, + templateUrl: '/profile/template/profileEdit.tmpl.cshtml', + controller: controller, + controllerAs: 'vm' + } + }); + + controller.$inject = ['$scope', 'profileSvc']; + function controller($scope, profileSvc) { + var vm = this; + vm.profile = $scope.profile; + + vm.saving = false; + vm.success = false; + vm.errorMessages = []; + vm.save = save; + + function save() { + vm.saving = true; + vm.success = false; + angular.copy([], vm.errorMessages); + + profileSvc.update(vm.profile) + .success(function () { + vm.success = true; + vm.form.$setPristine(); + }) + .error(function (data) { + vm.errorMessages = angular.copy(data.errorMessages, vm.errorMessages); + }) + .finally(function () { + vm.saving = false; + }); + } + } +})(); \ No newline at end of file diff --git a/InventoryTraker.Web/js/profile/profileSvc.js b/InventoryTraker.Web/js/profile/profileSvc.js new file mode 100644 index 0000000..13de7bc --- /dev/null +++ b/InventoryTraker.Web/js/profile/profileSvc.js @@ -0,0 +1,32 @@ +(function() { + window.app.factory("profileSvc", + [ + "$http", + function($http) { + var profile = {}; + + loadProfile(); + + var svc = { + update: update, + profile: profile + }; + + return svc; + + function loadProfile() { + $http.post("/Profile/Get") + .success(function(data) { + angular.copy(data, profile); + }); + } + + function update(updatedProfile) { + return $http.post("/Profile/Update", updatedProfile) + .success(function(data) { + angular.copy(data, profile); + }); + } + } + ]); +})(); \ No newline at end of file diff --git a/InventoryTraker.Web/js/profile/templates/profileEdit.tmpl.cshtml b/InventoryTraker.Web/js/profile/templates/profileEdit.tmpl.cshtml new file mode 100644 index 0000000..ef934cb --- /dev/null +++ b/InventoryTraker.Web/js/profile/templates/profileEdit.tmpl.cshtml @@ -0,0 +1,28 @@ +@using InventoryTraker.Web.Helpers +@model InventoryTraker.Web.Models.ProfileForm + + + + + + + + + + Changes saved + + + @Html.Angular().FormForModel("vm.profile") + + + + + + + + \ No newline at end of file diff --git a/InventoryTraker.Web/js/report/DistributionReportController.js b/InventoryTraker.Web/js/report/DistributionReportController.js index c4e92ce..a320918 100644 --- a/InventoryTraker.Web/js/report/DistributionReportController.js +++ b/InventoryTraker.Web/js/report/DistributionReportController.js @@ -1,7 +1,9 @@ -(function () { - 'use strict'; +(function() { + "use strict"; - window.app.controller('DistributionReportController', + window.app.controller("DistributionReportController", + [ + "$scope", "reportSvc", "downloadSvc", function($scope, reportSvc, downloadSvc) { var vm = this; vm.loadData = reportSvc.loadDistributionReport; @@ -10,6 +12,7 @@ vm.export = function(params) { reportSvc.exportDistributionReport(params) .success(downloadSvc.success); - } - }); + }; + } + ]); })(); \ No newline at end of file diff --git a/InventoryTraker.Web/js/report/DistributionReportDirective.js b/InventoryTraker.Web/js/report/DistributionReportDirective.js index 279f632..54a61d9 100644 --- a/InventoryTraker.Web/js/report/DistributionReportDirective.js +++ b/InventoryTraker.Web/js/report/DistributionReportDirective.js @@ -11,6 +11,7 @@ } }); + controller.$inject = ['$scope']; function controller($scope) { var vm = this; vm.distributionData = $scope.distributionData; diff --git a/InventoryTraker.Web/js/report/MovementReportController.js b/InventoryTraker.Web/js/report/MovementReportController.js index 5f94fa5..30dc33e 100644 --- a/InventoryTraker.Web/js/report/MovementReportController.js +++ b/InventoryTraker.Web/js/report/MovementReportController.js @@ -1,7 +1,9 @@ -(function () { - 'use strict'; +(function() { + "use strict"; - window.app.controller('MovementReportController', + window.app.controller("MovementReportController", + [ + "$scope", "reportSvc", "downloadSvc", function($scope, reportSvc, downloadSvc) { var vm = this; vm.loadData = reportSvc.loadMovementData; @@ -9,6 +11,7 @@ vm.export = function(month) { reportSvc.exportMovementData({ month: month }) .success(downloadSvc.success); - } - }); + }; + } + ]); })(); \ No newline at end of file diff --git a/InventoryTraker.Web/js/report/MovementReportDirective.js b/InventoryTraker.Web/js/report/MovementReportDirective.js index e84820e..b04cada 100644 --- a/InventoryTraker.Web/js/report/MovementReportDirective.js +++ b/InventoryTraker.Web/js/report/MovementReportDirective.js @@ -11,6 +11,7 @@ } }); + controller.$inject = ['$scope', '$uibModal', 'inventorySvc']; function controller($scope, $uibModal, inventorySvc) { var vm = this; vm.movementData = $scope.movementData; diff --git a/InventoryTraker.Web/js/report/reportSvc.js b/InventoryTraker.Web/js/report/reportSvc.js index 44fab75..b44c094 100644 --- a/InventoryTraker.Web/js/report/reportSvc.js +++ b/InventoryTraker.Web/js/report/reportSvc.js @@ -1,5 +1,7 @@ -(function () { - window.app.factory('reportSvc', +(function() { + window.app.factory("reportSvc", + [ + "$http", function($http) { var distributionData = []; var distributionQuery = {}; @@ -18,7 +20,7 @@ return svc; function loadDistributionReport(query) { - return $http.post('/Report/Distribution', query) + return $http.post("/Report/Distribution", query) .success(function(data) { distributionQuery = angular.copy(query, distributionQuery); angular.copy(data, distributionData); @@ -26,18 +28,19 @@ } function exportDistributionReport(query) { - return $http.post('/Report/DistributionExcel', query, { responseType: 'arraybuffer' }); + return $http.post("/Report/DistributionExcel", query, { responseType: "arraybuffer" }); } function loadMovementData(query) { - return $http.post('/Report/Movement', query) + return $http.post("/Report/Movement", query) .success(function(data) { angular.copy(data, movementData); }); } function exportMovementData(query) { - return $http.post('/Report/MovementExcel', query, { responseType: 'arraybuffer' }); + return $http.post("/Report/MovementExcel", query, { responseType: "arraybuffer" }); } - }); + } + ]); })(); \ No newline at end of file diff --git a/InventoryTraker.Web/js/transaction/TransactionController.js b/InventoryTraker.Web/js/transaction/TransactionController.js index 705ecaa..e1b15ad 100644 --- a/InventoryTraker.Web/js/transaction/TransactionController.js +++ b/InventoryTraker.Web/js/transaction/TransactionController.js @@ -1,7 +1,9 @@ (function() { - 'use strict'; + "use strict"; - window.app.controller('TransactionController', + window.app.controller("TransactionController", + [ + "$scope", "$uibModal", "transactionSvc", "inventorySvc", "uiGridConstants", function($scope, $uibModal, transactionSvc, inventorySvc, uiGridConstants) { var vm = this; @@ -20,27 +22,27 @@ enableSorting: false, columnDefs: [ { - field: 'name', + field: "name", cellTooltip: function(row) { return row.entity.name + "\r" + row.entity.unitsPerCase + " / " + row.entity.containerType; }, cellTemplate: '' + ' ' + - '{{row.entity.name}}', + "{{row.entity.name}}", width: "20%" }, - { field: 'transactionType', name: 'Type', width: "10%" }, - { field: 'destination', cellTooltip: true, width: "10%" }, - { field: 'memo', cellTooltip: true, width: "15%" }, - { field: 'transactionDate', name: 'Transaction Date', cellFilter: "date:'shortDate'", width: "10%" }, - { field: 'previousQuantity', name: 'Prev Qty', width: "10%", enableSorting: false }, - { field: 'addedQuantity', name: 'Add Qty', width: "10%", enableSorting: false, cellFilter: "hideZero" }, - { field: 'removedQuantity', name: 'Remove Qty', width: "10%", enableSorting: false, cellFilter: "hideZero" }, - { field: 'currentQuantity', name: 'Current Qty', width: "10%", enableSorting: false } + { field: "transactionType", name: "Type", width: "10%" }, + { field: "destination", cellTooltip: true, width: "10%" }, + { field: "memo", cellTooltip: true, width: "15%" }, + { field: "transactionDate", name: "Transaction Date", cellFilter: "date:'shortDate'", width: "10%" }, + { field: "previousQuantity", name: "Prev Qty", width: "10%", enableSorting: false }, + { field: "addedQuantity", name: "Add Qty", width: "10%", enableSorting: false, cellFilter: "hideZero" }, + { field: "removedQuantity", name: "Remove Qty", width: "10%", enableSorting: false, cellFilter: "hideZero" }, + { field: "currentQuantity", name: "Current Qty", width: "10%", enableSorting: false } ], onRegisterApi: function(gridApi) { vm.gridApi = gridApi; @@ -76,6 +78,7 @@ updateData(); }); }); - } - }); + }; + } + ]); })(); \ No newline at end of file diff --git a/InventoryTraker.Web/js/transaction/transactionSvc.js b/InventoryTraker.Web/js/transaction/transactionSvc.js index 3911470..9dc7f1a 100644 --- a/InventoryTraker.Web/js/transaction/transactionSvc.js +++ b/InventoryTraker.Web/js/transaction/transactionSvc.js @@ -1,5 +1,6 @@ (function() { - window.app.factory('transactionSvc', + window.app.factory('transactionSvc', [ + '$http', 'inventorySvc', function($http, inventorySvc) { var svc = { @@ -31,5 +32,5 @@ inventorySvc.refresh(data.inventoryId); }); } - }); + }]); })(); \ No newline at end of file diff --git a/InventoryTraker.Web/js/user/UserController.js b/InventoryTraker.Web/js/user/UserController.js index fa4f16e..9820508 100644 --- a/InventoryTraker.Web/js/user/UserController.js +++ b/InventoryTraker.Web/js/user/UserController.js @@ -1,7 +1,9 @@ (function() { - 'use strict'; + "use strict"; - window.app.controller('UserController', + window.app.controller("UserController", + [ + "$uibModal", "userSvc", "downloadSvc", function($uibModal, userSvc, downloadSvc) { var vm = this; @@ -9,21 +11,20 @@ vm.create = function() { $uibModal.open({ - template: '', - backdrop: 'static' + template: "", + backdrop: "static" }); - } - + }; vm.edit = function() { $uibModal.open({ - template: '', - backdrop: 'static' + template: "", + backdrop: "static" }); - } - + }; vm.export = function() { userSvc.exportUsers() .success(downloadSvc.success); - } - }); + }; + } + ]); })(); \ No newline at end of file diff --git a/InventoryTraker.Web/js/user/UserCreateDirective.js b/InventoryTraker.Web/js/user/UserCreateDirective.js index 086f582..f0b7525 100644 --- a/InventoryTraker.Web/js/user/UserCreateDirective.js +++ b/InventoryTraker.Web/js/user/UserCreateDirective.js @@ -9,6 +9,7 @@ } }); + controller.$inject = ['$scope', 'userSvc']; function controller($scope, userSvc){ var vm = this; diff --git a/InventoryTraker.Web/js/user/UserEditDirective.js b/InventoryTraker.Web/js/user/UserEditDirective.js index 6c0b9d9..1b52ad9 100644 --- a/InventoryTraker.Web/js/user/UserEditDirective.js +++ b/InventoryTraker.Web/js/user/UserEditDirective.js @@ -12,6 +12,7 @@ } }); + controller.$inject = ['$scope', 'userSvc']; function controller($scope, userSvc) { var vm = this; vm.user = angular.copy($scope.user); diff --git a/InventoryTraker.Web/js/user/templates/userCreate.tmpl.cshtml b/InventoryTraker.Web/js/user/templates/userCreate.tmpl.cshtml index 992be44..acc2cbe 100644 --- a/InventoryTraker.Web/js/user/templates/userCreate.tmpl.cshtml +++ b/InventoryTraker.Web/js/user/templates/userCreate.tmpl.cshtml @@ -19,7 +19,7 @@ diff --git a/InventoryTraker.Web/js/user/templates/userEdit.tmpl.cshtml b/InventoryTraker.Web/js/user/templates/userEdit.tmpl.cshtml index fec5e3e..38ffa55 100644 --- a/InventoryTraker.Web/js/user/templates/userEdit.tmpl.cshtml +++ b/InventoryTraker.Web/js/user/templates/userEdit.tmpl.cshtml @@ -19,7 +19,7 @@ diff --git a/InventoryTraker.Web/js/user/userSvc.js b/InventoryTraker.Web/js/user/userSvc.js index fa3bcd0..15c9210 100644 --- a/InventoryTraker.Web/js/user/userSvc.js +++ b/InventoryTraker.Web/js/user/userSvc.js @@ -1,5 +1,7 @@ -(function () { - window.app.factory('userSvc', +(function() { + window.app.factory("userSvc", + [ + "$http", function($http) { var users = []; @@ -15,28 +17,29 @@ return svc; function loadUsers() { - $http.post('/User/All') + $http.post("/User/All") .success(function(data) { users.addRange(data); }); } function exportusers() { - return $http.post('/User/Export', {}, { responseType: 'arraybuffer' }); + return $http.post("/User/Export", {}, { responseType: "arraybuffer" }); } function create(user) { - return $http.post('/User/Create', user) + return $http.post("/User/Create", user) .success(function(user) { users.unshift(user); }); } function edit(existingUser, editedUser) { - return $http.post('/User/Edit', editedUser) + return $http.post("/User/Edit", editedUser) .success(function(user) { angular.copy(user, existingUser); }); } - }); + } + ]); })(); \ No newline at end of file diff --git a/InventoryTraker.Web/js/utility/DateRangeQueryDirective.js b/InventoryTraker.Web/js/utility/DateRangeQueryDirective.js index ca3d230..096b7bb 100644 --- a/InventoryTraker.Web/js/utility/DateRangeQueryDirective.js +++ b/InventoryTraker.Web/js/utility/DateRangeQueryDirective.js @@ -13,6 +13,7 @@ } } + controller.$inject = ['$scope']; function controller($scope) { var vm = this; vm.query = {}; diff --git a/InventoryTraker.Web/js/utility/DownloadService.js b/InventoryTraker.Web/js/utility/DownloadService.js index f87d841..c841b64 100644 --- a/InventoryTraker.Web/js/utility/DownloadService.js +++ b/InventoryTraker.Web/js/utility/DownloadService.js @@ -1,15 +1,17 @@ -(function () { - window.app.factory('downloadSvc', - function($http) { +(function() { + window.app.factory("downloadSvc", + [ + function() { var svc = { success: function(data, status, headers, config) { - var file = new Blob([data], { type: headers('Content-Type') }); - var match = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(headers('Content-Disposition')); + var file = new Blob([data], { type: headers("Content-Type") }); + var match = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(headers("Content-Disposition")); saveAs(file, match[1]); } }; return svc; - }); + } + ]); })(); \ No newline at end of file diff --git a/InventoryTraker.Web/js/utility/ErrorList.js b/InventoryTraker.Web/js/utility/ErrorList.js index 89e2d9c..74fd1b6 100644 --- a/InventoryTraker.Web/js/utility/ErrorList.js +++ b/InventoryTraker.Web/js/utility/ErrorList.js @@ -14,6 +14,7 @@ } }); + controller.$inject = ['$scope']; function controller($scope) { var vm = this; vm.errors = $scope.errors; diff --git a/InventoryTraker.Web/js/utility/FormGroupValidationDirective.js b/InventoryTraker.Web/js/utility/FormGroupValidationDirective.js index 046f462..1f9a66d 100644 --- a/InventoryTraker.Web/js/utility/FormGroupValidationDirective.js +++ b/InventoryTraker.Web/js/utility/FormGroupValidationDirective.js @@ -23,6 +23,7 @@ } }); + controller.$inject = ['$scope']; function controller($scope) { var vm = this; diff --git a/InventoryTraker.Web/js/utility/FormatCases.js b/InventoryTraker.Web/js/utility/FormatCases.js index ad321ad..d410a2e 100644 --- a/InventoryTraker.Web/js/utility/FormatCases.js +++ b/InventoryTraker.Web/js/utility/FormatCases.js @@ -1,11 +1,13 @@ (function() { - window.app.filter('formatCases', + window.app.filter("formatCases", + [ function() { return function(qty) { - if (qty === '' || !isFinite(qty)) - return ''; + if (qty === "" || !isFinite(qty)) + return ""; - return '(' + qty + ' cs)'; - } - }); + return "(" + qty + " cs)"; + }; + } + ]); })(); \ No newline at end of file diff --git a/InventoryTraker.Web/js/utility/HideZeroFilter.js b/InventoryTraker.Web/js/utility/HideZeroFilter.js index 4caf077..9c16f42 100644 --- a/InventoryTraker.Web/js/utility/HideZeroFilter.js +++ b/InventoryTraker.Web/js/utility/HideZeroFilter.js @@ -1,9 +1,11 @@ -(function () { - window.app.filter('hideZero', +(function() { + window.app.filter("hideZero", + [ function() { return function(input) { return input > 0 ? input : ""; - } - }); + }; + } + ]); })(); \ No newline at end of file diff --git a/InventoryTraker.Web/js/utility/InputValidationIconsDirective.js b/InventoryTraker.Web/js/utility/InputValidationIconsDirective.js index 6de84e0..cd70e7b 100644 --- a/InventoryTraker.Web/js/utility/InputValidationIconsDirective.js +++ b/InventoryTraker.Web/js/utility/InputValidationIconsDirective.js @@ -21,6 +21,7 @@ } }); + controller.$inject = ['$scope']; function controller($scope) { var vm = this; diff --git a/InventoryTraker.Web/js/utility/MonthQueryDirective.js b/InventoryTraker.Web/js/utility/MonthQueryDirective.js index 247bf58..3d6b5f5 100644 --- a/InventoryTraker.Web/js/utility/MonthQueryDirective.js +++ b/InventoryTraker.Web/js/utility/MonthQueryDirective.js @@ -13,6 +13,7 @@ } }); + controller.$inject = ['$scope']; function controller($scope) { var vm = this; vm.query = {}; diff --git a/InventoryTraker.Web/js/utility/ParseDateFilter.js b/InventoryTraker.Web/js/utility/ParseDateFilter.js index 6462223..de854d0 100644 --- a/InventoryTraker.Web/js/utility/ParseDateFilter.js +++ b/InventoryTraker.Web/js/utility/ParseDateFilter.js @@ -1,10 +1,12 @@ (function() { window.app.filter("parseDate", + [ function() { return function(input) { - if (typeof input != 'string' || input.indexOf("/Date") === -1) return input; + if (typeof input != "string" || input.indexOf("/Date") === -1) return input; return new Date(parseInt(input.substr(6))); - } - }); + }; + } + ]); })(); \ No newline at end of file diff --git a/InventoryTraker.Web/js/utility/StatusMessage.js b/InventoryTraker.Web/js/utility/StatusMessage.js index 7007f03..58c442d 100644 --- a/InventoryTraker.Web/js/utility/StatusMessage.js +++ b/InventoryTraker.Web/js/utility/StatusMessage.js @@ -14,6 +14,7 @@ } }); + controller.$inject = ['$scope']; function controller($scope) { } })(); \ No newline at end of file diff --git a/InventoryTraker.Web/js/utility/ToUnits.js b/InventoryTraker.Web/js/utility/ToUnits.js index 2553d3e..fd3d0e0 100644 --- a/InventoryTraker.Web/js/utility/ToUnits.js +++ b/InventoryTraker.Web/js/utility/ToUnits.js @@ -1,12 +1,14 @@ (function() { - window.app.filter('toUnits', + window.app.filter("toUnits", + [ function() { return function(caseQty, unitsPerCase) { if (caseQty === "" || !isFinite(caseQty) || !isFinite(unitsPerCase)) return ""; return caseQty * unitsPerCase; - } - }); + }; + } + ]); })(); \ No newline at end of file