User profile editing and password

This commit is contained in:
2016-09-26 11:13:59 -04:00
parent 6789c1b3b5
commit 75b7c02979
54 changed files with 373 additions and 209 deletions
@@ -34,10 +34,6 @@
<HintPath>..\packages\AutoMapper.5.1.1\lib\net45\AutoMapper.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Heroic.AutoMapper, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Heroic.AutoMapper.2.0.0\lib\net45\Heroic.AutoMapper.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
<Private>True</Private>
@@ -1,6 +1,5 @@
using System;
using AutoMapper;
using Heroic.AutoMapper;
using InventoryTraker.Web.Core;
using InventoryTraker.Web.Models;
using NUnit.Framework;
@@ -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<ProfileForm>(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<ProfileForm>(user);
return BetterJson(model);
}
return Json(true);
[ActionLog]
public async Task<JsonResult> 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<ProfileForm>(user));
}
}
}
@@ -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());
}
@@ -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<IdentityResult> ChangePasswordAsync(User user, string newPassword)
{
var resetToken = await GeneratePasswordResetTokenAsync(user.Id);
return await ResetPasswordAsync(user.Id, resetToken, newPassword);
}
}
}
@@ -228,6 +228,8 @@
<Content Include="Global.asax" />
<Content Include="js\app.js" />
<Content Include="js\authentication\LoginController.js" />
<Content Include="js\profile\profileSvc.js" />
<Content Include="js\profile\ProfileEditDirective.js" />
<Content Include="js\user\UserCreateDirective.js" />
<Content Include="js\user\UserController.js" />
<Content Include="js\user\UserEditDirective.js" />
@@ -246,7 +248,7 @@
<Content Include="js\inventory\inventorySvc.js" />
<Content Include="js\inventory\InventoryEditDirective.js" />
<Content Include="js\inventory\InventoryDistributeDirective.js" />
<Content Include="js\profile\EditProfileController.js" />
<Content Include="js\profile\ProfileController.js" />
<Content Include="js\report\MovementReportDirective.js" />
<Content Include="js\report\MovementReportController.js" />
<Content Include="js\report\DistributionReportDirective.js" />
@@ -313,6 +315,7 @@
<Content Include="js\user\templates\userCreate.tmpl.cshtml" />
<Content Include="js\user\templates\userEdit.tmpl.cshtml" />
<Content Include="js\user\templates\userList.tmpl.cshtml" />
<Content Include="js\profile\templates\profileEdit.tmpl.cshtml" />
<None Include="NLog.xsd">
<SubType>Designer</SubType>
</None>
+24 -7
View File
@@ -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<User, ProfileForm>()
.ForMember(d => d.FullName, opt => opt.MapFrom(s => s.UserName))
.ForMember(d => d.EmailAddress, opt => opt.MapFrom(s => s.Email));
CreateMap<User, ProfileForm>();
}
}
}
+6 -31
View File
@@ -1,38 +1,13 @@
@using InventoryTraker.Web.Helpers
@model InventoryTraker.Web.Models.ProfileForm
@model InventoryTraker.Web.Models.ProfileForm
@{
ViewBag.Title = "Your Profile";
}
<h1 class="page-header">Update @ViewBag.Title</h1>
<form novalidate
name="vm.form"
ng-controller="EditProfileController as vm"
ng-submit="vm.form.$valid && vm.save()"
style="max-width: 500px;">
<fieldset ng-disabled="vm.saving">
<div class="alert alert-info" ng-show="vm.errorMessage == null && !vm.saving && !vm.success">
Make changes below.
</div>
<div class="alert alert-info" ng-show="vm.saving">
Saving changes...
</div>
<div class="alert alert-success" ng-show="vm.success">
<span class="fa fa-check"></span>
Changes saved!
</div>
<div class="alert alert-danger" ng-show="vm.errorMessage != null">
{{vm.errorMessage}}
</div>
@Html.Angular().FormForModel("vm.profile")
<div class="form-group">
<button class="btn btn-success">Save Changes</button>
<a class="btn btn-warning" href="/">Cancel</a>
</div>
</fieldset>
</form>
<div class="row" ng-controller="ProfileController as vm">
<div class="panel panel-default col-md-6">
<profile-edit profile="vm.profile"></profile-edit>
</div>
</div>
@@ -36,13 +36,13 @@
<a href="@(Html.BuildUrlFromExpression<TransactionController>(c => c.Index()))"><i class="fa fa-fw fa-list"></i> Transaction History</a>
</li>
<li>
<a href="#"><i class="fa fa-file-o"></i> Reports</a>
<a href="#"><i class="fa fa-fw fa-file-o"></i> Reports</a>
<ul>
<li>
<a href="@(Html.BuildUrlFromExpression<ReportController>(c => c.Distribution()))"><i class="fa fa-file-o"></i> Distribution</a>
<a href="@(Html.BuildUrlFromExpression<ReportController>(c => c.Distribution()))"><i class="fa fa-fw fa-file-o"></i> Distribution</a>
</li>
<li>
<a href="@(Html.BuildUrlFromExpression<ReportController>(c => c.Movement()))"><i class="fa fa-file-o"></i> Monthly Inventory</a>
<a href="@(Html.BuildUrlFromExpression<ReportController>(c => c.Movement()))"><i class="fa fa-fw fa-file-o"></i> Monthly Inventory</a>
</li>
</ul>
</li>
@@ -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;
});
}
});
}
]);
})();
@@ -11,7 +11,6 @@
});
controller.$inject = ['$scope', 'inventorySvc', 'inventoryTypeSvc'];
function controller($scope, inventorySvc, inventoryTypeSvc) {
var vm = this;
@@ -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: '<inventory-add />',
backdrop: 'static'
template: "<inventory-add />",
backdrop: "static"
});
};
vm.distribute = function() {
$uibModal.open({
template: '<inventory-distribute />',
backdrop: 'static'
template: "<inventory-distribute />",
backdrop: "static"
});
};
@@ -25,5 +27,6 @@
inventorySvc.exportInventory()
.success(downloadSvc.success);
};
});
}
]);
})();
@@ -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 });
}
});
}
]);
})();
@@ -85,7 +85,7 @@
</div>
<div class="modal-footer">
<button class="btn btn-success">Add</button>
<button class="btn btn-success" ng-disabled="vm.form.$invalid || vm.form.$pristine">Add</button>
<button type="button" class="btn" ng-click="$dismiss()">Cancel</button>
</div>
@@ -55,7 +55,7 @@
</div>
<div class="modal-footer">
<button class="btn btn-success">Save</button>
<button class="btn btn-success" ng-disabled="vm.form.$invalid || vm.form.$pristine">Save</button>
<button type="button" class="btn" ng-click="$dismiss()">Cancel</button>
</div>
@@ -15,7 +15,7 @@
<inventory-info inventory="inventory"></inventory-info>
<div class="modal-footer">
<button ng-click="vm.removeInventory()" class="btn btn-sm pull-left"><i class="fa fa-minus-circle"></i> Remove Inventory</button>
<button class="btn btn-success">Save</button>
<button class="btn btn-success" ng-disabled="vm.form.$invalid || vm.form.$pristine">Save</button>
<button type="button" class="btn" ng-click="$parent.$dismiss()">Cancel</button>
</div>
@@ -18,7 +18,7 @@
</tr>
</thead>
<tbody>
<tr ng-repeat="inventory in vm.inventories">
<tr ng-repeat="inventory in vm.inventories | filter:{name: ''}">
<td>
<a href="" ng-click="vm.edit(inventory)" title="Details"><i class="fa fa-edit"></i></a>
</td>
@@ -47,7 +47,7 @@
</div>
<div class="modal-footer">
<button class="btn btn-success">Remove</button>
<button class="btn btn-success" ng-disabled="vm.form.$invalid || vm.form.$pristine">Remove</button>
<button type="button" class="btn" ng-click="$parent.$dismiss()">Cancel</button>
</div>
@@ -10,6 +10,7 @@
};
});
controller.$inject = ['$scope', 'inventoryTypeSvc'];
function controller($scope, inventoryTypeSvc){
var vm = this;
@@ -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: '<inventory-type-add />',
backdrop: 'static'
template: "<inventory-type-add />",
backdrop: "static"
});
}
};
vm.export = function() {
inventoryTypeSvc.exportInventoryTypes()
.success(downloadSvc.success);
}
});
};
}
]);
})();
@@ -13,6 +13,7 @@
}
});
controller.$inject = ['$scope', 'inventoryTypeSvc'];
function controller($scope, inventoryTypeSvc) {
var vm = this;
vm.inventoryType = angular.copy($scope.inventoryType);
@@ -11,6 +11,7 @@
}
});
controller.$inject = ['$scope', '$uibModal'];
function controller($scope, $uibModal) {
var vm = this;
@@ -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);
});
}
});
}
]);
})();
@@ -19,7 +19,7 @@
</div>
<div class="modal-footer">
<button class="btn btn-success">Add</button>
<button class="btn btn-success" ng-disabled="vm.form.$invalid || vm.form.$pristine">Add</button>
<button type="button" class="btn" ng-click="$dismiss()">Cancel</button>
</div>
@@ -19,7 +19,7 @@
</div>
<div class="modal-footer">
<button class="btn btn-success">Save</button>
<button class="btn btn-success" ng-disabled="vm.form.$invalid || vm.form.$pristine">Save</button>
<button type="button" class="btn" ng-click="$parent.$dismiss()">Cancel</button>
</div>
@@ -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;
});
}
});
})();
@@ -0,0 +1,13 @@
(function() {
"use strict";
window.app.controller("ProfileController",
[
'$scope', 'profileSvc',
function ($scope, profileSvc) {
var vm = this;
vm.profile = profileSvc.profile;
}
]);
})();
@@ -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;
});
}
}
})();
@@ -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);
});
}
}
]);
})();
@@ -0,0 +1,28 @@
@using InventoryTraker.Web.Helpers
@model InventoryTraker.Web.Models.ProfileForm
<form novalidate
name="vm.form"
ng-submit="vm.form.$valid && vm.save()">
<fieldset ng-disabled="vm.saving">
<div class="panel">
<div class="panel-body">
<status-message message="vm.statusMessage"></status-message>
<error-list errors="vm.errorMessages"></error-list>
<div class="alert alert-success" ng-show="vm.success && vm.form.$pristine">
<span class="fa fa-check"></span>
Changes saved
</div>
@Html.Angular().FormForModel("vm.profile")
</div>
<div class="panel-footer">
<button class="btn btn-success" ng-disabled="vm.form.$invalid || vm.form.$pristine">Save</button>
<a class="btn btn-default" href="/">Cancel</a>
</div>
</div>
</fieldset>
</form>
@@ -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);
}
});
};
}
]);
})();
@@ -11,6 +11,7 @@
}
});
controller.$inject = ['$scope'];
function controller($scope) {
var vm = this;
vm.distributionData = $scope.distributionData;
@@ -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);
}
});
};
}
]);
})();
@@ -11,6 +11,7 @@
}
});
controller.$inject = ['$scope', '$uibModal', 'inventorySvc'];
function controller($scope, $uibModal, inventorySvc) {
var vm = this;
vm.movementData = $scope.movementData;
+10 -7
View File
@@ -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" });
}
});
}
]);
})();
@@ -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: '<div class="ui-grid-cell-contents" ' +
'title="{{row.entity.name}}' +
'\r{{row.entity.unitsPerCase}} / {{row.entity.containerType}}' +
'\rExp Date: {{row.entity.expirationDate | date:\'shortDate\'}}' +
"\r{{row.entity.unitsPerCase}} / {{row.entity.containerType}}" +
"\rExp Date: {{row.entity.expirationDate | date:'shortDate'}}" +
'\rAdd Date: {{row.entity.addedDate | date:\'shortDate\'}}">' +
'<a href="" ng-click="grid.appScope.editInventory(row.entity.inventoryId)"><i class="fa fa-edit"></i></a> ' +
'{{row.entity.name}}</div>',
"{{row.entity.name}}</div>",
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();
});
});
}
});
};
}
]);
})();
@@ -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);
});
}
});
}]);
})();
+13 -12
View File
@@ -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: '<user-create />',
backdrop: 'static'
template: "<user-create />",
backdrop: "static"
});
}
};
vm.edit = function() {
$uibModal.open({
template: '<user-edit />',
backdrop: 'static'
template: "<user-edit />",
backdrop: "static"
});
}
};
vm.export = function() {
userSvc.exportUsers()
.success(downloadSvc.success);
}
});
};
}
]);
})();
@@ -9,6 +9,7 @@
}
});
controller.$inject = ['$scope', 'userSvc'];
function controller($scope, userSvc){
var vm = this;
@@ -12,6 +12,7 @@
}
});
controller.$inject = ['$scope', 'userSvc'];
function controller($scope, userSvc) {
var vm = this;
vm.user = angular.copy($scope.user);
@@ -19,7 +19,7 @@
</div>
<div class="modal-footer">
<button class="btn btn-success">Create</button>
<button class="btn btn-success" ng-disabled="vm.form.$invalid || vm.form.$pristine">Create</button>
<button type="button" class="btn" ng-click="$dismiss()">Cancel</button>
</div>
@@ -19,7 +19,7 @@
</div>
<div class="modal-footer">
<button class="btn btn-success">Save</button>
<button class="btn btn-success" ng-disabled="vm.form.$invalid || vm.form.$pristine">Save</button>
<button type="button" class="btn" ng-click="$parent.$dismiss()">Cancel</button>
</div>
+10 -7
View File
@@ -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);
});
}
});
}
]);
})();
@@ -13,6 +13,7 @@
}
}
controller.$inject = ['$scope'];
function controller($scope) {
var vm = this;
vm.query = {};
@@ -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;
});
}
]);
})();
@@ -14,6 +14,7 @@
}
});
controller.$inject = ['$scope'];
function controller($scope) {
var vm = this;
vm.errors = $scope.errors;
@@ -23,6 +23,7 @@
}
});
controller.$inject = ['$scope'];
function controller($scope) {
var vm = this;
@@ -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)";
};
}
]);
})();
@@ -1,9 +1,11 @@
(function () {
window.app.filter('hideZero',
(function() {
window.app.filter("hideZero",
[
function() {
return function(input) {
return input > 0 ? input : "";
}
});
};
}
]);
})();
@@ -21,6 +21,7 @@
}
});
controller.$inject = ['$scope'];
function controller($scope) {
var vm = this;
@@ -13,6 +13,7 @@
}
});
controller.$inject = ['$scope'];
function controller($scope) {
var vm = this;
vm.query = {};
@@ -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)));
}
});
};
}
]);
})();
@@ -14,6 +14,7 @@
}
});
controller.$inject = ['$scope'];
function controller($scope) {
}
})();
+5 -3
View File
@@ -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;
}
});
};
}
]);
})();