resource_renderer 1.2.6 → 1.3.0

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: 60d698eeffefb491be6bb2bc9eeb9a6a2357c83e
4
- data.tar.gz: 2190a273079f6c92292cd13f749291723bd1c699
3
+ metadata.gz: a3ecfe1e591fee96ea9976ead738555b2ae398e9
4
+ data.tar.gz: 84f900f4a627fd4bec960dae5a30e1d14b0d4324
5
5
  SHA512:
6
- metadata.gz: 48223ad05645e083b49c43ed84d351ff2891f27aa126d757f8943cfc6ffd4b144691c4dd390111315b81e03a1d888353a5e3b30bfd344032b27cfa5231c03a2d
7
- data.tar.gz: 7b725cff4ca408a44a42192bb8d70c186cab45ffdbbd94b04249b3ebf2fd61eb8c3903c4940f86141268aa0f9ce20d1a088eddf78f1ff85786e23364123f5cdf
6
+ metadata.gz: cba9c6b711b146190447ad661b20f104061608c61bff030517c01ad3c0a333bd92bc2d80bcee09e832faace6a25508cafca3562bee957708a64ee8f8657df839
7
+ data.tar.gz: 8c6455db030ed61c1555e14fa189b2921b2c438cbcdac21e52a3d8c4fea73209b6150f9cfe3dbda5e72c80fa206bdfd05af8ebc70247d86f031bf5174f7293e6
@@ -0,0 +1,22 @@
1
+ class AwesomeNestedSetRenderer < ResourceRenderer::AttributeRenderer::Base
2
+ def display(attribute_name, label, options = {}, &block)
3
+ options.reverse_merge!(scope: nil)
4
+
5
+ scope = options.delete(:scope)
6
+
7
+ # scope = "#{scope}_id".intern if scope.is_a?(Symbol) && scope.to_s !~ /_id$/
8
+
9
+ data_attributes = {
10
+ 'awesome-nested-set-item': true,
11
+ 'awesome-nested-set-item-uid': model.to_param,
12
+ 'awesome-nested-set-item-on-drop-target': h.url_for([:reposition, model])
13
+ }
14
+ # data_attributes['awesome-nested-set-item-scope'] = "#{scope}-#{model.send(scope)}" if scope.present?
15
+ data_attributes['awesome-nested-set-item-scope'] = scope.call(model) if scope.present?
16
+
17
+
18
+ h.content_tag(:span, data: data_attributes, class: 'btn btn-xs btn-default awesome-nested-set-item') do
19
+ h.tag(:span, class: 'glyphicon glyphicon-sort')
20
+ end
21
+ end
22
+ end
@@ -56,6 +56,10 @@ class TableCollectionRenderer < ResourceRenderer::CollectionRenderer::Base
56
56
  def acts_as_list_actions(options = {})
57
57
  column(:acts_as_published_actions)
58
58
  end
59
+
60
+ def awesome_nested_set_actions(options = {})
61
+ column(:awesome_nested_set_actions)
62
+ end
59
63
  private
60
64
 
61
65
  def column_with_sorting(attribute_name, options = {})
@@ -53,6 +53,14 @@ class TableResourceRenderer < ResourceRenderer::ResourceRenderer::Base
53
53
  column :acts_as_list_actions, column_options
54
54
  end
55
55
 
56
+ def awesome_nested_set_actions(options = {})
57
+ scope = options[:scope]
58
+
59
+ column_options = { as: :awesome_nested_set }
60
+ column_options[:scope] = scope if scope.present?
61
+ column :awesome_nested_set_actions, column_options
62
+ end
63
+
56
64
  private
57
65
 
58
66
  def build_table_data(attribute_name, options = {}, &block)
@@ -1,3 +1,3 @@
1
1
  module ResourceRenderer
2
- VERSION = '1.2.6'
2
+ VERSION = '1.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resource_renderer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.6
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-18 00:00:00.000000000 Z
11
+ date: 2016-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -178,6 +178,7 @@ files:
178
178
  - app/attribute_renderers/array_renderer.rb
179
179
  - app/attribute_renderers/association_renderer.rb
180
180
  - app/attribute_renderers/attachment_renderer.rb
181
+ - app/attribute_renderers/awesome_nested_set_renderer.rb
181
182
  - app/attribute_renderers/big_decimal_renderer.rb
182
183
  - app/attribute_renderers/boolean_renderer.rb
183
184
  - app/attribute_renderers/date_renderer.rb