@simpli/resource-collection
Advanced tools
Comparing version 1.1.4 to 1.1.5
@@ -66,3 +66,3 @@ "use strict"; | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.currentPage = -1; | ||
_this._currentPage = null; | ||
_this.queryAsExpansible = _this.queryAsPage; | ||
@@ -82,2 +82,12 @@ _this.items = []; // final list | ||
}); | ||
Object.defineProperty(ExpansibleCollection.prototype, "currentPage", { | ||
get: function () { | ||
return this._currentPage || 0; | ||
}, | ||
set: function (val) { | ||
this._currentPage = val; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(ExpansibleCollection.prototype, "maxPerPage", { | ||
@@ -97,6 +107,11 @@ get: function () { | ||
case 0: | ||
if (this.isLastPage && this.currentPage > -1) { | ||
if (this.isLastPage && this._currentPage !== null) { | ||
return [2 /*return*/]; | ||
} | ||
this.currentPage += 1; | ||
if (this._currentPage === null) { | ||
this._currentPage = 0; | ||
} | ||
else { | ||
this._currentPage += 1; | ||
} | ||
this.isExpanding = true; | ||
@@ -130,3 +145,3 @@ // 1 - call onBeforeSerialization => addedItems = [] | ||
case 0: | ||
currentPage = Number(this.currentPage) || 0; | ||
currentPage = this.currentPage; | ||
perPage = Number(this.perPage) || 0; | ||
@@ -150,3 +165,3 @@ this.currentPage = 0; | ||
return __generator(this, function (_a) { | ||
this.currentPage = -1; | ||
this._currentPage = null; | ||
this.items = []; | ||
@@ -153,0 +168,0 @@ this.expandedItems = []; |
import { IResource } from './IResource'; | ||
import { PageCollection } from './PageCollection'; | ||
export declare abstract class ExpansibleCollection<R extends IResource> extends PageCollection<R> { | ||
currentPage: number; | ||
_currentPage: number | null; | ||
queryAsExpansible: () => Promise<any>; | ||
@@ -11,2 +11,3 @@ items: R[]; | ||
readonly isLastPage: boolean; | ||
currentPage: number; | ||
readonly maxPerPage: number; | ||
@@ -13,0 +14,0 @@ expand(): Promise<void>; |
{ | ||
"name": "@simpli/resource-collection", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "A data-structure library to work with ResourceCollections (with Id and Tag) and PageCollections (search and order as well)", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
2741351
21512
10