aboutsummaryrefslogtreecommitdiff
path: root/src/main/webapp/apps/core/PagingTableService.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/webapp/apps/core/PagingTableService.js')
-rwxr-xr-xsrc/main/webapp/apps/core/PagingTableService.js72
1 files changed, 0 insertions, 72 deletions
diff --git a/src/main/webapp/apps/core/PagingTableService.js b/src/main/webapp/apps/core/PagingTableService.js
deleted file mode 100755
index af593df..0000000
--- a/src/main/webapp/apps/core/PagingTableService.js
+++ /dev/null
@@ -1,72 +0,0 @@
-function PagingTableService() {
- var create = function ($scope, fetchCallback, options) {
- options = options || {};
- var watcher = options.watcher || function(){};
- var self = {
- rows: [],
- startIndex: options.startIndex || 0,
- count: options.count || 10
- };
-
- var update = function(){
- fetchCallback(self.startIndex, self.count, function(data) {
- self.rows = data.rows;
- watcher();
- });
- };
-
- self.first = function () {
- self.startIndex = 0;
- update();
- };
-
- self.next = function () {
- self.startIndex += self.count;
- update();
- };
-
- self.prev = function () {
- if (self.startIndex == 0) {
- return;
- }
- self.startIndex -= self.count;
- update();
- };
-
- // Do an initial fetch
- update();
-
- return self;
- };
-
- var defaultCallback = function(Resource, args) {
- args = args || {};
- return function(startIndex, count, cb) {
- if(startIndex) {
- args.startIndex = startIndex;
- }
- if(count) {
- args.count = count;
- }
- console.log("fetching", args);
- Resource.query(args, function(data, headers) {
- var totalResults = headers("total-results");
- console.log("totalResults", totalResults);
- console.log("got data", data);
- cb({
- totalResults: totalResults,
- rows: data
- });
- });
- };
- };
-
- return {
- create: create,
- defaultCallback: defaultCallback
- }
-}
-
-angular.
- module('pagingTableService', ['ngResource']).
- factory('PagingTableService', PagingTableService);