Skip to content

Commit

Permalink
feat(*): allow creation of first PageInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
cburgdorf committed Aug 4, 2014
1 parent 298f8ca commit 5d74c39
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
9 changes: 7 additions & 2 deletions dist/sofa.couchService.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* sofa-couch-service - v0.10.0 - 2014-08-01
* sofa-couch-service - v0.10.0 - 2014-08-04
*
*
* Copyright (c) 2014 CouchCommerce GmbH (http://www.couchcommerce.com / http://www.sofa.io) and other contributors
Expand Down Expand Up @@ -114,7 +114,8 @@ sofa.define('sofa.CouchService', function ($http, $q, configService) {
* @return {object} The PageInfo object.
*/
self.createPageInfo = function (entities) {
return pageInfoFactory.createPageInfo(entities);
return entities ?
pageInfoFactory.createPageInfo(entities) : pageInfoFactory.createFirstPageInfo();
};

/**
Expand Down Expand Up @@ -556,6 +557,10 @@ sofa.define('sofa.PageInfoFactory', function (configService) {
return new PageInfo(DEFAULT_PAGE_SIZE, entities.length - DEFAULT_PAGE_SIZE);
};

self.createFirstPageInfo = function () {
return new PageInfo(DEFAULT_PAGE_SIZE, 0);
};

return self;
});

Expand Down
4 changes: 2 additions & 2 deletions dist/sofa.couchService.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/sofa.PageInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@ sofa.define('sofa.PageInfoFactory', function (configService) {
return new PageInfo(DEFAULT_PAGE_SIZE, entities.length - DEFAULT_PAGE_SIZE);
};

self.createFirstPageInfo = function () {
return new PageInfo(DEFAULT_PAGE_SIZE, 0);
};

return self;
});
3 changes: 2 additions & 1 deletion src/sofa.couchService.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ sofa.define('sofa.CouchService', function ($http, $q, configService) {
* @return {object} The PageInfo object.
*/
self.createPageInfo = function (entities) {
return pageInfoFactory.createPageInfo(entities);
return entities ?
pageInfoFactory.createPageInfo(entities) : pageInfoFactory.createFirstPageInfo();
};

/**
Expand Down

0 comments on commit 5d74c39

Please sign in to comment.