awesome_nested_set-tools 0.0.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/awesome_nested_set/tools/helper.rb +17 -14
- data/lib/awesome_nested_set/tools/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64a9e07fa1a431b3d9c525f4f8159a6b2903e40f
|
4
|
+
data.tar.gz: 37fca9a5bc7fedbedf338efd91ff3ee84960d82f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 667ed2a418d37165d2586232480024d6d74806caae09e5e9c7cb8632ed771d8e85193a9dd158d4b19b8fa116abf1e5a634139da8ba35f16f84e9908ba34f0685
|
7
|
+
data.tar.gz: 4c76f91a6ba861c098fcd1a48f88b46b7ee4912533bfc6eab12a475f703181638e6d7d65d0c7be266db1e80c42a88d19361436c39ce781c2221ece360cde1e6f
|
@@ -2,17 +2,20 @@ module AwesomeNestedSet
|
|
2
2
|
module Tools
|
3
3
|
module Helper
|
4
4
|
def nested_li(objects, options = {}, &block)
|
5
|
-
options.reverse_merge!
|
6
|
-
|
5
|
+
options.reverse_merge!({
|
6
|
+
tree_css_classes: 'list-group',
|
7
|
+
item_css_classes: 'list-group-item'
|
8
|
+
})
|
9
|
+
|
7
10
|
objects = objects.order(:lft) if objects.is_a? Class
|
8
11
|
|
9
12
|
return '' if objects.size == 0
|
10
13
|
|
11
14
|
if objects.first.root?
|
12
|
-
output = "<ul class=\"#{options[:
|
15
|
+
output = "<ul class=\"#{options[:tree_css_classes]}\"><li class=\"#{options[:item_css_classes]}\">"
|
13
16
|
else
|
14
17
|
output = ''
|
15
|
-
end
|
18
|
+
end
|
16
19
|
path = [nil]
|
17
20
|
|
18
21
|
objects.each_with_index do |o, i|
|
@@ -24,27 +27,27 @@ module AwesomeNestedSet
|
|
24
27
|
path.pop
|
25
28
|
output << '</li></ul>'
|
26
29
|
end
|
27
|
-
output <<
|
30
|
+
output << "</li><li class=\"#{options[:item_css_classes]}\">"
|
28
31
|
else
|
29
32
|
path << o.parent_id
|
30
33
|
if i == 0 && !objects.first.root?
|
31
|
-
output << "<ul class=\"#{options[:
|
34
|
+
output << "<ul class=\"#{options[:tree_css_classes]}\"><li class=\"#{options[:item_css_classes]}\">"
|
32
35
|
else
|
33
|
-
output <<
|
36
|
+
output << "<ul><li class=\"#{options[:item_css_classes]}\">"
|
34
37
|
end
|
35
38
|
end
|
36
39
|
elsif i != 0
|
37
|
-
output <<
|
40
|
+
output << "</li><li class=\"#{options[:item_css_classes]}\">"
|
38
41
|
end
|
39
|
-
o = o.first if o.is_a? Array
|
42
|
+
o = o.first if o.is_a? Array
|
40
43
|
output << capture(o, path.size - 1, &block)
|
41
44
|
end
|
42
|
-
|
45
|
+
|
43
46
|
if objects.first.root?
|
44
47
|
output << '</li></ul>' * path.length
|
45
48
|
else
|
46
49
|
output << '</li></ul>' * (path.length - 1)
|
47
|
-
end
|
50
|
+
end
|
48
51
|
output.html_safe
|
49
52
|
end
|
50
53
|
|
@@ -83,7 +86,7 @@ module AwesomeNestedSet
|
|
83
86
|
recombine_lists(results, children_of, o.id)
|
84
87
|
end
|
85
88
|
end
|
86
|
-
end
|
89
|
+
end
|
87
90
|
end
|
88
|
-
end
|
89
|
-
end
|
91
|
+
end
|
92
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awesome_nested_set-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.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: 2015-10-
|
11
|
+
date: 2015-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|