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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ba39a8bf4b8f837b968c093923dca37474fa52d
4
- data.tar.gz: 9d5467ecf2e9dd763aa582ed4c772b6d30ca4ad9
3
+ metadata.gz: 64a2154a735c343c9b8a826f52292ffde568d3a1
4
+ data.tar.gz: 8c098ff7b6d48c0663d2bbc7876dc624b5e07efd
5
5
  SHA512:
6
- metadata.gz: a5a2117422be0c98f4474ff04e55ee1ab725be9232c1df9d18a5977062dc8088c63b2f9ec7963fdacaf6cc07e46ee467aaab94e0898b46517ab49f1cdf04714b
7
- data.tar.gz: 7acdf172f6e9bebafe591ded966bcdab595be6303b10ca76ff6e219089b99eee3e11ba4e3f305fb1e2b903d894fa476a80f56ab7a5df5b39bfc73e373253e980
6
+ metadata.gz: 5f0308ad85cb0d8f83c138aaff589afe23fa67df1164b889f470c9f7b0f71df037841eb2a9c2a4c02ab0422147fcc03a3022f574369df712876d96e277edf8b2
7
+ data.tar.gz: 2e7152a1ee53e367a034d21c81042bd1bcf19ae64cad712615b6468f69f4f21c7d5f3b56127b96e8f41c9596e17bf1e167ef3a4deb0a4253e84a99a67fd3a7fa
@@ -65,7 +65,7 @@ module GraphStarter
65
65
 
66
66
  def update
67
67
  @asset = asset
68
- @asset.update(params[:book])
68
+ @asset.update(params[params[:model_slug].singularize])
69
69
 
70
70
  redirect_to action: :edit
71
71
  end
@@ -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
@@ -0,0 +1,10 @@
1
+ .ui.buttons
2
+ a.ui.labeled.icon.button.right.floated data-authorizable="#{asset.to_json}"
3
+ | Permissions
4
+
5
+ .or
6
+
7
+ a.ui.labeled.icon.button.right.floated href="#{edit_asset_path(id: asset)}"
8
+ i.edit.icon
9
+ | Edit
10
+
@@ -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
- label = property.name.humanize
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
- = render partial: 'graph_starter/properties/property', locals: {property: property, asset: @asset, level: level, form: f}
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
- = form.text_field property.name
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
@@ -1,3 +1,3 @@
1
1
  module GraphStarter
2
- VERSION = "0.7.2"
2
+ VERSION = "0.7.3"
3
3
  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.2
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-02 00:00:00.000000000 Z
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