revelry_data 0.0.8 → 0.0.8.1
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: a57b18574b99199842afc5cd31456a9fecaeee63
|
4
|
+
data.tar.gz: 6c885121517a05658e658948b633b427573adbde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb0997aec122b06921f16b7144fcc2311b63dbe46d3959a8e263a4551a1099a7c2bf8c40e5bd4810f4e0751c6d9cd962946bec555194300e7a18ab5afa757c9d
|
7
|
+
data.tar.gz: 55ad445cbc2b9ef619d415e48b331e9be2f7d8646da4b584395fbb19665ff2e2cf3b91bfb0e77a60a6beb438e9255fa3d80548989c4d838715c640d77585fa03
|
@@ -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.8
|
4
|
+
version: 0.0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Prehn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- lib/revelry_data/jsonapi_resources_patch.rb
|
130
130
|
- lib/revelry_data/resource_controller_concern.rb
|
131
131
|
- lib/revelry_data/version.rb
|
132
|
+
- lib/revelry_data/version.rb.orig
|
132
133
|
- lib/tasks/revelry_data_tasks.rake
|
133
134
|
- spec/dummy/README.rdoc
|
134
135
|
- spec/dummy/Rakefile
|
@@ -729,7 +730,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
729
730
|
version: '0'
|
730
731
|
requirements: []
|
731
732
|
rubyforge_project:
|
732
|
-
rubygems_version: 2.
|
733
|
+
rubygems_version: 2.4.5.1
|
733
734
|
signing_key:
|
734
735
|
specification_version: 4
|
735
736
|
summary: Revelry Data is a library for managing data within React applications using
|