graph_starter 0.12.5 → 0.13.0
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/controllers/graph_starter/assets_controller.rb +20 -6
- data/app/helpers/graph_starter/application_helper.rb +4 -0
- data/app/models/graph_starter/asset.rb +12 -10
- data/app/views/graph_starter/assets/_card.html.slim +1 -1
- data/app/views/graph_starter/assets/show.json.jbuilder +11 -0
- data/config/routes.rb +1 -1
- data/lib/graph_starter/version.rb +1 -1
- data/test/dummy/config/application.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d1fa716435b1f5c2cbc5429b1dd9567651de86b
|
4
|
+
data.tar.gz: 4dd99e0d6f47c5d9591f2886060b199abf50a50f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ad2a74e69e199ffdf7c32ca23fd2b8a0911f46ff47a74e49a36b5378aaaba3eab04bae3d7d9050cbbff99124c259290cf9492af6d8e444945ee84db36f32ddf
|
7
|
+
data.tar.gz: 1c54c2ae4913e699723a8b375be7b9a78aae8752458cbf7fff82e77d44521ab081f3f456b2b5ee1e289a15795acef8db3bc05c83fb912afbeedfb9c0183c37e5
|
@@ -43,11 +43,7 @@ module GraphStarter
|
|
43
43
|
|
44
44
|
scope = scope.limit(limit)
|
45
45
|
|
46
|
-
scope =
|
47
|
-
scope.query_as(var).with(var).proxy_as(model_class, var).with_associations(*associations)
|
48
|
-
else
|
49
|
-
scope
|
50
|
-
end
|
46
|
+
scope = apply_associations(scope, var)
|
51
47
|
|
52
48
|
scope
|
53
49
|
end
|
@@ -122,7 +118,7 @@ module GraphStarter
|
|
122
118
|
end
|
123
119
|
|
124
120
|
def asset
|
125
|
-
model_class_scope.where(uuid: params[:id]).to_a[0]
|
121
|
+
apply_associations(model_class_scope.where(uuid: params[:id])).to_a[0]
|
126
122
|
end
|
127
123
|
|
128
124
|
def asset_with_access_level
|
@@ -141,5 +137,23 @@ module GraphStarter
|
|
141
137
|
model_class.all(var)
|
142
138
|
end
|
143
139
|
end
|
140
|
+
|
141
|
+
def associations
|
142
|
+
return @associations if @associations.present?
|
143
|
+
|
144
|
+
@associations = []
|
145
|
+
@associations << model_class.image_association
|
146
|
+
@associations += model_class.category_associations
|
147
|
+
@associations.compact!
|
148
|
+
@associations
|
149
|
+
end
|
150
|
+
|
151
|
+
def apply_associations(scope, var = :asset)
|
152
|
+
if associations.present?
|
153
|
+
scope.query_as(var).with(var).proxy_as(model_class, var).with_associations(*associations)
|
154
|
+
else
|
155
|
+
scope
|
156
|
+
end
|
157
|
+
end
|
144
158
|
end
|
145
159
|
end
|
@@ -263,16 +263,18 @@ module GraphStarter
|
|
263
263
|
end
|
264
264
|
end
|
265
265
|
|
266
|
-
def as_json(
|
267
|
-
{
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
266
|
+
def as_json(options = {})
|
267
|
+
data = {
|
268
|
+
id: id,
|
269
|
+
title: title,
|
270
|
+
name: title,
|
271
|
+
model_slug: self.class.model_slug
|
272
|
+
}.tap do |result|
|
273
|
+
result[:images] = images.map {|image| image.source.url } if self.class.has_images?
|
274
|
+
result[:image] = image.source_url if self.class.has_image? && image
|
275
|
+
end
|
276
|
+
|
277
|
+
options[:root] ? {self.class.model_slug.singularize => data} : data
|
276
278
|
end
|
277
279
|
|
278
280
|
def views
|
@@ -0,0 +1,11 @@
|
|
1
|
+
@asset.class.authorized_properties(current_user).each do |property|
|
2
|
+
json.set! property.name, @asset.read_attribute(property.name)
|
3
|
+
end
|
4
|
+
|
5
|
+
|
6
|
+
json.associations do
|
7
|
+
@asset.class.authorized_associations.each do |name, association|
|
8
|
+
json.set! name, @asset.send(name).to_a
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
data/config/routes.rb
CHANGED
@@ -22,7 +22,7 @@ GraphStarter::Engine.routes.draw do
|
|
22
22
|
get ':model_slug/new' => 'assets#new', as: :new_asset
|
23
23
|
post ':model_slug' => 'assets#create', as: :create_asset
|
24
24
|
|
25
|
-
get ':model_slug/:id' => 'assets#show', as: :asset
|
25
|
+
get ':model_slug/:id(.:format)' => 'assets#show', as: :asset
|
26
26
|
get ':model_slug/:id/edit' => 'assets#edit', as: :edit_asset
|
27
27
|
put ':model_slug/:id/rate(/:new_rating)' => 'assets#rate', as: :rate_asset
|
28
28
|
get ':model_slug/search/:query.json' => 'assets#search', as: :search_assets
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graph_starter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Underwood
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 6.0.0.
|
33
|
+
version: 6.0.0.rc
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 6.0.0.
|
40
|
+
version: 6.0.0.rc
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: semantic-ui-sass
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- app/views/graph_starter/assets/index.html.slim
|
151
151
|
- app/views/graph_starter/assets/new.html.slim
|
152
152
|
- app/views/graph_starter/assets/show.html.slim
|
153
|
+
- app/views/graph_starter/assets/show.json.jbuilder
|
153
154
|
- app/views/graph_starter/authorizables/show.json.jbuilder
|
154
155
|
- app/views/graph_starter/authorizables/user_and_group_search.json.jbuilder
|
155
156
|
- app/views/graph_starter/categories/show.html.slim
|