rails_admin_sort_embedded 0.1.0 → 0.1.1

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: dcf6ebd2958b3b0144c17cc6c39fc5575dce5205
4
- data.tar.gz: 3af26e237488484cf6859cde6c7a738b0f0e4cdf
3
+ metadata.gz: 7a3a89123a545d6635558c8dc335b46ea31fae6f
4
+ data.tar.gz: 9ec43c84610451802feb8753a9b48151941ea98b
5
5
  SHA512:
6
- metadata.gz: 847b12f747a99dd133a09f7401fa9f7a071daea20ee94ff936c1e33f574f15bb4fce12f6be744f8fc39890889ff6f6079b1d88b09431779d0b76649b9d8e3b5f
7
- data.tar.gz: 087e44e696dd10a6c7292b69ea8b6f6f63faf6a7afcf7130c093ecaa95b23473dc09c108c5a62f1282c513d4ec89a49208dc261b949a04961113789f73a1a26b
6
+ metadata.gz: 917a7a92b8cf96a99f032d9918041da9fcfac9baae563cbb5baedac7b84380b4282ab49f14a271ab44184060404d594c99f3cba29bcec12ccdfd1a87ed514593
7
+ data.tar.gz: 13859eee5e3652d9899e83ece40815b0a2a03cc7517250b65da70aab9a57cb9d57cb6db684565267e4721c42b1887268e55c81fbf162909b704bdaf5bafb00fa
@@ -8,6 +8,7 @@ module RailsAdminSortEmbedded
8
8
  @options ||= {
9
9
  fields: [{}],
10
10
  thumbnail_fields: [:image, :cover],
11
+ hint_fields: [],
11
12
  thumbnail_size: :thumb,
12
13
  thumbnail_gem: :paperclip,
13
14
  }.merge(config || {})
@@ -1,7 +1,7 @@
1
1
  module RailsAdminSortEmbedded
2
2
  module Helper
3
3
  def rails_admin_sort_embedded(tree, opts= {})
4
- tree = tree.to_a.sort_by { |m| m.send(opts[:embedded_model_order_field] || "order") }
4
+ tree = tree.to_a.sort_by { |m| m.send(opts[:embedded_model_order_field] || "order").to_i }
5
5
  roots = tree#.select{|elem| elem.parent_id.nil?}
6
6
  id = "ns_#{rand(100_000_000..999_999_999)}"
7
7
  tree_config = {update_url: sort_embedded_path(model_name: @abstract_model),
@@ -57,6 +57,25 @@ module RailsAdminSortEmbedded
57
57
  content += image_tag(img, style: "max-height: 40px; max-width: 100px;", class: 'pull-right')
58
58
  end
59
59
  end
60
+
61
+ sort_embedded_hint_fields.each do |hint|
62
+ if hint.is_a?(Array)
63
+ hint_field = hint[0]
64
+ if hint.size == 2
65
+ hint_args = hint[1]
66
+ else
67
+ hint_args = hint[1..-1].to_a
68
+ end
69
+ else
70
+ hint_field = hint
71
+ hint_args = nil
72
+ end
73
+
74
+ if node.respond_to?(hint_field)
75
+ html_code = (hint_args ? node.send(hint_field, *hint_args) : node.send(hint_field))
76
+ content += content_tag(:div, html_code, class: 'pull-right')
77
+ end
78
+ end
60
79
  content
61
80
  end
62
81
 
@@ -100,6 +119,9 @@ module RailsAdminSortEmbedded
100
119
  def sort_embedded_thumbnail_fields
101
120
  @sort_conf.options[:thumbnail_fields]
102
121
  end
122
+ def sort_embedded_hint_fields
123
+ @sort_conf.options[:hint_fields]
124
+ end
103
125
  def sort_embedded_paperclip?
104
126
  @sort_conf.options[:thumbnail_gem] == :paperclip
105
127
  end
@@ -1,3 +1,3 @@
1
1
  module RailsAdminSortEmbedded
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin_sort_embedded
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Kiseliev
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-12 00:00:00.000000000 Z
12
+ date: 2015-03-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails_admin