Inventory details
This commit is contained in:
@@ -3,20 +3,21 @@
|
||||
|
||||
window.app.controller('TransactionController', TransactionController);
|
||||
|
||||
TransactionController.$inject = ['$scope', '$uibModal', 'transactionSvc', 'uiGridConstants'];
|
||||
function TransactionController($scope, $uibModal, transactionSvc, uiGridConstants) {
|
||||
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
|
||||
};
|
||||
|
||||
|
||||
vm.gridOptions = {
|
||||
enablePaginationControls: true,
|
||||
paginationPageSize: paginationOptions.pageSize,
|
||||
paginationPageSizes: [20,50,100],
|
||||
paginationPageSizes: paginationOptions.pageSizes,
|
||||
useExternalPagination: true,
|
||||
enableSorting: false,
|
||||
columnDefs: [
|
||||
@@ -30,7 +31,7 @@
|
||||
'\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="vm.edit()"><i class="fa fa-edit"></i></a> ' +
|
||||
'<a href="" ng-click="grid.appScope.editInventory(row.entity.inventoryId)"><i class="fa fa-edit"></i></a> ' +
|
||||
'{{row.entity.name}}</div>'
|
||||
},
|
||||
{ field: 'transactionType', name: 'Type', width: "10%" },
|
||||
@@ -43,33 +44,34 @@
|
||||
],
|
||||
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;
|
||||
vm.gridApi.pagination
|
||||
.on.paginationChanged($scope, function(pageNumber, pageSize) {
|
||||
paginationOptions.pageNumber = pageNumber;
|
||||
paginationOptions.pageSize = pageSize;
|
||||
updateData();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var updateData = function () {
|
||||
function updateData() {
|
||||
transactionSvc
|
||||
.getTransactions(paginationOptions.pageNumber, paginationOptions.pageSize)
|
||||
.success(function(data) {
|
||||
vm.gridOptions.totalItems = data.totalItems;
|
||||
.filterByPage(paginationOptions.pageNumber, paginationOptions.pageSize)
|
||||
.success(function (data) {
|
||||
vm.gridOptions.data = data.transactions;
|
||||
vm.gridOptions.totalItems = data.totalItems;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
updateData();
|
||||
|
||||
$scope.editInventory = function (inventoryId) {
|
||||
inventorySvc.getInventory(inventoryId)
|
||||
.success(function(inventory) {
|
||||
$uibModal.open({
|
||||
template: '<edit-inventory inventory="inventory" />',
|
||||
scope: angular.extend($scope.$new(true), { inventory: inventory })
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -5,33 +5,25 @@
|
||||
function transactionSvc($http) {
|
||||
|
||||
var svc = {
|
||||
update: update,
|
||||
getTransactions: getTransactions,
|
||||
getTransaction: getTransaction
|
||||
filterByPage: filterByPage,
|
||||
filterByInventoryId: filterByInventoryId
|
||||
};
|
||||
|
||||
return svc;
|
||||
|
||||
function filterByPage(pageNumber, pageSize) {
|
||||
return getTransactions({ pageNumber: pageNumber, pageSize: pageSize });
|
||||
}
|
||||
|
||||
function getTransactions(pageNumber, pageSize) {
|
||||
function filterByInventoryId(inventoryId) {
|
||||
return getTransactions({ inventoryId: inventoryId });
|
||||
}
|
||||
|
||||
function getTransactions(params) {
|
||||
var url = '/Transaction/GetTransactions';
|
||||
return $http.post(url, { pageNumber: pageNumber, pageSize: pageSize });
|
||||
//.success(function(data) {
|
||||
// return data.data;
|
||||
//});
|
||||
}
|
||||
|
||||
function update(existingTransaction, updatedTransaction) {
|
||||
return $http.post('/Transaction/Update', updatedTransaction)
|
||||
.success(function(transaction) {
|
||||
angular.extend(existingTransaction, transaction);
|
||||
return $http.post(url, params)
|
||||
.success(function (data) {
|
||||
});
|
||||
}
|
||||
|
||||
function getTransaction(id) {
|
||||
for (var i = 0; i < transactions.length; i++) {
|
||||
if (transactions[i].Id == id) return transactions[i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user