revelry_data 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/revelry_data/models/CollectionQueryParameters.es6 +3 -3
- data/lib/revelry_data/engine.rb +5 -0
- data/lib/revelry_data/jsonapi_resources_patch.rb +13 -1
- data/lib/revelry_data/resource_controller_concern.rb +64 -41
- data/lib/revelry_data/version.rb +1 -1
- data/lib/revelry_data/version.rb.orig +3 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d499b1c3e5bf1c2b32b9889a0e0f7bf1153dc8f9
|
4
|
+
data.tar.gz: 9be265367378e45c773dc2b8e49256c0589f16ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e6ed3a95b74b66dc6dfa8824fa166dcaf09047564ee3821c0c65cc2d219f8023146b9faf3ab522c06c876bd70f94511ad57681b93d715134bfd9949805da914
|
7
|
+
data.tar.gz: 81f53e67125f304989ad9696d1ff620aaa149165e57c8ff76117a5cf6edce1f28aad2f027eac38a8c8fa75be1c547d72c1ed85f232173c5c5c445a0e07671e6f
|
@@ -280,16 +280,16 @@ class CollectionQueryParameters {
|
|
280
280
|
get fetchData() {
|
281
281
|
// Pagination options
|
282
282
|
let params = {
|
283
|
-
page:
|
283
|
+
page: this.page
|
284
284
|
}
|
285
285
|
|
286
286
|
// The size option if set, otherwise skip
|
287
287
|
if(this.paginatorType === "paged") {
|
288
|
-
|
288
|
+
params.page = {size: this.size, number: this.page}
|
289
289
|
}
|
290
290
|
|
291
291
|
if(this.paginatorType === "offset") {
|
292
|
-
|
292
|
+
params.page = {limit: this.limit, offset: this.offset}
|
293
293
|
}
|
294
294
|
|
295
295
|
// The sort option if set, otherwise skip
|
data/lib/revelry_data/engine.rb
CHANGED
@@ -8,5 +8,10 @@ module RevelryData
|
|
8
8
|
config.always_include_to_many_linkage_data = true
|
9
9
|
end
|
10
10
|
end
|
11
|
+
|
12
|
+
initializer 'revelry_data.blacklist_props', after: 'execjs_rails.setup_view_helpers' do |app|
|
13
|
+
break unless defined?(ExecJS::Rails)
|
14
|
+
config.execjs_rails.blacklisted_assigns += %w(request response)
|
15
|
+
end
|
11
16
|
end
|
12
17
|
end
|
@@ -38,8 +38,20 @@ JSONAPI::Request.class_eval do
|
|
38
38
|
@operations.push JSONAPI::NewOperation.new(
|
39
39
|
@resource_klass,
|
40
40
|
{
|
41
|
-
|
41
|
+
context: @context,
|
42
|
+
include_directives: @include_directives,
|
42
43
|
}
|
43
44
|
)
|
44
45
|
end
|
45
46
|
end
|
47
|
+
|
48
|
+
JSONAPI::ActsAsResourceController.class_eval do
|
49
|
+
def base_response_meta
|
50
|
+
{
|
51
|
+
current_user: current_user,
|
52
|
+
csrf_token: form_authenticity_token,
|
53
|
+
current_org: current_user.try(:org),
|
54
|
+
flashes: flash,
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
@@ -1,63 +1,86 @@
|
|
1
1
|
module RevelryData
|
2
2
|
module Resource
|
3
3
|
extend ActiveSupport::Concern
|
4
|
-
include JSONAPI::ActsAsResourceController
|
5
4
|
|
6
5
|
included do
|
6
|
+
include JSONAPI::ActsAsResourceController
|
7
7
|
respond_to :html, :json, :props
|
8
8
|
before_filter :setup_request
|
9
|
-
end
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
def new
|
11
|
+
if respond_to? :process_request_operations
|
12
|
+
process_request_operations
|
13
|
+
else
|
14
|
+
process_request
|
15
|
+
end
|
16
|
+
end
|
14
17
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
def setup_request
|
19
|
+
@request = JSONAPI::Request.new(params, {
|
20
|
+
context: context,
|
21
|
+
key_formatter: key_formatter
|
22
|
+
})
|
23
|
+
render_errors(@request.errors) unless @request.errors.empty?
|
24
|
+
rescue => e
|
25
|
+
handle_exceptions(e)
|
26
|
+
end
|
24
27
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
+
def process_request
|
29
|
+
@request = JSONAPI::Request.new(params, context: context,
|
30
|
+
key_formatter: key_formatter,
|
31
|
+
server_error_callbacks: (self.class.server_error_callbacks || []))
|
32
|
+
unless @request.errors.empty?
|
33
|
+
render_errors(@request.errors)
|
34
|
+
else
|
35
|
+
operation_results = create_operations_processor.process(@request)
|
36
|
+
render_results(operation_results)
|
37
|
+
end
|
28
38
|
|
29
|
-
|
30
|
-
|
39
|
+
rescue => e
|
40
|
+
handle_exceptions(e)
|
41
|
+
ensure
|
42
|
+
if response.body.size > 0 && fmt_is_json_api?
|
43
|
+
response.headers['Content-Type'] = JSONAPI::MEDIA_TYPE
|
44
|
+
end
|
45
|
+
end
|
31
46
|
|
32
|
-
|
33
|
-
|
47
|
+
def fmt_is_json_api?
|
48
|
+
request.format == 'json'
|
34
49
|
end
|
35
|
-
end
|
36
50
|
|
37
|
-
|
38
|
-
|
51
|
+
def setup_response
|
52
|
+
return unless fmt_is_json_api?
|
39
53
|
|
40
|
-
|
41
|
-
|
42
|
-
@json_api = response_doc.contents
|
43
|
-
render status: response_doc.status
|
54
|
+
if response.body.size > 0
|
55
|
+
response.headers['Content-Type'] = JSONAPI::MEDIA_TYPE
|
44
56
|
end
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
57
|
+
end
|
58
|
+
|
59
|
+
def render_results(operation_results)
|
60
|
+
response_doc = create_response_document(operation_results)
|
61
|
+
|
62
|
+
respond_with response_doc.contents do |fmt|
|
63
|
+
fmt.html do
|
64
|
+
@json_api = response_doc.contents
|
65
|
+
render status: response_doc.status
|
66
|
+
end
|
67
|
+
fmt.json do
|
68
|
+
render json: response_doc.contents, status: response_doc.status
|
69
|
+
end
|
70
|
+
fmt.props do
|
71
|
+
render json: response_doc.contents, status: response_doc.status
|
72
|
+
end
|
50
73
|
end
|
51
74
|
end
|
52
|
-
end
|
53
75
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
76
|
+
def base_response_meta
|
77
|
+
{
|
78
|
+
current_user: current_user,
|
79
|
+
csrf_token: form_authenticity_token,
|
80
|
+
current_org: current_user.try(:org),
|
81
|
+
flashes: flash,
|
82
|
+
}
|
83
|
+
end
|
61
84
|
end
|
62
85
|
end
|
63
86
|
end
|
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.15
|
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-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -1316,3 +1316,4 @@ test_files:
|
|
1316
1316
|
- spec/javascripts/support/jasmine.yml
|
1317
1317
|
- spec/revelry_data_test.rb
|
1318
1318
|
- spec/spec_helper.rb
|
1319
|
+
has_rdoc:
|