Add transaction list
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
window.app.controller('TransactionController', TransactionController);
|
||||
|
||||
TransactionController.$inject = ['$scope', '$uibModal', 'transactionSvc', 'uiGridConstants'];
|
||||
function TransactionController($scope, $uibModal, transactionSvc, uiGridConstants) {
|
||||
var vm = this;
|
||||
|
||||
var paginationOptions = {
|
||||
pageNumber: 1,
|
||||
pageSize: 20,
|
||||
sort: null
|
||||
};
|
||||
|
||||
vm.gridOptions = {
|
||||
enablePaginationControls: true,
|
||||
paginationPageSize: paginationOptions.pageSize,
|
||||
paginationPageSizes: [20,50,100],
|
||||
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="#">{{row.entity.name}}</a></div>'
|
||||
},
|
||||
{ field: 'memo', cellTooltip: true },
|
||||
{ field: 'transactionDate', name: 'Transaction Date', cellFilter: "date:MM/dd/yyyy", width: "15%" },
|
||||
{ field: 'addedQuantity', name: 'Add Qty', width: "10%", enableSorting: false },
|
||||
{ field: 'removedQuantity', name: 'Remove Qty', width: "10%", enableSorting: false },
|
||||
{ field: 'currentQuantity', name: 'Current Qty', width: "15%", enableSorting: false }
|
||||
],
|
||||
onRegisterApi: function(gridApi) {
|
||||
vm.gridApi = gridApi;
|
||||
//vm.gridApi.core.on.sortChanged($scope,
|
||||
// function(grid, sortColumns) {
|
||||
// if (sortColumns.length == 0) {
|
||||
// paginationOptions.sort = null;
|
||||
// } else {
|
||||
// paginationOptions.sort = sortColumns[0].sort.direction;
|
||||
// }
|
||||
// getPage();
|
||||
// });
|
||||
vm.gridApi.pagination.on.paginationChanged($scope,
|
||||
function(newPage, pageSize) {
|
||||
paginationOptions.pageNumber = newPage;
|
||||
paginationOptions.pageSize = pageSize;
|
||||
updateData();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var updateData = function () {
|
||||
transactionSvc
|
||||
.getTransactions(paginationOptions.pageNumber, paginationOptions.pageSize)
|
||||
.then(function(data) {
|
||||
vm.gridOptions.totalItems = data.totalItems;
|
||||
vm.gridOptions.data = data.transactions;
|
||||
});
|
||||
};
|
||||
|
||||
updateData();
|
||||
|
||||
function del() {
|
||||
$uibModal.open({
|
||||
template: '<inventory-distribute />',
|
||||
backdrop: 'static'
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -3,23 +3,20 @@
|
||||
|
||||
transactionSvc.$inject = ['$http'];
|
||||
function transactionSvc($http) {
|
||||
var transactions = [];
|
||||
|
||||
loadTransactions();
|
||||
|
||||
var svc = {
|
||||
add: add,
|
||||
update: update,
|
||||
transactions: transactions,
|
||||
getTransactions: getTransactions,
|
||||
getTransaction: getTransaction
|
||||
};
|
||||
|
||||
return svc;
|
||||
|
||||
function loadTransactions() {
|
||||
$http.post('/Transaction/All')
|
||||
.success(function(data) {
|
||||
angular.copy(data, transactions);
|
||||
function getTransactions(pageNumber, pageSize) {
|
||||
var url = '/Transaction/GetTransactions';
|
||||
return $http.post(url, {pageNumber: pageNumber, pageSize: pageSize})
|
||||
.then(function(data) {
|
||||
return data.data;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user