graph_starter 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/graph_starter/assets_controller.rb +1 -1
- data/app/helpers/graph_starter/application_helper.rb +8 -0
- data/app/models/graph_starter/asset.rb +23 -2
- data/app/views/graph_starter/assets/_admin_buttons.html.slim +10 -0
- data/app/views/graph_starter/assets/_property_items.html.slim +0 -9
- data/app/views/graph_starter/assets/edit.html.slim +6 -2
- data/app/views/graph_starter/assets/show.html.slim +3 -0
- data/app/views/graph_starter/properties/_property.html.slim +10 -3
- data/lib/graph_starter/configuration.rb +6 -1
- data/lib/graph_starter/version.rb +1 -1
- 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: 64a2154a735c343c9b8a826f52292ffde568d3a1
|
4
|
+
data.tar.gz: 8c098ff7b6d48c0663d2bbc7876dc624b5e07efd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f0308ad85cb0d8f83c138aaff589afe23fa67df1164b889f470c9f7b0f71df037841eb2a9c2a4c02ab0422147fcc03a3022f574369df712876d96e277edf8b2
|
7
|
+
data.tar.gz: 2e7152a1ee53e367a034d21c81042bd1bcf19ae64cad712615b6468f69f4f21c7d5f3b56127b96e8f41c9596e17bf1e167ef3a4deb0a4253e84a99a67fd3a7fa
|
@@ -19,5 +19,13 @@ module GraphStarter
|
|
19
19
|
def present_asset(object)
|
20
20
|
yield(AssetPresenter.new(object, self)) if block_given?
|
21
21
|
end
|
22
|
+
|
23
|
+
def app_user_is_admin?
|
24
|
+
current_user && current_user.respond_to?(:admin?) && current_user.admin?
|
25
|
+
end
|
26
|
+
|
27
|
+
def app_user
|
28
|
+
defined?(:current_user) ? current_user : nil
|
29
|
+
end
|
22
30
|
end
|
23
31
|
end
|
@@ -90,6 +90,25 @@ module GraphStarter
|
|
90
90
|
end
|
91
91
|
|
92
92
|
|
93
|
+
def self.enumerable_property(property_name, values)
|
94
|
+
fail "values needs to be an Array, was #{values.inspect}" if !values.is_a?(Array)
|
95
|
+
|
96
|
+
validates :status, inclusion: {in: values}
|
97
|
+
|
98
|
+
enumerable_property_values[self.name.to_sym] ||= {}
|
99
|
+
enumerable_property_values[self.name.to_sym][property_name.to_sym] ||= values
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.enumerable_property_values_for(property_name)
|
103
|
+
enumerable_property_values[self.name.to_sym] &&
|
104
|
+
enumerable_property_values[self.name.to_sym][property_name.to_sym]
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.enumerable_property_values
|
108
|
+
@enumerable_property_values ||= {}
|
109
|
+
end
|
110
|
+
|
111
|
+
|
93
112
|
def self.rated
|
94
113
|
@rated = true
|
95
114
|
end
|
@@ -242,9 +261,11 @@ module GraphStarter
|
|
242
261
|
{id: id,
|
243
262
|
title: title,
|
244
263
|
name: title,
|
245
|
-
images: images.map {|image| image.source.url },
|
246
264
|
model_slug: self.class.model_slug}
|
247
|
-
}
|
265
|
+
}.tap do |result|
|
266
|
+
result[:images] = images.map {|image| image.source.url } if self.class.has_images?
|
267
|
+
result[:image] = image.source.url if self.class.has_image?
|
268
|
+
end
|
248
269
|
end
|
249
270
|
|
250
271
|
def self.descendants
|
@@ -1,12 +1,3 @@
|
|
1
|
-
- if @current_user_is_admin
|
2
|
-
a.ui.labeled.icon.button.right.floated data-authorizable="#{asset.to_json}"
|
3
|
-
| Edit Permissions
|
4
|
-
|
5
|
-
- if @current_user_is_admin
|
6
|
-
a.ui.labeled.icon.button.right.floated href="#{edit_asset_path(id: asset)}"
|
7
|
-
i.edit.icon
|
8
|
-
| Edit
|
9
|
-
|
10
1
|
.ui.items
|
11
2
|
- if asset.class.rated? && defined?(current_user) && current_user
|
12
3
|
.item
|
@@ -14,9 +14,13 @@ h1 = @asset.name
|
|
14
14
|
|
15
15
|
- @asset.class.authorized_properties_and_levels(current_user).each do |property, level|
|
16
16
|
.field
|
17
|
-
|
17
|
+
- editable_properties = GraphStarter.configuration.editable_properties[@asset.class.name.to_sym]
|
18
|
+
- can_write = (level == 'write') && !f.nil? && (editable_properties.nil? || editable_properties.map(&:to_s).include?(property.name))
|
18
19
|
|
19
|
-
|
20
|
+
- if @asset.class.display_property?(property.name) || can_write
|
21
|
+
label = property.name.humanize
|
22
|
+
|
23
|
+
= render partial: 'graph_starter/properties/property', locals: {property: property, asset: @asset, form: f, can_write: can_write}
|
20
24
|
|
21
25
|
|
22
26
|
= f.submit 'Update', class: 'ui button'
|
@@ -21,6 +21,9 @@ javascript:
|
|
21
21
|
= render_body(@asset, @model_slug)
|
22
22
|
|
23
23
|
div class="#{right_width} wide column" id="right-column"
|
24
|
+
- if app_user_is_admin?
|
25
|
+
= render partial: 'admin_buttons', locals: {asset: @asset}
|
26
|
+
|
24
27
|
- if !asset_presenter.left_sidebar_exists?
|
25
28
|
= render partial: 'dynamic_items', locals: {asset: @asset}
|
26
29
|
|
@@ -1,5 +1,3 @@
|
|
1
|
-
- can_write = (level == 'write') && !form.nil?
|
2
|
-
|
3
1
|
- value = asset.read_attribute(property.name)
|
4
2
|
|
5
3
|
- ruby_type = property.ruby_type.to_s
|
@@ -28,9 +26,18 @@
|
|
28
26
|
- else
|
29
27
|
= value
|
30
28
|
|
29
|
+
- when /ActiveAttr::Typecasting::Boolean$/, /Boolean$/
|
30
|
+
- if can_write
|
31
|
+
= form.select property.name, [['True', true], ['False', false]], {}, class: 'ui dropdown'
|
32
|
+
- else
|
33
|
+
= value
|
31
34
|
- else
|
35
|
+
|
32
36
|
- if can_write
|
33
|
-
=
|
37
|
+
- if values = asset.class.enumerable_property_values_for(property.name)
|
38
|
+
= form.select property.name, values, {}, class: 'ui dropdown'
|
39
|
+
- else
|
40
|
+
= form.text_field property.name
|
34
41
|
- else
|
35
42
|
- if property.name.to_s.match(/url$/i)
|
36
43
|
= link_to value, value
|
@@ -2,11 +2,12 @@ module GraphStarter
|
|
2
2
|
class Configuration
|
3
3
|
attr_writer :user_class
|
4
4
|
|
5
|
-
attr_accessor :menu_models, :icon_classes, :scope_filters
|
5
|
+
attr_accessor :menu_models, :icon_classes, :scope_filters, :editable_properties
|
6
6
|
|
7
7
|
def initialize
|
8
8
|
@icon_classes = {}
|
9
9
|
@scope_filters = {}
|
10
|
+
@editable_properties = {}
|
10
11
|
end
|
11
12
|
|
12
13
|
def user_class
|
@@ -23,6 +24,10 @@ module GraphStarter
|
|
23
24
|
errors[:icon_classes] = 'should be a Hash'
|
24
25
|
end
|
25
26
|
|
27
|
+
if !@editable_properties.is_a?(Hash)
|
28
|
+
errors[:editable_properties] = 'should be a Hash'
|
29
|
+
end
|
30
|
+
|
26
31
|
if !@scope_filters.is_a?(Hash)
|
27
32
|
errors[:scope_filters] = 'should be a Hash'
|
28
33
|
end
|
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.7.
|
4
|
+
version: 0.7.3
|
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-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- app/presenters/graph_starter/application_presenter.rb
|
134
134
|
- app/presenters/graph_starter/asset_presenter.rb
|
135
135
|
- app/views/graph_starter/assets/TODO.md
|
136
|
+
- app/views/graph_starter/assets/_admin_buttons.html.slim
|
136
137
|
- app/views/graph_starter/assets/_body.html.slim
|
137
138
|
- app/views/graph_starter/assets/_cards.html.slim
|
138
139
|
- app/views/graph_starter/assets/_dynamic_items.html.slim
|