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
@@ -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;
}
});
};
}
]);
})();