the_sortable_tree 1.8.0 → 1.8.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +17 -0
- data/app/helpers/the_sortable_tree_helper.rb +13 -5
- data/lib/the_sortable_tree/version.rb +1 -1
- metadata +53 -83
data/README.md
CHANGED
@@ -33,6 +33,11 @@ Copy and Paste rebuild function from TheSortableTreeController.
|
|
33
33
|
|
34
34
|
Perhaps, you may have to slightly change the function of the controller.
|
35
35
|
|
36
|
+
### Changelog
|
37
|
+
|
38
|
+
1.8.5 - helper can rendering a part tree
|
39
|
+
1.8.0 - stable release
|
40
|
+
|
36
41
|
### Is it fast?
|
37
42
|
|
38
43
|
Hmmmm...
|
@@ -232,6 +237,18 @@ Customize and use it!
|
|
232
237
|
= sortable_tree @pages, :new_url => new_page_path, :path => 'pages/the_sortable_tree', :max_levels => 2
|
233
238
|
```
|
234
239
|
|
240
|
+
### Rendering a part of tree
|
241
|
+
|
242
|
+
``` ruby
|
243
|
+
@root = Page.root
|
244
|
+
@pages = @root.descendants.nested_set.all
|
245
|
+
```
|
246
|
+
|
247
|
+
``` ruby
|
248
|
+
= @root.inspect
|
249
|
+
= sortable_tree @pages, :new_url => new_page_path
|
250
|
+
```
|
251
|
+
|
235
252
|
### LiveDemo
|
236
253
|
|
237
254
|
https://github.com/the-teacher/the_sortable_tree_test_app
|
@@ -41,9 +41,17 @@ module TheSortableTreeHelper
|
|
41
41
|
node = opts[:node]
|
42
42
|
|
43
43
|
unless node
|
44
|
-
roots = tree.select{|elem| elem.parent_id.nil?}
|
44
|
+
roots = tree.select{ |elem| elem.parent_id.nil? }
|
45
|
+
|
46
|
+
# TODO: try to remove compact
|
47
|
+
# children rendering
|
48
|
+
if roots.empty? && !tree.empty?
|
49
|
+
min_parent_id = tree.map(&:parent_id).compact.min
|
50
|
+
roots = tree.select{ |elem| elem.parent_id == min_parent_id }
|
51
|
+
end
|
52
|
+
|
45
53
|
roots.each do |root|
|
46
|
-
_opts
|
54
|
+
_opts = opts.merge({:node => root, :root => true, :level => opts[:level].next})
|
47
55
|
result << sortable_tree_builder(tree, _opts)
|
48
56
|
end
|
49
57
|
else
|
@@ -51,11 +59,11 @@ module TheSortableTreeHelper
|
|
51
59
|
children = tree.select{|elem| elem.parent_id == node.id}
|
52
60
|
opts.merge!({:has_children => children.blank?})
|
53
61
|
children.each do |elem|
|
54
|
-
_opts
|
62
|
+
_opts = opts.merge({:node => elem, :root => false, :level => opts[:level].next})
|
55
63
|
children_res << sortable_tree_builder(tree, _opts)
|
56
64
|
end
|
57
65
|
result << render(:partial => "#{opts[:path]}/node", :locals => {:opts => opts, :root => root, :node => node, :children => children_res})
|
58
66
|
end
|
59
67
|
raw result
|
60
|
-
end
|
61
|
-
end
|
68
|
+
end
|
69
|
+
end
|
metadata
CHANGED
@@ -1,89 +1,68 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_sortable_tree
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.8.5
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 8
|
9
|
-
- 0
|
10
|
-
version: 1.8.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Ilya N. Zykin, Matthew Clark, Mikhail Dieterle
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-04-03 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: rails
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &80466760 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 3
|
31
|
-
- 1
|
32
|
-
version: "3.1"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.1'
|
33
22
|
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: sqlite3
|
37
23
|
prerelease: false
|
38
|
-
|
24
|
+
version_requirements: *80466760
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: sqlite3
|
27
|
+
requirement: &80466550 !ruby/object:Gem::Requirement
|
39
28
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
segments:
|
45
|
-
- 0
|
46
|
-
version: "0"
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
47
33
|
type: :development
|
48
|
-
version_requirements: *id002
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: rspec
|
51
34
|
prerelease: false
|
52
|
-
|
35
|
+
version_requirements: *80466550
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
requirement: &80466320 !ruby/object:Gem::Requirement
|
53
39
|
none: false
|
54
|
-
requirements:
|
55
|
-
- -
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
|
58
|
-
segments:
|
59
|
-
- 0
|
60
|
-
version: "0"
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
61
44
|
type: :development
|
62
|
-
version_requirements: *id003
|
63
|
-
- !ruby/object:Gem::Dependency
|
64
|
-
name: rspec-rails
|
65
45
|
prerelease: false
|
66
|
-
|
46
|
+
version_requirements: *80466320
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec-rails
|
49
|
+
requirement: &80466110 !ruby/object:Gem::Requirement
|
67
50
|
none: false
|
68
|
-
requirements:
|
69
|
-
- -
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
|
72
|
-
segments:
|
73
|
-
- 0
|
74
|
-
version: "0"
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
75
55
|
type: :development
|
76
|
-
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *80466110
|
77
58
|
description: Drag&Drop GUI helper for awesome_nested_set gem. Sortable tree view helper
|
78
|
-
email:
|
59
|
+
email:
|
79
60
|
- zykin-ilya@ya.ru
|
80
61
|
executables: []
|
81
|
-
|
82
62
|
extensions: []
|
83
|
-
|
84
|
-
extra_rdoc_files:
|
63
|
+
extra_rdoc_files:
|
85
64
|
- README.md
|
86
|
-
files:
|
65
|
+
files:
|
87
66
|
- app/controllers/the_sortable_tree_controller.rb
|
88
67
|
- app/assets/images/iconza/red/edit.png
|
89
68
|
- app/assets/images/iconza/red/down.png
|
@@ -169,38 +148,29 @@ files:
|
|
169
148
|
- spec/dummy/script/rails
|
170
149
|
homepage: https://github.com/the-teacher/the_sortable_tree
|
171
150
|
licenses: []
|
172
|
-
|
173
151
|
post_install_message:
|
174
152
|
rdoc_options: []
|
175
|
-
|
176
|
-
require_paths:
|
153
|
+
require_paths:
|
177
154
|
- lib
|
178
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
155
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
179
156
|
none: false
|
180
|
-
requirements:
|
181
|
-
- -
|
182
|
-
- !ruby/object:Gem::Version
|
183
|
-
|
184
|
-
|
185
|
-
- 0
|
186
|
-
version: "0"
|
187
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ! '>='
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
162
|
none: false
|
189
|
-
requirements:
|
190
|
-
- -
|
191
|
-
- !ruby/object:Gem::Version
|
192
|
-
|
193
|
-
segments:
|
194
|
-
- 0
|
195
|
-
version: "0"
|
163
|
+
requirements:
|
164
|
+
- - ! '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
196
167
|
requirements: []
|
197
|
-
|
198
168
|
rubyforge_project: the_sortable_tree
|
199
169
|
rubygems_version: 1.8.15
|
200
170
|
signing_key:
|
201
171
|
specification_version: 3
|
202
172
|
summary: Drag&Drop GUI helper for awesome_nested_set gem. Sortable tree view helper
|
203
|
-
test_files:
|
173
|
+
test_files:
|
204
174
|
- spec/controlllers/controller_mixin_spec.rb
|
205
175
|
- spec/spec_helper.rb
|
206
176
|
- spec/dummy/README.rdoc
|