revelry_data 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e50d8ff5a38c9ebc9f025d6d2071037649d3c02
|
4
|
+
data.tar.gz: b398499f4959cc8fe0cbc0af778cd581a2d41806
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dd38dad98c3e8fc14312455f303f9665a66f142571dca818b251ef969e53d0f7e68fd46a9650be5d6762f5677479d996aa9f867375b9dd2fa63ad349075fb45
|
7
|
+
data.tar.gz: 3341bdb1d470a9395ce9a3e712130578aa165dc7cd28066708c3c447fb67e3d87372333fcfbbbad3854581f3c8b73398d6dc6d22b6617e7437907027368a7503
|
@@ -65,7 +65,7 @@ class CollectionQueryParameters {
|
|
65
65
|
* @param {String} newValue - the new value of the filter to apply
|
66
66
|
*/
|
67
67
|
setFilter(filterName, newValue) {
|
68
|
-
// if filter changes, reset pagination
|
68
|
+
// if filter changes, reset pagination
|
69
69
|
if (this.filters[filterName] !== newValue) {
|
70
70
|
this.resetPage()
|
71
71
|
}
|
@@ -96,6 +96,38 @@ class CollectionQueryParameters {
|
|
96
96
|
this.page = n
|
97
97
|
}
|
98
98
|
|
99
|
+
/**
|
100
|
+
* Get the currently selected paginaion size
|
101
|
+
*/
|
102
|
+
getSize() {
|
103
|
+
return this.size
|
104
|
+
}
|
105
|
+
|
106
|
+
/**
|
107
|
+
* Set the selected size to a new value and fetch is `fetchExplicitly` is
|
108
|
+
* `false`
|
109
|
+
* @param {Integer} n - the new size number
|
110
|
+
*/
|
111
|
+
setSize(n) {
|
112
|
+
this.size = n
|
113
|
+
}
|
114
|
+
|
115
|
+
/**
|
116
|
+
* Get the currently selected pagination limit
|
117
|
+
*/
|
118
|
+
getLimit() {
|
119
|
+
return this.offset
|
120
|
+
}
|
121
|
+
|
122
|
+
/**
|
123
|
+
* Set the selected limit to a new value and fetch is `fetchExplicitly` is
|
124
|
+
* `false`
|
125
|
+
* @param {Integer} n - the new limit number
|
126
|
+
*/
|
127
|
+
setLimit(n) {
|
128
|
+
this.limit = n
|
129
|
+
}
|
130
|
+
|
99
131
|
/**
|
100
132
|
* Get the currently selected page number (1 by default)
|
101
133
|
*/
|
@@ -129,6 +161,34 @@ class CollectionQueryParameters {
|
|
129
161
|
this.maybeFetch()
|
130
162
|
}
|
131
163
|
|
164
|
+
/**
|
165
|
+
* Set the selected size to a new value, limit to null, resets page
|
166
|
+
* and fetch is `fetchExplicitly` is `false`
|
167
|
+
* https://github.com/cerebris/jsonapi-resources#paged-paginator
|
168
|
+
* @param {Integer} n - the new pagination size
|
169
|
+
*/
|
170
|
+
|
171
|
+
set size(n) {
|
172
|
+
this._size = n
|
173
|
+
this._limit = null
|
174
|
+
this.resetPage()
|
175
|
+
this.maybeFetch()
|
176
|
+
}
|
177
|
+
|
178
|
+
/**
|
179
|
+
* Set the selected limit to a new value, size to null, resets page
|
180
|
+
* and fetch is `fetchExplicitly` is `false`
|
181
|
+
* https://github.com/cerebris/jsonapi-resources#offset-paginator
|
182
|
+
* @param {Integer} n - the new pagination limit
|
183
|
+
*/
|
184
|
+
|
185
|
+
set limit(n) {
|
186
|
+
this._limit = n
|
187
|
+
this._size = null
|
188
|
+
this.resetPage()
|
189
|
+
this.maybeFetch()
|
190
|
+
}
|
191
|
+
|
132
192
|
/**
|
133
193
|
* Get the currently selected page number (1 by default)
|
134
194
|
*/
|
@@ -136,6 +196,47 @@ class CollectionQueryParameters {
|
|
136
196
|
return this._page || 1
|
137
197
|
}
|
138
198
|
|
199
|
+
get offset(){
|
200
|
+
if(this.page > 1){
|
201
|
+
return (this.page - 1) * this.limit
|
202
|
+
}
|
203
|
+
|
204
|
+
return 0;
|
205
|
+
}
|
206
|
+
|
207
|
+
/**
|
208
|
+
* Get the currently selected size for pagination
|
209
|
+
*/
|
210
|
+
|
211
|
+
get size() {
|
212
|
+
return this._size
|
213
|
+
}
|
214
|
+
|
215
|
+
/**
|
216
|
+
* Get the currently selected limit for pagination
|
217
|
+
*/
|
218
|
+
|
219
|
+
get limit() {
|
220
|
+
return this._limit
|
221
|
+
}
|
222
|
+
|
223
|
+
/**
|
224
|
+
* Get the currently selected paginator type:
|
225
|
+
* If size exist it returns paged
|
226
|
+
* If limit exist it returns offset
|
227
|
+
* If no-one exist it returns nil for backward compatibility
|
228
|
+
*/
|
229
|
+
|
230
|
+
get paginatorType() {
|
231
|
+
if(this.size){
|
232
|
+
return "paged"
|
233
|
+
}
|
234
|
+
|
235
|
+
if(this.limit){
|
236
|
+
return "offset"
|
237
|
+
}
|
238
|
+
}
|
239
|
+
|
139
240
|
/**
|
140
241
|
* Set the page back to page 1. Frequently we do this when changing sorting
|
141
242
|
* or filtering options so that the user is not disoriented in the result set.
|
@@ -179,8 +280,18 @@ class CollectionQueryParameters {
|
|
179
280
|
get fetchData() {
|
180
281
|
// Pagination options
|
181
282
|
let params = {
|
182
|
-
page:
|
283
|
+
page: {},
|
284
|
+
}
|
285
|
+
|
286
|
+
// The size option if set, otherwise skip
|
287
|
+
if(this.paginatorType === "paged") {
|
288
|
+
_.extend(params.page, {size: this.size, number: this.page})
|
183
289
|
}
|
290
|
+
|
291
|
+
if(this.paginatorType === "offset") {
|
292
|
+
_.extend(params.page, {limit: this.limit, offset: this.offset})
|
293
|
+
}
|
294
|
+
|
184
295
|
// The sort option if set, otherwise skip
|
185
296
|
if(this.sort) {
|
186
297
|
_.extend(params, {sort: this.sort})
|
data/lib/revelry_data/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: revelry_data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Prehn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -731,7 +731,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
731
731
|
version: '0'
|
732
732
|
requirements: []
|
733
733
|
rubyforge_project:
|
734
|
-
rubygems_version: 2.
|
734
|
+
rubygems_version: 2.4.5.1
|
735
735
|
signing_key:
|
736
736
|
specification_version: 4
|
737
737
|
summary: Revelry Data is a library for managing data within React applications using
|