the_sortable_tree 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# TheSortableTree v2.
|
1
|
+
# TheSortableTree v2.2.0
|
2
2
|
|
3
3
|
Nested Set + Drag&Drop GUI. Very fast! Best render helper! **2000 nodes/sec**. Ready for rails 4 ([RubyGems](http://rubygems.org/gems/the_sortable_tree))
|
4
4
|
|
@@ -103,31 +103,39 @@ class PagesController < ApplicationController
|
|
103
103
|
end
|
104
104
|
```
|
105
105
|
|
106
|
+
## Basic Render Method
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
build_server_tree(tree, options)
|
110
|
+
```
|
111
|
+
|
106
112
|
## Render Tree
|
107
113
|
|
108
114
|
**app/views/pages/manage.html.haml**
|
109
115
|
|
110
116
|
```haml
|
111
|
-
%ol.tree=
|
117
|
+
%ol.tree= just_tree @pages
|
112
118
|
```
|
113
119
|
|
114
|
-
|
120
|
+
**just_tree** is just alias of **build_server_tree(tree, type: :tree)**
|
115
121
|
|
116
|
-
|
122
|
+
## Render Sortable Tree
|
117
123
|
|
118
124
|
```haml
|
119
125
|
%ol.sortable_tree{ data: { max_levels: 5, rebuild_url: rebuild_pages_url } }
|
120
|
-
=
|
126
|
+
= sortable_tree @pages
|
121
127
|
```
|
128
|
+
**sortable_tree** is just alias of **build_server_tree(tree, type: :sortable)**
|
122
129
|
|
123
130
|
## Render Nested Options Tree
|
124
131
|
|
125
|
-
**app/views/pages/manage.html.haml**
|
126
|
-
|
127
132
|
```haml
|
128
|
-
= select_tag :
|
133
|
+
= select_tag :page_id, nested_options(@pages, :selected => Page.last), class: :nested_options
|
129
134
|
```
|
130
135
|
|
136
|
+
**nested_options** is just alias of **build_server_tree(tree, type: :nested_options)**
|
137
|
+
|
138
|
+
|
131
139
|
## build_server_tree options
|
132
140
|
|
133
141
|
**Client side:**
|
@@ -144,11 +152,20 @@ Required params for sortable GUI! Must be defined at root element of tree.
|
|
144
152
|
|
145
153
|
**Server side:**
|
146
154
|
|
155
|
+
|
156
|
+
define
|
157
|
+
|
158
|
+
```ruby
|
159
|
+
build_server_tree(pages, {:option_1 => :value_1, :option_2 => :value_2})
|
160
|
+
```
|
161
|
+
|
162
|
+
use
|
163
|
+
|
147
164
|
```ruby
|
148
165
|
options[:NAME]
|
149
166
|
```
|
150
167
|
|
151
|
-
|
168
|
+
Options list:
|
152
169
|
|
153
170
|
1. **id** - id field of node
|
154
171
|
2. **title** - title field of node
|
@@ -201,11 +218,12 @@ bundle exec rails g the_sortable_tree:views assets
|
|
201
218
|
|
202
219
|
BANCHMARK:
|
203
220
|
|
204
|
-
|
221
|
+
tree params: 16.000 nodes, 3 levels
|
222
|
+
|
205
223
|
- Views: 7999.6ms | ActiveRecord: 79.2ms
|
206
224
|
- WebInspector full time ~ 9.64s
|
207
225
|
|
208
|
-
total:
|
226
|
+
total: ~ **2000 nodes/sec**
|
209
227
|
|
210
228
|
## Looking for maintainers
|
211
229
|
|
@@ -219,6 +237,13 @@ Try to create view helpers for:
|
|
219
237
|
4. Comments Tree gem
|
220
238
|
3. gem Ancestry (???)
|
221
239
|
|
240
|
+
## I want to try! I need tests!
|
241
|
+
|
242
|
+
1. I'm develop gem with test app [the_sortable_tree_test_app](https://github.com/the-teacher/the_sortable_tree_test_app). You can clone it and see some testcase-pages for gem
|
243
|
+
2. Sorry, but I have not tests for this gem. Gem is so easy. It's easy to test only with test app.
|
244
|
+
3. You can write some tests, if your need.
|
245
|
+
4. No! I know RSpec. I can write tests. But I have not reasons to write tests here.
|
246
|
+
|
222
247
|
## Аcknowledgment
|
223
248
|
|
224
249
|
1. [mjsarfatti/nestedSortable](https://github.com/mjsarfatti/nestedSortable)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module RenderNestedOptionsHelper
|
2
2
|
class Render
|
3
3
|
class << self
|
4
4
|
attr_accessor :h, :options
|
@@ -10,7 +10,7 @@ module RenderSelectOptionsHelper
|
|
10
10
|
selected = (options[:selected] == node) ? ' selected' : nil
|
11
11
|
|
12
12
|
"
|
13
|
-
<option value='#{node[:id]}' class='l_#{ options[:level] }#{selected}'>#{ node[:title] }</option>
|
13
|
+
<option value='#{node[:id]}' class='l_#{ options[:level] }#{selected}'>#{ node.send(options[:title]) }</option>
|
14
14
|
#{ options[:children] }
|
15
15
|
"
|
16
16
|
end
|
@@ -9,7 +9,7 @@ module TheSortableTreeHelper
|
|
9
9
|
TREE_RENDERERS = {
|
10
10
|
:tree => RenderTreeHelper,
|
11
11
|
:sortable => RenderSortableTreeHelper,
|
12
|
-
:
|
12
|
+
:nested_options => RenderNestedOptionsHelper
|
13
13
|
}
|
14
14
|
|
15
15
|
###############################################
|
@@ -29,13 +29,19 @@ module TheSortableTreeHelper
|
|
29
29
|
end
|
30
30
|
|
31
31
|
###############################################
|
32
|
-
#
|
32
|
+
# Shortcuts
|
33
33
|
###############################################
|
34
|
+
|
35
|
+
def just_tree tree, options = {}
|
36
|
+
build_server_tree(tree, { :type => :tree }.merge!(options))
|
37
|
+
end
|
38
|
+
|
39
|
+
def sortable_tree tree, options = {}
|
40
|
+
build_server_tree(tree, { :type => :sortable }.merge!(options))
|
41
|
+
end
|
34
42
|
|
35
43
|
def nested_options tree, options = {}
|
36
|
-
|
37
|
-
opts.merge!(options)
|
38
|
-
build_server_tree(tree, opts)
|
44
|
+
build_server_tree(tree, { :type => :nested_options }.merge!(options))
|
39
45
|
end
|
40
46
|
|
41
47
|
###############################################
|
@@ -72,6 +78,8 @@ module TheSortableTreeHelper
|
|
72
78
|
opts[:klass] = define_class_of_elements_of(tree) unless opts[:klass]
|
73
79
|
|
74
80
|
# BOOST PATCH (BUILD ONCE)
|
81
|
+
# solution of main perfomance problem
|
82
|
+
# magick index-array, which made me happy!
|
75
83
|
if opts[:boost].empty?
|
76
84
|
tree.each do |item|
|
77
85
|
num = item.parent_id || 0
|
@@ -91,9 +99,11 @@ module TheSortableTreeHelper
|
|
91
99
|
end
|
92
100
|
|
93
101
|
# children rendering
|
94
|
-
roots
|
95
|
-
|
96
|
-
|
102
|
+
if roots
|
103
|
+
roots.each do |root|
|
104
|
+
_opts = opts.merge({ :node => root, :root => true, :level => opts[:level].next, :boost => opts[:boost] })
|
105
|
+
result << build_server_tree(tree, _opts)
|
106
|
+
end
|
97
107
|
end
|
98
108
|
else
|
99
109
|
# RENDER NODE'S CHILDREN
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_sortable_tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &85373190 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.1'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *85373190
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: sqlite3
|
27
|
-
requirement: &
|
27
|
+
requirement: &85372810 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *85372810
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &85372410 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *85372410
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec-rails
|
49
|
-
requirement: &
|
49
|
+
requirement: &85372120 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *85372120
|
58
58
|
description: Drag&Drop GUI for awesom_nested_set. Render Tree Helper. Very fast! Ready
|
59
59
|
for Rails 4
|
60
60
|
email:
|
@@ -81,10 +81,10 @@ files:
|
|
81
81
|
- app/assets/javascripts/sortable_tree/initializer.js.coffee
|
82
82
|
- app/views/sortable/client/_tree.html.erb
|
83
83
|
- app/views/tree/client/_tree.html.erb
|
84
|
-
- app/helpers/render_select_options_helper.rb
|
85
84
|
- app/helpers/render_tree_helper.rb
|
86
85
|
- app/helpers/the_sortable_tree_helper.rb
|
87
86
|
- app/helpers/render_sortable_tree_helper.rb
|
87
|
+
- app/helpers/render_nested_options_helper.rb
|
88
88
|
- lib/the_sortable_tree/version.rb
|
89
89
|
- lib/the_sortable_tree/engine.rb
|
90
90
|
- lib/generators/the_sortable_tree/views_generator.rb
|