From 4a6c9c52d006ecb717bae7d9b502d9b661a08ccd Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Fri, 4 Jan 2013 10:18:56 +0100 Subject: o Using the PagingTableService on the front page and person apps. --- src/main/webapp/apps/frontPageApp/frontPageApp.js | 67 +---------------------- 1 file changed, 3 insertions(+), 64 deletions(-) mode change 100644 => 100755 src/main/webapp/apps/frontPageApp/frontPageApp.js (limited to 'src/main/webapp/apps/frontPageApp/frontPageApp.js') diff --git a/src/main/webapp/apps/frontPageApp/frontPageApp.js b/src/main/webapp/apps/frontPageApp/frontPageApp.js old mode 100644 new mode 100755 index c4fa0cc..21bc91f --- a/src/main/webapp/apps/frontPageApp/frontPageApp.js +++ b/src/main/webapp/apps/frontPageApp/frontPageApp.js @@ -1,71 +1,10 @@ 'use strict'; -var frontPageApp = angular.module('frontPageApp', ['ngGrid', 'person']).config(function ($routeProvider, $locationProvider) { +var frontPageApp = angular.module('frontPageApp', ['ngGrid', 'person', 'pagingTableService']).config(function ($routeProvider, $locationProvider) { $routeProvider. when('/', {controller: FrontPageCtrl, templateUrl: '/apps/frontPageApp/frontPage.html?noCache=' + noCache}); }); -function FrontPageCtrl($scope, $http, Person) { - $scope.persons = []; - - $scope.pagingOptions = { - pageSizes: [10], - pageSize: 10, - totalServerItems: 0, - currentPage: 1 - }; - - $scope.personsGridOptions = { - data: 'persons', - displayFooter: true, - enablePaging: true, - enableRowReordering: false, - enableColumnReordering: false, - showFilter: false, - showColumnMenu: false, - canSelectRows: false, - displaySelectionCheckbox: false, - pagingOptions: $scope.pagingOptions, - columnDefs: [ - { - field: 'name', - displayName: 'Name', - cellTemplate: '{{row.getProperty(col.field)}}' - }, - { - field: 'badges', - displayName: 'Badges', - cellTemplate: '
{{row.getProperty(col.field).length}}
' - } - ] - }; - - $scope.setPagingData = function(data, page, pageSize){ -// $scope.persons = data.slice((page - 1) * pageSize, page * pageSize); - $scope.persons = data; -// $scope.personsGridOptions.totalServerItems = data.length; - window.x = $scope.personsGridOptions; - if (!$scope.$$phase) { - $scope.$apply(); - } - }; - - $scope.getPagedDataAsync = function (pageSize, page/*, searchText*/) { - setTimeout(function () { - - Person.query({startIndex: page * pageSize, count: pageSize}, function (persons) { - $scope.setPagingData(persons, page, pageSize); - }); - }, 100); - }; - - $scope.$watch('pagingOptions', function () { - $scope.getPagedDataAsync($scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage); - }, true); - -// $http.get('/resource/core/person-count').success(function(count) { -// $scope.pagingOptions.totalServerItems = count; -// -// $scope.getPagedDataAsync($scope.pagingOptions.pageSize, $scope.pagingOptions.currentPage); -// }); +function FrontPageCtrl($scope, Person, PagingTableService) { + $scope.persons = PagingTableService.create($scope, PagingTableService.defaultCallback(Person)); } -- cgit v1.2.3