1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| (function() {
'use strict';
angular
.module('boProcess')
.component('extraCategoryListComponent', {
templateUrl: 'app/components/extra-category-list/extra-category-list.template.html',
controller: ExtraCategoryListController,
controllerAs: 'extraCategoryListCtrl'
});
/** @ngInject */
function ExtraCategoryListController($log, $scope, extraCategoryService, commonService) {
$scope.query = {
total: 0,
page: 1,
maxPerPage: 10,
search: '',
bookmark: 1
};
/**
* @param page current selected page
* @param limit number of items per page
*/
$scope.onPaginate = function (page, limit) {
$scope.query.page = page;
$scope.query.maxPerPage = limit;
$scope.getExtraCategories();
};
/**
* List Extra Categories
* @param page page number
* @param limit number of items requested
* @search search term
*/
$scope.getExtraCategories = function () {
// call API
extraCategoryService.query({page: $scope.query.page, maxPerPage: $scope.query.maxPerPage, search: $scope.query.search}).$promise
.then(function(response) {
// update pagination
$scope.query.total = response.info.totalResult;
$scope.query.page = response.info.pagination.currentPage;
$scope.query.maxPerPage = response.info.pagination.maxPerPage;
// update data
$scope.extraCategories = response.data;
})
.catch(function(response) {
$log.debug("Error append with status code " + response.status + ".");
$scope.query.total = 0;
$scope.query.page = 1;
$scope.query.maxPerPage = 0;
$scope.query.search = '';
commonService.showToast('SCREEN.EXTRA-CATEGORY-LIST.TOAST.QUERY-ERROR');
})
;
};
}
})(); |
Partager