Add user management
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user