revelry_data 0.0.8.1 → 0.0.10
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: 1beb262d66e95114e390158d5e307d0689117b1e
|
4
|
+
data.tar.gz: 91409632a5232c3af42d5059192fc9d948db40ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d43388eb4286560a50145b80480008403c392129405b89467116163c1bb30bd730e5740e5d7bf7523e9e41a9972e541b026e67fa07810714b152923fb021482
|
7
|
+
data.tar.gz: dc7c981fb5b175f7a8cca068e45d3ab6d4cb97dfca6d40ce3c6d174d5735e9fddb517d8077e2b1f45ca021b7df47c3a44cd545b14f9ff7c2867420e1a3a52c12
|
@@ -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,38 +96,6 @@ 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
|
-
|
131
99
|
/**
|
132
100
|
* Get the currently selected page number (1 by default)
|
133
101
|
*/
|
@@ -161,34 +129,6 @@ class CollectionQueryParameters {
|
|
161
129
|
this.maybeFetch()
|
162
130
|
}
|
163
131
|
|
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
|
-
|
192
132
|
/**
|
193
133
|
* Get the currently selected page number (1 by default)
|
194
134
|
*/
|
@@ -196,47 +136,6 @@ class CollectionQueryParameters {
|
|
196
136
|
return this._page || 1
|
197
137
|
}
|
198
138
|
|
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
|
-
|
240
139
|
/**
|
241
140
|
* Set the page back to page 1. Frequently we do this when changing sorting
|
242
141
|
* or filtering options so that the user is not disoriented in the result set.
|
@@ -280,18 +179,8 @@ class CollectionQueryParameters {
|
|
280
179
|
get fetchData() {
|
281
180
|
// Pagination options
|
282
181
|
let params = {
|
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})
|
182
|
+
page: this.page,
|
289
183
|
}
|
290
|
-
|
291
|
-
if(this.paginatorType === "offset") {
|
292
|
-
_.extend(params.page, {limit: this.limit, offset: this.offset})
|
293
|
-
}
|
294
|
-
|
295
184
|
// The sort option if set, otherwise skip
|
296
185
|
if(this.sort) {
|
297
186
|
_.extend(params, {sort: this.sort})
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# This exists because JSON API Resources won't let you route to 'new' or 'edit'
|
2
|
+
# and clobbers the value of the :except param to jsonapi_resources
|
3
|
+
# In order to support new and edit forms we have to patch these routing helpers
|
4
|
+
# for now
|
5
|
+
module ActionDispatch
|
6
|
+
module Routing
|
7
|
+
class Mapper
|
8
|
+
Resources.class_eval do
|
9
|
+
def jsonapi_resource(*resources, &_block)
|
10
|
+
@resource_type = resources.first
|
11
|
+
res = JSONAPI::Resource.resource_for(resource_type_with_module_prefix(@resource_type))
|
12
|
+
|
13
|
+
options = resources.extract_options!.dup
|
14
|
+
options[:controller] ||= @resource_type
|
15
|
+
options.merge!(res.routing_resource_options)
|
16
|
+
options[:path] = format_route(@resource_type)
|
17
|
+
|
18
|
+
resource @resource_type, options do
|
19
|
+
@scope[:jsonapi_resource] = @resource_type
|
20
|
+
|
21
|
+
if block_given?
|
22
|
+
yield
|
23
|
+
else
|
24
|
+
jsonapi_relationships
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def jsonapi_resources(*resources, &_block)
|
30
|
+
@resource_type = resources.first
|
31
|
+
res = JSONAPI::Resource.resource_for(resource_type_with_module_prefix(@resource_type))
|
32
|
+
|
33
|
+
options = resources.extract_options!.dup
|
34
|
+
options[:controller] ||= @resource_type
|
35
|
+
options.merge!(res.routing_resource_options)
|
36
|
+
|
37
|
+
options[:param] = :id
|
38
|
+
|
39
|
+
options[:path] = format_route(@resource_type)
|
40
|
+
|
41
|
+
if res.resource_key_type == :uuid
|
42
|
+
options[:constraints] = {id: /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}(,[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})*/}
|
43
|
+
end
|
44
|
+
|
45
|
+
resources @resource_type, options do
|
46
|
+
@scope[:jsonapi_resource] = @resource_type
|
47
|
+
|
48
|
+
if block_given?
|
49
|
+
yield
|
50
|
+
else
|
51
|
+
jsonapi_relationships
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/revelry_data/version.rb
CHANGED
data/lib/revelry_data.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.10
|
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-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -127,9 +127,9 @@ files:
|
|
127
127
|
- lib/revelry_data.rb
|
128
128
|
- lib/revelry_data/engine.rb
|
129
129
|
- lib/revelry_data/jsonapi_resources_patch.rb
|
130
|
+
- lib/revelry_data/jsonapi_resources_routing_patch.rb
|
130
131
|
- lib/revelry_data/resource_controller_concern.rb
|
131
132
|
- lib/revelry_data/version.rb
|
132
|
-
- lib/revelry_data/version.rb.orig
|
133
133
|
- lib/tasks/revelry_data_tasks.rake
|
134
134
|
- spec/dummy/README.rdoc
|
135
135
|
- spec/dummy/Rakefile
|
@@ -730,7 +730,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
730
730
|
version: '0'
|
731
731
|
requirements: []
|
732
732
|
rubyforge_project:
|
733
|
-
rubygems_version: 2.
|
733
|
+
rubygems_version: 2.2.2
|
734
734
|
signing_key:
|
735
735
|
specification_version: 4
|
736
736
|
summary: Revelry Data is a library for managing data within React applications using
|