Add user management

This commit is contained in:
2016-09-23 15:12:46 -04:00
parent 9f50a4635c
commit 0b5dde065a
53 changed files with 1046 additions and 690 deletions
@@ -1,30 +1,28 @@
(function () {
'use strict';
window.app.controller('LoginController', LoginController);
LoginController.$inject = ['$window', '$http'];
function LoginController($window, $http) {
var vm = this;
vm.errorMessage = null;
vm.loggingIn = false;
vm.login = login;
function login() {
vm.loggingIn = true;
window.app.controller('LoginController',
function($window, $http) {
var vm = this;
vm.errorMessage = null;
vm.loggingIn = false;
vm.login = login;
$http.post("/Authentication/Login", { emailAddress: vm.emailAddress, password: vm.password })
.success(function() {
$window.location.href = "/";
})
.error(function(data) {
vm.errorMessage = "There was a problem logging in: " + data;
})
.finally(function() {
vm.loggingIn = false;
});
}
}
function login() {
vm.loggingIn = true;
vm.errorMessage = null;
$http.post("/Authentication/Login", { emailAddress: vm.emailAddress, password: vm.password })
.success(function() {
$window.location.href = "/";
})
.error(function(data) {
vm.errorMessage = "There was a problem logging in: " + data;
})
.finally(function() {
vm.loggingIn = false;
});
}
});
})();
@@ -1,15 +1,14 @@
(function() {
"use strict";
window.app.directive('inventoryAdd', inventoryAdd);
function inventoryAdd() {
return {
templateUrl: '/inventory/template/inventoryAdd.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
window.app.directive('inventoryAdd',
function() {
return {
templateUrl: '/inventory/template/inventoryAdd.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
});
controller.$inject = ['$scope', 'inventorySvc', 'inventoryTypeSvc'];
@@ -1,15 +1,14 @@
(function() {
"use strict";
window.app.directive('inventoryDistribute', inventoryDistribute);
function inventoryDistribute() {
return {
templateUrl: '/inventory/template/inventoryDistribute.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
window.app.directive('inventoryDistribute',
function() {
return {
templateUrl: '/inventory/template/inventoryDistribute.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
});
controller.$inject = ['$scope', 'inventorySvc'];
function controller($scope, inventorySvc) {
@@ -1,18 +1,17 @@
(function() {
"use strict";
window.app.directive('editInventory', editInventory);
function editInventory() {
return {
scope: {
inventory: "="
},
templateUrl: '/inventory/template/inventoryEdit.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
window.app.directive('editInventory',
function() {
return {
scope: {
inventory: "="
},
templateUrl: '/inventory/template/inventoryEdit.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
});
controller.$inject = ['$scope', '$uibModal', 'inventorySvc', 'transactionSvc'];
function controller($scope, $uibModal, inventorySvc, transactionSvc) {
@@ -1,33 +1,29 @@
(function() {
'use strict';
window.app.controller('InventoryListController', InventoryListController);
window.app.controller('InventoryListController',
function($uibModal, inventorySvc, downloadSvc) {
var vm = this;
InventoryListController.$inject = ['$uibModal', 'inventorySvc', 'downloadSvc'];
function InventoryListController($uibModal, inventorySvc, downloadSvc) {
var vm = this;
vm.inventories = inventorySvc.inventories;
vm.add = add;
vm.distribute = distribute;
vm.inventories = inventorySvc.inventories;
function add() {
$uibModal.open({
template: '<inventory-add />',
backdrop: 'static'
});
}
vm.add = function() {
$uibModal.open({
template: '<inventory-add />',
backdrop: 'static'
});
};
function distribute() {
$uibModal.open({
template: '<inventory-distribute />',
backdrop: 'static'
});
}
vm.distribute = function() {
$uibModal.open({
template: '<inventory-distribute />',
backdrop: 'static'
});
};
vm.export = function () {
inventorySvc.exportInventory()
.success(downloadSvc.success);
}
}
vm.export = function() {
inventorySvc.exportInventory()
.success(downloadSvc.success);
};
});
})();
@@ -1,15 +1,15 @@
(function() {
'use strict';
window.app.directive('inventoryList', inventoryList);
function inventoryList() {
return {
scope: {"inventories" : "="},
templateUrl: '/inventory/template/inventoryList.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
window.app.directive('inventoryList',
function () {
return {
scope: {"inventories" : "="},
templateUrl: '/inventory/template/inventoryList.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
});
controller.$inject = ['$scope', '$uibModal'];
function controller($scope, $uibModal) {
@@ -1,16 +1,15 @@
(function() {
"use strict";
window.app.directive('inventoryInfo', inventoryInfo);
function inventoryInfo() {
return {
scope: { "inventory": "=" },
templateUrl: '/inventory/template/inventoryInfo.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
window.app.directive('inventoryInfo',
function() {
return {
scope: { "inventory": "=" },
templateUrl: '/inventory/template/inventoryInfo.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
});
controller.$inject = ['$scope'];
function controller($scope) {
@@ -1,16 +1,15 @@
(function() {
"use strict";
window.app.directive('inventoryRemove', inventoryRemove);
function inventoryRemove() {
return {
scope: { "inventory": "=" },
templateUrl: '/inventory/template/inventoryRemove.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
window.app.directive('inventoryRemove',
function() {
return {
scope: { "inventory": "=" },
templateUrl: '/inventory/template/inventoryRemove.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
});
controller.$inject = ['$scope', 'inventorySvc'];
function controller($scope, inventorySvc) {
@@ -1,87 +1,85 @@
(function() {
window.app.factory('inventorySvc', inventorySvc);
window.app.factory('inventorySvc',
function($http, $filter) {
var inventories = [];
inventorySvc.$inject = ['$http', '$filter'];
function inventorySvc($http, $filter) {
var inventories = [];
loadInventories();
loadInventories();
var svc = {
add: add,
distribute: distribute,
update: update,
remove: remove,
inventories: inventories,
get: get,
refresh: refresh,
find: find,
exportInventory: exportInventory
};
var svc = {
add: add,
distribute: distribute,
update: update,
remove: remove,
inventories: inventories,
get: get,
refresh: refresh,
find: find,
exportInventory: exportInventory
};
return svc;
return svc;
function loadInventories() {
$http.post('/Inventory/All')
.success(function(data) {
angular.copy(data, inventories);
});
}
function exportInventory() {
return $http.post('/Inventory/Export', {}, { responseType: 'arraybuffer' });
}
function add(inventory) {
return $http.post('/Inventory/Add', inventory)
.success(function(inventory) {
inventories.unshift(inventory);
});
}
function 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)
.success(function(inventory) {
angular.extend(existingInventory, inventory);
});
}
// remove quantity from this inventory
function remove(removeForm) {
var existingInventory = get(removeForm.inventoryId);
return $http.post('/Inventory/Remove', removeForm)
.success(function(data) {
angular.copy(data, existingInventory);
});
}
function get(id) {
var results = $filter('filter')(inventories, { id: id });
if (results.length > 0)
return results[0];
return null;
}
// refresh this inventory from the server
function refresh(id) {
var existingInventory = get(id);
if (existingInventory) {
find(id)
.success(function(inventory) {
angular.copy(inventory, existingInventory);
function loadInventories() {
$http.post('/Inventory/All')
.success(function(data) {
angular.copy(data, inventories);
});
}
}
function find(id) {
return $http.post('/Inventory/Find', { id: id });
}
}
function exportInventory() {
return $http.post('/Inventory/Export', {}, { responseType: 'arraybuffer' });
}
function add(inventory) {
return $http.post('/Inventory/Add', inventory)
.success(function(inventory) {
inventories.unshift(inventory);
});
}
function 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)
.success(function(inventory) {
angular.extend(existingInventory, inventory);
});
}
// remove quantity from this inventory
function remove(removeForm) {
var existingInventory = get(removeForm.inventoryId);
return $http.post('/Inventory/Remove', removeForm)
.success(function(data) {
angular.copy(data, existingInventory);
});
}
function get(id) {
var results = $filter('filter')(inventories, { id: id });
if (results.length > 0)
return results[0];
return null;
}
// refresh this inventory from the server
function refresh(id) {
var existingInventory = get(id);
if (existingInventory) {
find(id)
.success(function(inventory) {
angular.copy(inventory, existingInventory);
});
}
}
function find(id) {
return $http.post('/Inventory/Find', { id: id });
}
});
})();
@@ -1,17 +1,15 @@
(function() {
"use strict";
window.app.directive('inventoryTypeAdd', inventoryTypeAdd);
window.app.directive("inventoryTypeAdd",
function() {
return {
templateUrl: "/inventoryType/template/inventoryTypeAdd.tmpl.cshtml",
controller: controller,
controllerAs: "vm"
};
});
function inventoryTypeAdd() {
return {
templateUrl: '/inventoryType/template/inventoryTypeAdd.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
controller.$inject = ['$scope', 'inventoryTypeSvc'];
function controller($scope, inventoryTypeSvc){
var vm = this;
@@ -1,33 +1,22 @@
(function() {
'use strict';
window.app.controller('InventoryTypeController', InventoryTypeController);
window.app.controller('InventoryTypeController',
function($uibModal, inventoryTypeSvc, downloadSvc) {
var vm = this;
InventoryTypeController.$inject = ['$uibModal', 'inventoryTypeSvc', 'downloadSvc'];
function InventoryTypeController($uibModal, inventoryTypeSvc, downloadSvc) {
var vm = this;
vm.inventoryTypes = inventoryTypeSvc.inventoryTypes;
vm.add = add;
vm.edit = edit;
vm.inventoryTypes = inventoryTypeSvc.inventoryTypes;
vm.add = function() {
$uibModal.open({
template: '<inventory-type-add />',
backdrop: 'static'
});
}
function add() {
$uibModal.open({
template: '<inventory-type-add />',
backdrop: 'static'
});
}
function edit() {
$uibModal.open({
template: '<inventory-type-edit />',
backdrop: 'static'
});
}
vm.export = function () {
inventoryTypeSvc.exportInventoryTypes()
.success(downloadSvc.success);
}
}
vm.export = function() {
inventoryTypeSvc.exportInventoryTypes()
.success(downloadSvc.success);
}
});
})();
@@ -1,20 +1,18 @@
(function() {
"use strict";
window.app.directive('editInventoryType', editInventory);
window.app.directive('editInventoryType',
function() {
return {
scope: {
inventoryType: "="
},
templateUrl: '/inventoryType/template/inventoryTypeEdit.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
});
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);
@@ -1,28 +1,26 @@
(function() {
'use strict';
window.app.directive('inventoryTypeList', inventoryTypeList);
function inventoryTypeList() {
return {
scope: { "inventoryTypes": "=" },
templateUrl: '/inventoryType/template/inventoryTypeList.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
window.app.directive('inventoryTypeList',
function() {
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) {
vm.edit = function(inventoryType) {
$uibModal.open({
template: '<edit-inventory-type inventory-type="inventoryType" />',
scope: angular.extend($scope.$new(true), { inventoryType: inventoryType })
});
}
};
}
})();
@@ -1,44 +1,42 @@
(function () {
window.app.factory('inventoryTypeSvc', inventoryTypeSvc);
window.app.factory('inventoryTypeSvc',
function($http) {
var inventoryTypes = [];
inventoryTypeSvc.$inject = ['$http'];
function inventoryTypeSvc($http) {
var inventoryTypes = [];
loadInventoryTypes();
loadInventoryTypes();
var svc = {
add: add,
update: update,
inventoryTypes: inventoryTypes,
exportInventoryTypes: exportInventoryTypes
};
var svc = {
add: add,
update: update,
inventoryTypes: inventoryTypes,
exportInventoryTypes: exportInventoryTypes
};
return svc;
return svc;
function loadInventoryTypes() {
$http.post('/InventoryType/All')
.success(function(data) {
inventoryTypes.addRange(data);
});
}
function loadInventoryTypes() {
$http.post('/InventoryType/All')
.success(function (data) {
inventoryTypes.addRange(data);
});
}
function exportInventoryTypes() {
return $http.post('/InventoryType/Export', {}, { responseType: 'arraybuffer' });
}
function exportInventoryTypes() {
return $http.post('/InventoryType/Export', {}, { responseType: 'arraybuffer' });
}
function add(inventoryType) {
return $http.post('/InventoryType/Add', inventoryType)
.success(function(inventoryType) {
inventoryTypes.unshift(inventoryType);
});
}
function add(inventoryType) {
return $http.post('/InventoryType/Add', inventoryType)
.success(function (inventoryType) {
inventoryTypes.unshift(inventoryType);
});
}
function update(existingInventoryType, updatedInventoryType) {
return $http.post('/InventoryType/Update', updatedInventoryType)
.success(function (inventoryType) {
angular.extend(existingInventoryType, inventoryType);
});
}
}
function update(existingInventoryType, updatedInventoryType) {
return $http.post('/InventoryType/Update', updatedInventoryType)
.success(function(inventoryType) {
angular.extend(existingInventoryType, inventoryType);
});
}
});
})();
@@ -1,30 +1,28 @@
(function() {
'use strict';
window.app.controller('EditProfileController', EditProfileController);
window.app.controller('EditProfileController',
function($http, editProfileConfig, model) {
var vm = this;
EditProfileController.$inject = ['$http', 'editProfileConfig', 'model'];
function EditProfileController($http, editProfileConfig, model) {
var vm = this;
vm.profile = model;
vm.save = save;
vm.profile = model;
vm.save = save;
function save() {
vm.saving = true;
vm.errorMessage = null;
vm.success = false;
function save() {
vm.saving = true;
vm.errorMessage = null;
vm.success = false;
$http.post(editProfileConfig.saveUrl, vm.profile)
.success(function() {
vm.success = true;
})
.error(function(msg) {
vm.errorMessage = msg;
})
.finally(function() {
vm.saving = false;
});
}
}
$http.post(editProfileConfig.saveUrl, vm.profile)
.success(function() {
vm.success = true;
})
.error(function(msg) {
vm.errorMessage = msg;
})
.finally(function() {
vm.saving = false;
});
}
});
})();
@@ -1,17 +1,15 @@
(function () {
'use strict';
window.app.controller('DistributionReportController', DistributionReportController);
DistributionReportController.$inject = ['$scope', 'reportSvc', 'downloadSvc'];
function DistributionReportController($scope, reportSvc, downloadSvc) {
var vm = this;
vm.loadData = reportSvc.loadDistributionReport;
vm.query = reportSvc.distributionQuery;
vm.distributionData = reportSvc.distributionData;
vm.export = function (params) {
reportSvc.exportDistributionReport(params)
.success(downloadSvc.success);
}
}
window.app.controller('DistributionReportController',
function($scope, reportSvc, downloadSvc) {
var vm = this;
vm.loadData = reportSvc.loadDistributionReport;
vm.query = reportSvc.distributionQuery;
vm.distributionData = reportSvc.distributionData;
vm.export = function(params) {
reportSvc.exportDistributionReport(params)
.success(downloadSvc.success);
}
});
})();
@@ -1,17 +1,16 @@
(function() {
'use strict';
window.app.directive('distributionReport', distributionReport);
function distributionReport() {
return {
scope: {distributionData: "="},
templateUrl: '/report/template/distributionReport.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
window.app.directive('distributionReport',
function () {
return {
scope: {distributionData: "="},
templateUrl: '/report/template/distributionReport.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
});
controller.$inject = ['$scope'];
function controller($scope) {
var vm = this;
vm.distributionData = $scope.distributionData;
@@ -1,16 +1,14 @@
(function () {
'use strict';
window.app.controller('MovementReportController', MovementReportController);
MovementReportController.$inject = ['$scope', 'reportSvc', 'downloadSvc'];
function MovementReportController($scope, reportSvc, downloadSvc) {
var vm = this;
vm.loadData = reportSvc.loadMovementData;
vm.movementData = reportSvc.movementData;
vm.export = function(month) {
reportSvc.exportMovementData({month: month})
.success(downloadSvc.success);
}
}
window.app.controller('MovementReportController',
function($scope, reportSvc, downloadSvc) {
var vm = this;
vm.loadData = reportSvc.loadMovementData;
vm.movementData = reportSvc.movementData;
vm.export = function(month) {
reportSvc.exportMovementData({ month: month })
.success(downloadSvc.success);
}
});
})();
@@ -1,17 +1,16 @@
(function() {
'use strict';
window.app.directive('movementReport', movementReport);
function movementReport() {
return {
scope: { movementData: "=" },
templateUrl: '/report/template/movementReport.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
window.app.directive('movementReport',
function() {
return {
scope: { movementData: "=" },
templateUrl: '/report/template/movementReport.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
});
controller.$inject = ['$scope', '$uibModal', 'inventorySvc'];
function controller($scope, $uibModal, inventorySvc) {
var vm = this;
vm.movementData = $scope.movementData;
+35 -37
View File
@@ -1,45 +1,43 @@
(function () {
window.app.factory('reportSvc', reportSvc);
window.app.factory('reportSvc',
function($http) {
var distributionData = [];
var distributionQuery = {};
var movementData = {};
reportSvc.$inject = ['$http'];
function reportSvc($http) {
var distributionData = [];
var distributionQuery = {};
var movementData = {};
var svc = {
distributionData: distributionData,
distributionQuery: distributionQuery,
loadDistributionReport: loadDistributionReport,
exportDistributionReport: exportDistributionReport,
movementData: movementData,
loadMovementData: loadMovementData,
exportMovementData: exportMovementData
};
var svc = {
distributionData: distributionData,
distributionQuery: distributionQuery,
loadDistributionReport: loadDistributionReport,
exportDistributionReport: exportDistributionReport,
movementData: movementData,
loadMovementData: loadMovementData,
exportMovementData: exportMovementData
};
return svc;
return svc;
function loadDistributionReport(query) {
return $http.post('/Report/Distribution', query)
.success(function(data) {
distributionQuery = angular.copy(query, distributionQuery);
angular.copy(data, distributionData);
});
}
function loadDistributionReport(query) {
return $http.post('/Report/Distribution', query)
.success(function (data) {
distributionQuery = angular.copy(query, distributionQuery);
angular.copy(data, distributionData);
});
}
function exportDistributionReport(query) {
return $http.post('/Report/DistributionExcel', query, { responseType: 'arraybuffer' });
}
function exportDistributionReport(query) {
return $http.post('/Report/DistributionExcel', query, { responseType: 'arraybuffer' });
}
function loadMovementData(query) {
return $http.post('/Report/Movement', query)
.success(function(data) {
angular.copy(data, movementData);
});
}
function loadMovementData(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' });
}
}
function exportMovementData(query) {
return $http.post('/Report/MovementExcel', query, { responseType: 'arraybuffer' });
}
});
})();
@@ -1,82 +1,81 @@
(function() {
'use strict';
window.app.controller('TransactionController', TransactionController);
window.app.controller('TransactionController',
function($scope, $uibModal, transactionSvc, inventorySvc, uiGridConstants) {
var vm = this;
TransactionController.$inject = ['$scope', '$uibModal', 'transactionSvc', 'inventorySvc', 'uiGridConstants'];
function TransactionController($scope, $uibModal, transactionSvc, inventorySvc, uiGridConstants) {
var vm = this;
var paginationOptions = {
pageNumber: 1,
pageSize: 20,
pageSizes: [20, 50, 100],
sort: null
};
var paginationOptions = {
pageNumber: 1,
pageSize: 20,
pageSizes: [20,50,100],
sort: null
};
vm.gridOptions = {
enablePaginationControls: true,
paginationPageSize: paginationOptions.pageSize,
paginationPageSizes: paginationOptions.pageSizes,
useExternalPagination: true,
enableSorting: false,
columnDefs: [
{
field: 'name',
cellTooltip: function(row) {
return row.entity.name + "\r" + row.entity.unitsPerCase + " / " + row.entity.containerType;
vm.gridOptions = {
enablePaginationControls: true,
paginationPageSize: paginationOptions.pageSize,
paginationPageSizes: paginationOptions.pageSizes,
useExternalPagination: true,
enableSorting: false,
columnDefs: [
{
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\'}}' +
'\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>',
width: "20%"
},
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\'}}' +
'\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>',
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 }
],
onRegisterApi: function(gridApi) {
vm.gridApi = gridApi;
vm.gridApi.pagination
.on.paginationChanged($scope, function(pageNumber, pageSize) {
paginationOptions.pageNumber = pageNumber;
paginationOptions.pageSize = pageSize;
updateData();
{ 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;
vm.gridApi.pagination
.on.paginationChanged($scope,
function(pageNumber, pageSize) {
paginationOptions.pageNumber = pageNumber;
paginationOptions.pageSize = pageSize;
updateData();
});
}
};
function updateData() {
transactionSvc
.filterByPage(paginationOptions.pageNumber, paginationOptions.pageSize)
.success(function(data) {
vm.gridOptions.data = data.transactions;
vm.gridOptions.totalItems = data.totalItems;
});
}
};
function updateData() {
transactionSvc
.filterByPage(paginationOptions.pageNumber, paginationOptions.pageSize)
.success(function (data) {
vm.gridOptions.data = data.transactions;
vm.gridOptions.totalItems = data.totalItems;
});
}
updateData();
updateData();
$scope.editInventory = function (inventoryId) {
inventorySvc.find(inventoryId)
.success(function(inventory) {
$uibModal.open({
template: '<edit-inventory inventory="inventory" />',
scope: angular.extend($scope.$new(true), { inventory: inventory })
})
.closed.then(function() {
updateData();
});
});
}
}
$scope.editInventory = function(inventoryId) {
inventorySvc.find(inventoryId)
.success(function(inventory) {
$uibModal.open({
template: '<edit-inventory inventory="inventory" />',
scope: angular.extend($scope.$new(true), { inventory: inventory })
})
.closed.then(function() {
updateData();
});
});
}
});
})();
@@ -1,37 +1,35 @@
(function() {
window.app.factory('transactionSvc', transactionSvc);
window.app.factory('transactionSvc',
function($http, inventorySvc) {
transactionSvc.$inject = ['$http', 'inventorySvc'];
function transactionSvc($http, inventorySvc) {
var svc = {
filterByPage: filterByPage,
filterByInventoryId: filterByInventoryId,
deleteTransaction: deleteTransaction
};
var svc = {
filterByPage: filterByPage,
filterByInventoryId: filterByInventoryId,
deleteTransaction: deleteTransaction
};
return svc;
return svc;
function filterByPage(pageNumber, pageSize) {
return getTransactions({ pageNumber: pageNumber, pageSize: pageSize });
}
function filterByPage(pageNumber, pageSize) {
return getTransactions({ pageNumber: pageNumber, pageSize: pageSize });
}
function filterByInventoryId(inventoryId) {
return getTransactions({ inventoryId: inventoryId });
}
function filterByInventoryId(inventoryId) {
return getTransactions({ inventoryId: inventoryId });
}
function getTransactions(params) {
var url = '/Transaction/Get';
return $http.post(url, params)
.success(function (data) {
});
}
function getTransactions(params) {
var url = '/Transaction/Get';
return $http.post(url, params)
.success(function(data) {
});
}
function deleteTransaction(transactionId) {
return $http.post('/Transaction/Delete', { transactionId: transactionId })
.success(function (data) {
inventorySvc.refresh(data.inventoryId);
});
}
}
function deleteTransaction(transactionId) {
return $http.post('/Transaction/Delete', { transactionId: transactionId })
.success(function(data) {
inventorySvc.refresh(data.inventoryId);
});
}
});
})();
@@ -0,0 +1,29 @@
(function() {
'use strict';
window.app.controller('UserController',
function($uibModal, userSvc, downloadSvc) {
var vm = this;
vm.users = userSvc.users;
vm.create = function() {
$uibModal.open({
template: '<user-create />',
backdrop: 'static'
});
}
vm.edit = function() {
$uibModal.open({
template: '<user-edit />',
backdrop: 'static'
});
}
vm.export = function() {
userSvc.exportUsers()
.success(downloadSvc.success);
}
});
})();
@@ -0,0 +1,37 @@
(function() {
"use strict";
window.app.directive('userCreate', function() {
return {
templateUrl: '/user/template/userCreate.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
});
function controller($scope, userSvc){
var vm = this;
vm.saving = false;
vm.user = {};
vm.statusMessage = "Create a user";
vm.errorMessages = [];
vm.create = function() {
vm.statusMessage = null;
vm.saving = true;
userSvc.create(vm.user)
.success(function() {
//Close the modal
$scope.$close();
})
.error(function(data) {
vm.errorMessages = angular.copy(data.errorMessages, vm.errorMessages);
})
.finally(function() {
vm.saving = false;
});
};
}
})();
@@ -0,0 +1,42 @@
(function() {
"use strict";
window.app.directive('userEdit', function (){
return {
scope: {
user: "="
},
templateUrl: '/user/template/userEdit.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
});
function controller($scope, userSvc) {
var vm = this;
vm.user = angular.copy($scope.user);
vm.save = save;
vm.saving = false;
vm.userSvc = userSvc;
vm.statusMessage = "Edit this user";
vm.errorMessages = [];
function save() {
vm.statusMessage = null;
vm.saving = true;
userSvc.edit($scope.user, vm.user)
.success(function () {
//Close the modal
$scope.$parent.$close();
})
.error(function(data) {
vm.errorMessages = angular.copy(data.errorMessages, vm.errorMessages);
})
.finally(function() {
vm.saving = false;
});
}
}
})();
@@ -0,0 +1,27 @@
(function() {
'use strict';
window.app.directive('userList', function () {
return {
scope: { "users": "=" },
templateUrl: '/user/template/userList.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
});
controller.$inject = ['$scope', '$uibModal'];
function controller($scope, $uibModal) {
var vm = this;
vm.users = $scope.users;
vm.edit = edit;
function edit(user) {
$uibModal.open({
template: '<user-edit user="user" />',
scope: angular.extend($scope.$new(true), { user: user })
});
}
}
})();
@@ -0,0 +1,27 @@
@using InventoryTraker.Web.Helpers
@model InventoryTraker.Web.Models.UserEditForm
<form novalidate
name="vm.form"
ng-submit="vm.form.$valid && vm.create()">
<fieldset ng-disabled="vm.saving">
<div class="modal-header">
<h3 class="modal-title"><i class="fa fa-user"></i> Create User</h3>
</div>
<div class="modal-body">
<status-message message="vm.statusMessage"></status-message>
<error-list errors="vm.errorMessages"></error-list>
@Html.Angular().FormForModel("vm.user")
</div>
<div class="modal-footer">
<button class="btn btn-success">Create</button>
<button type="button" class="btn" ng-click="$dismiss()">Cancel</button>
</div>
</fieldset>
</form>
@@ -0,0 +1,27 @@
@using InventoryTraker.Web.Helpers
@model InventoryTraker.Web.Models.UserEditForm
<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-user"></i> Edit User</h3>
</div>
<div class="modal-body">
<status-message message="vm.statusMessage"></status-message>
<error-list errors="vm.errorMessages"></error-list>
@Html.Angular().FormForModel("vm.user")
</div>
<div class="modal-footer">
<button class="btn btn-success">Save</button>
<button type="button" class="btn" ng-click="$parent.$dismiss()">Cancel</button>
</div>
</fieldset>
</form>
@@ -0,0 +1,16 @@
<table class="table table-striped">
<thead>
<tr>
<th class="control-column"></th>
<th>Name</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="user in vm.users | orderBy:'name'">
<td><a href="" ng-click="vm.edit(user)"><i class="fa fa-edit"></i></a></td>
<td>{{user.userName}}</td>
<td>{{user.email}}</td>
</tr>
</tbody>
</table>
+42
View File
@@ -0,0 +1,42 @@
(function () {
window.app.factory('userSvc',
function($http) {
var users = [];
loadUsers();
var svc = {
create: create,
edit: edit,
users: users,
exportusers: exportusers
};
return svc;
function loadUsers() {
$http.post('/User/All')
.success(function(data) {
users.addRange(data);
});
}
function exportusers() {
return $http.post('/User/Export', {}, { responseType: 'arraybuffer' });
}
function create(user) {
return $http.post('/User/Create', user)
.success(function(user) {
users.unshift(user);
});
}
function edit(existingUser, editedUser) {
return $http.post('/User/Edit', editedUser)
.success(function(user) {
angular.copy(user, existingUser);
});
}
});
})();
@@ -13,7 +13,6 @@
}
}
controller.$inject = ['$scope'];
function controller($scope) {
var vm = this;
vm.query = {};
@@ -1,17 +1,15 @@
(function () {
window.app.factory('downloadSvc', downloadSvc);
window.app.factory('downloadSvc',
function($http) {
downloadSvc.$inject = ['$http'];
function downloadSvc($http) {
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'));
saveAs(file, match[1]);
}
};
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'));
saveAs(file, match[1]);
}
};
return svc;
}
return svc;
});
})();
+12 -13
View File
@@ -1,20 +1,19 @@
(function() {
'use strict';
window.app.directive('errorList', errorList);
function errorList() {
return {
scope: {
errors: "=",
editMsg: "="
},
templateUrl: '/utility/template/errorList.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
window.app.directive('errorList',
function() {
return {
scope: {
errors: "=",
editMsg: "="
},
templateUrl: '/utility/template/errorList.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
});
controller.$inject = ['$scope'];
function controller($scope) {
var vm = this;
vm.errors = $scope.errors;
@@ -1,30 +1,28 @@
(function () {
'use strict';
window.app.directive('formGroupValidation', formGroupValidation);
function formGroupValidation() {
return {
require: '^form',
replace: true,
transclude: true,
template:
'<div class="has-feedback" ng-class="vm.getValidationClass()">' +
'<ng-transclude></ng-transclude>' +
//'<input-validation-icons field="vm.field"></input-validation-icons>' +
'</div>',
scope: {
field: '@formGroupValidation'
},
controller: controller,
controllerAs: 'vm',
link: function (scope, element, attrs, formCtrl) {
scope.form = formCtrl;
window.app.directive('formGroupValidation',
function() {
return {
require: '^form',
replace: true,
transclude: true,
template:
'<div class="has-feedback" ng-class="vm.getValidationClass()">' +
'<ng-transclude></ng-transclude>' +
//'<input-validation-icons field="vm.field"></input-validation-icons>' +
'</div>',
scope: {
field: '@formGroupValidation'
},
controller: controller,
controllerAs: 'vm',
link: function(scope, element, attrs, formCtrl) {
scope.form = formCtrl;
}
}
}
}
});
controller.$inject = ['$scope'];
function controller($scope) {
var vm = this;
@@ -1,12 +1,11 @@
(function() {
window.app.filter('formatCases', formatCases);
window.app.filter('formatCases',
function() {
return function(qty) {
if (qty === '' || !isFinite(qty))
return '';
function formatCases() {
return function (qty) {
if (qty === '' || !isFinite(qty))
return '';
return '(' + qty + ' cs)';
}
}
return '(' + qty + ' cs)';
}
});
})();
@@ -1,10 +1,9 @@
(function () {
window.app.filter('hideZero', hideZero);
window.app.filter('hideZero',
function() {
return function(input) {
function hideZero() {
return function (input) {
return input > 0 ? input : '';
}
}
return input > 0 ? input : "";
}
});
})();
@@ -1,28 +1,26 @@
(function () {
'use strict';
window.app.directive('inputValidationIcons', inputValidationIcons);
function inputValidationIcons() {
return {
require: '^form',
scope: {
field: '='
},
template:
'<span ng-show="vm.canBeValidated() && vm.isValid()" ' +
'class="fa fa-2x fa-check-square form-control-feedback"></span>' +
'<span ng-show="vm.canBeValidated() && !vm.isValid()" ' +
'class="fa fa-2x fa-exclamation-triangle form-control-feedback"></span>',
controller: controller,
controllerAs: 'vm',
link: function (scope, element, attrs, formCtrl) {
scope.form = formCtrl;
window.app.directive('inputValidationIcons',
function() {
return {
require: '^form',
scope: {
field: '='
},
template:
'<span ng-show="vm.canBeValidated() && vm.isValid()" ' +
'class="fa fa-2x fa-check-square form-control-feedback"></span>' +
'<span ng-show="vm.canBeValidated() && !vm.isValid()" ' +
'class="fa fa-2x fa-exclamation-triangle form-control-feedback"></span>',
controller: controller,
controllerAs: 'vm',
link: function(scope, element, attrs, formCtrl) {
scope.form = formCtrl;
}
}
}
}
});
controller.$inject = ['$scope'];
function controller($scope) {
var vm = this;
@@ -1,35 +1,34 @@
(function() {
'use strict';
window.app.directive('monthQuery', monthQuery);
function monthQuery() {
return {
scope: {
queryFn: '='
},
templateUrl: '/utility/template/monthQuery.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
window.app.directive('monthQuery',
function() {
return {
scope: {
queryFn: '='
},
templateUrl: '/utility/template/monthQuery.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
});
controller.$inject = ['$scope'];
function controller($scope) {
var vm = this;
vm.query = {};
vm.submitting = false;
vm.errorMessages = [];
vm.submit = submit;
function submit() {
vm.submitting = true;
$scope.queryFn({ month: vm.query })
.error(function (data) {
vm.errorMessages = angular.copy(data.errorMessages, vm.errorMessages);
})
.finally(function () {
vm.submitting = false;
});
}
vm.submit =
function() {
vm.submitting = true;
$scope.queryFn({ month: vm.query })
.error(function(data) {
vm.errorMessages
= angular.copy(data.errorMessages, vm.errorMessages);
})
.finally(function() {
vm.submitting = false;
});
};
}
})();
@@ -1,46 +0,0 @@
(function () {
window.app.directive('mvcGrid', mvcGrid);
function mvcGrid() {
return {
scope: {
gridDataUrl: '@',
title: '@',
columns: '@?'
},
template:
'<div>' +
'<h4><i class="fa fa-pie-chart fa-fw"></i> {{vm.title}}</h4>' +
'<div>' +
'<p ng-if="vm.loading">Loading...</p>' +
'<div ng-if="!vm.loading" ui-grid="vm.gridOptions"></div>' +
'</div>' +
'</div>',
controllerAs: 'vm',
controller: controller
}
}
controller.$inject = ['$scope', '$http'];
function controller($scope, $http) {
var vm = this;
vm.gridOptions = {
enableHorizontalScrollbar: 0
}
vm.loading = true;
vm.title = $scope.title;
if ($scope.columns)
vm.gridOptions.columnDefs = angular.fromJson($scope.columns);
$http.post($scope.gridDataUrl)
.success(function (data) {
vm.gridOptions.data = data;
vm.loading = false;
});
}
})();
@@ -1,11 +1,10 @@
(function() {
window.app.filter('parseDate', parseDate);
window.app.filter("parseDate",
function() {
return function(input) {
if (typeof input != 'string' || input.indexOf("/Date") === -1) return input;
function parseDate() {
return function(input) {
if (typeof input != 'string' || input.indexOf('/Date') === -1) return input;
return new Date(parseInt(input.substr(6)));
}
}
return new Date(parseInt(input.substr(6)));
}
});
})();
+12 -13
View File
@@ -1,20 +1,19 @@
(function() {
'use strict';
window.app.directive('statusMessage', statusMessage);
function statusMessage() {
return {
scope: {
message: "=",
severity: "=?"
},
templateUrl: '/utility/template/statusMessage.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
}
window.app.directive('statusMessage',
function() {
return {
scope: {
message: "=",
severity: "=?"
},
templateUrl: '/utility/template/statusMessage.tmpl.cshtml',
controller: controller,
controllerAs: 'vm'
}
});
controller.$inject = ['$scope'];
function controller($scope) {
}
})();
+8 -9
View File
@@ -1,13 +1,12 @@
(function() {
window.app.filter('toUnits', toUnits);
window.app.filter('toUnits',
function() {
return function(caseQty, unitsPerCase) {
if (caseQty === "" || !isFinite(caseQty) || !isFinite(unitsPerCase))
return "";
function toUnits() {
return function (caseQty, unitsPerCase) {
if (caseQty === '' || !isFinite(caseQty) || !isFinite(unitsPerCase))
return '';
return caseQty * unitsPerCase;
}
}
return caseQty * unitsPerCase;
}
});
})();