graph_starter 0.11.1 → 0.12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ec68f902c939f0d9fa77a0bd809f7bd028306a4
4
- data.tar.gz: 8f25eef0ecd140167da7192396ffbb35f6df2ce1
3
+ metadata.gz: 2e93b2fd5ab114bce65b7cd36d10356fcceb10d8
4
+ data.tar.gz: 6d1cb374a9e762c72dd1936fbee87713e73ae465
5
5
  SHA512:
6
- metadata.gz: e953e46300491928880f94d64fde22b4668f9a086a977c927a320c02810f811f69100c2586b4313f9c568d274ae2d166087ca1b7a0ea844eb42763cff9aa2066
7
- data.tar.gz: a7a320754fcbde4de9e04e5c4b04bd40e5d1206e402119cf52f51576a367b5af242345dcfb2c02ccc0808dcfa849b35214995b25ac809883da2c7774eec0594d
6
+ metadata.gz: c6a8a9430df7817c48146f63821a7dac8453f726205e53e34cc3dc64855eecc8c1281a250fa64ed06bb560f28b1dc5f9f75b08a4c10d91fddd172c8f0106ac14
7
+ data.tar.gz: 2fd86d7a0b3ad29214d240f0396f997f41da9a5058543e494931a67cedadeef0e2bde7b53d80f23c365ca8cca30516c8c80b757828b109406452e740ae8c5bda
@@ -156,8 +156,6 @@ module GraphStarter
156
156
 
157
157
  def self.body_property(property_name = nil)
158
158
  if property_name.nil?
159
- body_property(default_name_property) if @body_property.nil?
160
-
161
159
  @body_property
162
160
  else
163
161
  fail "Cannot declare body_property twice" if @body_property.present?
@@ -176,7 +174,7 @@ module GraphStarter
176
174
  fail "No body_property defined for #{self.name}!"
177
175
  end
178
176
 
179
- body_property || 'body'
177
+ @body_property
180
178
  end
181
179
 
182
180
 
@@ -210,11 +208,13 @@ module GraphStarter
210
208
 
211
209
  send(method_name)
212
210
  elsif method_name.to_sym == :body
213
- self.class.send(:define_method, method_name) do
214
- read_attribute(self.class.body_property)
215
- end
211
+ if self.class.body_property
212
+ self.class.send(:define_method, method_name) do
213
+ read_attribute(self.class.body_property)
214
+ end
216
215
 
217
- send(method_name)
216
+ send(method_name)
217
+ end
218
218
  else
219
219
  super
220
220
  end
@@ -363,7 +363,7 @@ module GraphStarter
363
363
  end
364
364
 
365
365
  def self.authorized_associations
366
- associations.except(*Asset.associations.keys + [:images, :image])
366
+ @authorized_associations ||= associations.except(*Asset.associations.keys + [:images, :image])
367
367
  end
368
368
 
369
369
  def self.icon_class
@@ -13,11 +13,27 @@ module GraphStarter
13
13
  end
14
14
 
15
15
  def left_sidebar_exists?
16
- @left_sidebar_exists ||= asset.class.authorized_associations.size > 2
16
+ @left_sidebar_exists ||= authorized_associations.size > 4
17
17
  end
18
18
 
19
19
  def main_column_exists?
20
- @main_column_exists ||= ((asset.class.has_images? || asset.class.has_image?) && asset.image_array.present?) || asset.body.present?
20
+ @main_column_exists ||= images_present? || body_present? || associations_in_body?
21
+ end
22
+
23
+ def images_present?
24
+ @images_present ||= ((asset.class.has_images? || asset.class.has_image?) && asset.image_array.present?)
25
+ end
26
+
27
+ def body_present?
28
+ @body_present ||= asset.body.present?
29
+ end
30
+
31
+ def associations_in_body?
32
+ @associations_in_body ||= !images_present? && !body_present? && authorized_associations.size > 0
33
+ end
34
+
35
+ def authorized_associations
36
+ @authorized_associations ||= asset.class.authorized_associations
21
37
  end
22
38
  end
23
39
  end
@@ -0,0 +1,21 @@
1
+ - as_cards = false if !defined?(as_cards)
2
+
3
+ - asset.class.authorized_associations.each do |name, association|
4
+ - result = asset.send(name)
5
+ - if result.present?
6
+ .item
7
+ .content
8
+ .ui.horizontal.divider = name.to_s.humanize
9
+ .description
10
+ - if as_cards
11
+ .ui.link.cards
12
+ - Array(result).each do |object|
13
+ = render partial: 'card', locals: {asset: object}
14
+ - else
15
+ .ui.middle.aligned.big.divided.list
16
+ - Array(result).each do |object|
17
+ .item
18
+ i class="#{association.target_class.icon_class} icon"
19
+ .content
20
+ = link_to object.title, asset_path(object)
21
+
@@ -0,0 +1,30 @@
1
+ .card
2
+ .content
3
+ - if asset.private?
4
+ .right.floated.meta
5
+ i.hide.large.red.icon
6
+ .header = link_to asset.safe_title, asset_path(asset)
7
+ - if asset.class.has_images? || asset.class.has_image?
8
+ .image
9
+ - if asset.first_image_source_url.present?
10
+ = image_tag asset.first_image_source_url
11
+ - else
12
+ = image_tag 'missing'
13
+ - categories = Array(asset.categories).sort_by(&:name)
14
+ - if categories.present?
15
+ .content
16
+ .ui.relaxed.divided.list
17
+ - categories[0,2].each do |category|
18
+ .item
19
+ - if (category.class.has_images? || category.class.has_image?) && category.first_image_source_url.present?
20
+ = image_tag category.first_image_source_url, class: 'ui avatar image'
21
+ - else
22
+ i class="#{category.class.icon_class || 'folder'} large icon"
23
+ .content
24
+ = link_to category.name, asset_path(category)
25
+ - if categories.size > 2
26
+ .item
27
+ i.ellipsis.horizontal.large.icon
28
+ .content more categories
29
+
30
+
@@ -8,32 +8,4 @@
8
8
 
9
9
  .ui.link.cards
10
10
  - asset_group.each do |asset|
11
- .card
12
- .content
13
- - if asset.private?
14
- .right.floated.meta
15
- i.hide.large.red.icon
16
- .header = link_to asset.safe_title, asset_path(asset)
17
- - if asset.class.has_images? || asset.class.has_image?
18
- .image
19
- - if asset.first_image_source_url.present?
20
- = image_tag asset.first_image_source_url
21
- - else
22
- = image_tag 'missing'
23
- - categories = Array(asset.categories).sort_by(&:name)
24
- - if categories.present?
25
- .content
26
- .ui.relaxed.divided.list
27
- - categories[0,2].each do |category|
28
- .item
29
- - if (category.class.has_images? || category.class.has_image?) && category.first_image_source_url.present?
30
- = image_tag category.first_image_source_url, class: 'ui avatar image'
31
- - else
32
- i class="#{category.class.icon_class || 'folder'} large icon"
33
- .content
34
- = link_to category.name, asset_path(category)
35
- - if categories.size > 2
36
- .item
37
- i.ellipsis.horizontal.large.icon
38
- .content more categories
39
-
11
+ = render partial: 'card', locals: {asset: asset}
@@ -18,6 +18,8 @@
18
18
  = render partial: 'graph_starter/properties/property', locals: {property: property, asset: @asset, form: f, can_write: can_write}
19
19
 
20
20
  - @asset.class.authorized_associations.each do |name, association|
21
+ - target_class = association.target_class
22
+ - next if !target_class.is_a?(GraphStarter::Asset)
21
23
  javascript:
22
24
  var current_#{name} = [];
23
25
 
@@ -25,7 +27,6 @@
25
27
  label = name.to_s.humanize
26
28
 
27
29
  - field_name = (association.type == :has_many ? "#{name.to_s.singularize}_ids" : "#{name}_id")
28
- - target_class = association.target_class
29
30
  - options = target_class.as(:n).pluck(target_class.name_property, target_class.id_property_name)
30
31
 
31
32
  - html_options = {class: 'ui fluid search dropdown'}
@@ -0,0 +1,11 @@
1
+ - recommendations = asset.secret_sauce_recommendations
2
+ - if recommendations.present?
3
+ .item
4
+ .content
5
+ .ui.horizontal.divider Recommended
6
+ .description
7
+ .ui.middle.aligned.big.divided.list
8
+ - recommendations.each do |recommendation|
9
+ .item data-score="#{recommendation.score}"
10
+ .content = link_to recommendation.asset.title, asset_path(recommendation.asset)
11
+
@@ -18,14 +18,20 @@ javascript:
18
18
 
19
19
  - if asset_presenter.main_column_exists?
20
20
  div class="#{center_width} wide column"
21
- = render_body(@asset, @model_slug)
21
+ - if asset_presenter.associations_in_body?
22
+ = render partial: 'associations', locals: {asset: @asset, as_cards: true}
23
+ - else
24
+ = render_body(@asset, @model_slug)
22
25
 
23
26
  div class="#{right_width} wide column" id="right-column"
24
27
  - if app_user_is_admin?
25
28
  = render partial: 'admin_buttons', locals: {asset: @asset}
26
29
 
27
30
  - if !asset_presenter.left_sidebar_exists?
28
- = render partial: 'dynamic_items', locals: {asset: @asset}
31
+ .ui.items
32
+ - if !asset_presenter.associations_in_body?
33
+ = render partial: 'associations', locals: {asset: @asset}
34
+ = render partial: 'recommendations', locals: {asset: @asset}
29
35
 
30
36
  = render partial: 'property_items', locals: {asset: @asset}
31
37
 
@@ -1,3 +1,3 @@
1
1
  module GraphStarter
2
- VERSION = "0.11.1"
2
+ VERSION = "0.12.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graph_starter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Underwood
@@ -135,12 +135,14 @@ files:
135
135
  - app/presenters/graph_starter/asset_presenter.rb
136
136
  - app/views/graph_starter/assets/TODO.md
137
137
  - app/views/graph_starter/assets/_admin_buttons.html.slim
138
+ - app/views/graph_starter/assets/_associations.html.slim
138
139
  - app/views/graph_starter/assets/_body.html.slim
140
+ - app/views/graph_starter/assets/_card.html.slim
139
141
  - app/views/graph_starter/assets/_cards.html.slim
140
- - app/views/graph_starter/assets/_dynamic_items.html.slim
141
142
  - app/views/graph_starter/assets/_form.html.slim
142
143
  - app/views/graph_starter/assets/_images.html.slim
143
144
  - app/views/graph_starter/assets/_property_items.html.slim
145
+ - app/views/graph_starter/assets/_recommendations.html.slim
144
146
  - app/views/graph_starter/assets/_search.html.slim
145
147
  - app/views/graph_starter/assets/edit.html.slim
146
148
  - app/views/graph_starter/assets/home.html.slim
@@ -1,48 +0,0 @@
1
- .ui.items
2
- .item
3
- .ui.statistic
4
- .label
5
- | Total Views
6
- .value
7
- = asset.total_view_count || 0
8
-
9
- .ui.statistic
10
- .label
11
- | Unique Views
12
- .value
13
- = asset.unique_view_count || 0
14
-
15
-
16
-
17
- - asset.class.authorized_associations.each do |name, association|
18
- - result = asset.send(name)
19
- - if result.present?
20
- .item
21
- .content
22
- .ui.horizontal.divider = name.to_s.humanize
23
- .description
24
- - case association.type
25
- - when :has_one
26
- - object = result
27
- i class="#{association.target_class.icon_class} icon"
28
- = link_to object.title, asset_path(object)
29
- - when :has_many
30
- .ui.middle.aligned.big.divided.list
31
- - result.each do |object|
32
- .item
33
- i class="#{association.target_class.icon_class} icon"
34
- .content
35
- = link_to object.title, asset_path(object)
36
-
37
- - recommendations = asset.secret_sauce_recommendations
38
- - if recommendations.present?
39
- .item
40
- .content
41
- .ui.horizontal.divider Recommended
42
- .description
43
- .ui.middle.aligned.big.divided.list
44
- - recommendations.each do |recommendation|
45
- .item data-score="#{recommendation.score}"
46
- .content = link_to recommendation.asset.title, asset_path(recommendation.asset)
47
-
48
-