graph_starter 0.6.1 → 0.6.2
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: b7ac9279e5dab5c536514d8cf61bc16548bdff3a
|
4
|
+
data.tar.gz: a2d83d9cb07bc829cf3d801ae0807e12c6896400
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd023ba0acc4a0719ac257244cfb52aca43afa7a8088d3996ea27e61e4ab388a9241bc9ead8390e761f02380f279599162fdfd7f6269bcb42a1d36baf53db71b
|
7
|
+
data.tar.gz: e8ea82d6f9d71ecfbe2192cf25949319daaa0051d43e7d8df3acd6473c9f83a3f430dcebc8d199b69e000da65494fc98b5e91dbf82bf100d18f704e009d78fc9
|
@@ -18,7 +18,7 @@ module GraphStarter
|
|
18
18
|
title: asset.title,
|
19
19
|
url: asset_path(id: asset, model_slug: asset.class.model_slug),
|
20
20
|
description: description,
|
21
|
-
image:
|
21
|
+
image: asset.first_image_source_url
|
22
22
|
}.reject {|_, v| v.nil? }.tap do |result|
|
23
23
|
model_class.search_properties.each do |property|
|
24
24
|
result[property] = asset.read_attribute(property)
|
@@ -33,8 +33,9 @@ module GraphStarter
|
|
33
33
|
|
34
34
|
def asset_set(var = :asset)
|
35
35
|
associations = []
|
36
|
-
associations <<
|
37
|
-
associations << model_class.category_association
|
36
|
+
associations << model_class.image_association
|
37
|
+
associations << model_class.category_association
|
38
|
+
associations.compact
|
38
39
|
|
39
40
|
scope = model_class_scope(var)
|
40
41
|
scope = yield scope if block_given?
|
@@ -86,10 +87,6 @@ module GraphStarter
|
|
86
87
|
model_class_scope.find(params[:id])
|
87
88
|
end
|
88
89
|
|
89
|
-
def images?
|
90
|
-
model_class_scope.has_images?
|
91
|
-
end
|
92
|
-
|
93
90
|
def model_class_scope(var = :asset)
|
94
91
|
#@model_class_scope = if defined?(current_user)
|
95
92
|
# model_class.authorized_for(current_user)
|
@@ -27,19 +27,39 @@ module GraphStarter
|
|
27
27
|
def self.has_images
|
28
28
|
@has_images = true
|
29
29
|
has_many :out, :images, type: :HAS_IMAGE, model_class: '::GraphStarter::Image'
|
30
|
-
has_one :out, :image, type: :HAS_IMAGE, model_class: '::GraphStarter::Image'
|
31
30
|
end
|
32
31
|
|
33
32
|
def self.has_image
|
34
|
-
|
33
|
+
@has_image = true
|
34
|
+
has_one :out, :image, type: :HAS_IMAGE, model_class: '::GraphStarter::Image'
|
35
35
|
end
|
36
36
|
|
37
37
|
def self.has_images?
|
38
38
|
!!@has_images
|
39
39
|
end
|
40
40
|
|
41
|
+
def self.has_image?
|
42
|
+
!!@has_image
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.image_association
|
46
|
+
if has_images?
|
47
|
+
:images
|
48
|
+
elsif has_image?
|
49
|
+
:image
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def first_image
|
54
|
+
if self.class.has_images?
|
55
|
+
images.first
|
56
|
+
elsif self.class.has_image?
|
57
|
+
image
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
41
61
|
def first_image_source_url
|
42
|
-
|
62
|
+
first_image && first_image.source_url
|
43
63
|
end
|
44
64
|
|
45
65
|
def self.category_association(association_name = nil)
|
@@ -14,7 +14,7 @@
|
|
14
14
|
.right.floated.meta
|
15
15
|
i.hide.large.red.icon
|
16
16
|
.header = link_to asset.title, asset_path(asset)
|
17
|
-
- if asset.class.has_images?
|
17
|
+
- if asset.class.has_images? || asset.class.has_image?
|
18
18
|
.image
|
19
19
|
- if asset.first_image_source_url.present?
|
20
20
|
= image_tag asset.first_image_source_url
|