rails_admin_nested_set 0.3.1 → 0.3.3

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: 2fce2a65eac5674759600702de8f7f24d6747d2f
4
- data.tar.gz: 1714bbceae8cd43619fc579acb53adabc91ac637
3
+ metadata.gz: eaca614b321bd75f019961125d72f029934c634c
4
+ data.tar.gz: 9b7a9a427601f078c45af3463f93c18f5147ff25
5
5
  SHA512:
6
- metadata.gz: 2391efafbe5eedacf14514fec4f8cb0e57af4562cf35bb9ae61362b3c030fd18f6a73dae1aa02cab521a3a4ce733e461559664c9fcba0d586d7ae6ebe72cc785
7
- data.tar.gz: e7dd6f8bbb7ae0fd81afd8f5729b159faedd73239c56f5beaff43b291f46f98b2b1e201c41cbe1b85a05edc6939ffdfb0fb57304dce60aa7cdaf6b4e62469076
6
+ metadata.gz: c6c0547158f84e74c8d6d3011fe6873603343b5bb772a43cccb235e0226ba4fca676cf8e0c88d8d4f9f57b8023c09ed9685623d8967ce7431036e57990f23788
7
+ data.tar.gz: aab28c14ec9e03696cf0b52b6b517462481b1fb255274087daca047d7d7f781ae0c92bbd129d1a1c7afdb6078f0ebbca764832a304cd07c125937cac7c5b37f9
@@ -35,10 +35,26 @@
35
35
  line-height: 20px;
36
36
  }
37
37
 
38
+ .dd-item .badge {
39
+ margin-right: 10px;
40
+ }
41
+
42
+ .dd-item img {
43
+ display: inline-block;
44
+ margin-left: 10px;
45
+ }
46
+
47
+ .dd-item > div {
48
+ position: relative
49
+ }
50
+
38
51
  .dd-handle {
39
52
  display: block;
40
- height: 30px;
41
- margin: 5px 0;
53
+ position: absolute;
54
+ top: 0;
55
+ left: 0;
56
+ bottom: 0;
57
+ width: 30px;
42
58
  padding: 5px 10px;
43
59
  color: #333;
44
60
  text-decoration: none;
@@ -74,7 +90,7 @@
74
90
 
75
91
  .dd3-content {
76
92
  display: block;
77
- height: 30px;
93
+ min-height: 30px;
78
94
  padding: 5px 10px 5px 40px;
79
95
  color: #333;
80
96
  text-decoration: none;
@@ -9,6 +9,14 @@ module RailsAdminNestedSet
9
9
  content + content_tag(:script, js.html_safe, type: 'text/javascript')
10
10
  end
11
11
 
12
+ def g_link(node, fv, on, badge)
13
+ link_to(
14
+ fv.html_safe,
15
+ toggle_path(model_name: @abstract_model, id: node.id, method: 'enabled', on: on.to_s),
16
+ method: :post,
17
+ class: 'badge ' + badge,
18
+ )
19
+ end
12
20
 
13
21
  def rails_admin_nested_set_builder(nodes, tree)
14
22
  nodes.map do |node|
@@ -17,8 +25,29 @@ module RailsAdminNestedSet
17
25
  content_tag :li, class: li_classes, :'data-id' => node.id do
18
26
  output = content_tag :div, 'drag', class: 'dd-handle dd3-handle'
19
27
  output+= content_tag :div, class: 'dd3-content' do
20
- content = link_to @model_config.with(object: node).object_label, edit_path(@abstract_model, node.id)
21
- content + content_tag(:div, action_links(node), class: 'pull-right links')
28
+ content = ''.html_safe
29
+
30
+ if node.respond_to?(:enabled) && respond_to?(:toggle_path)
31
+ content += case node.enabled
32
+ when nil
33
+ g_link(node, '✘', 0, 'badge-important') + g_link(node, '✓', 1, 'badge-success')
34
+ when false
35
+ g_link(node, '✘', 1, 'badge-important')
36
+ when true
37
+ g_link(node, '&#x2713', 0, 'badge-success')
38
+ else
39
+ %{<span class="badge">-</span>}
40
+ end.html_safe
41
+ end
42
+
43
+ content += link_to @model_config.with(object: node).object_label, edit_path(@abstract_model, node.id)
44
+ [:cover, :image].each do |mth|
45
+ if node.respond_to?(mth)
46
+ content += image_tag(node.send(mth), style: "max-height: 90px")
47
+ end
48
+ end
49
+ content += content_tag(:div, action_links(node), class: 'pull-right links')
50
+ content
22
51
  end
23
52
 
24
53
  children = tree.select{|elem| elem.parent_id == node.id}
@@ -1,3 +1,3 @@
1
1
  module RailsAdminNestedSet
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin_nested_set
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Tv