the_sortable_tree 1.9.4 → 2.0.0
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.
- data/MIT-LICENSE +4 -2
- data/README.md +237 -438
- data/app/assets/images/iconza/{gray → icons}/add.png +0 -0
- data/app/assets/images/iconza/{gray → icons}/delete.png +0 -0
- data/app/assets/images/iconza/{gray → icons}/edit.png +0 -0
- data/app/assets/images/iconza/icons/move.png +0 -0
- data/app/assets/images/iconza/{red/add.png → icons/red_add.png} +0 -0
- data/app/assets/images/iconza/{red/delete.png → icons/red_delete.png} +0 -0
- data/app/assets/images/iconza/{red/edit.png → icons/red_edit.png} +0 -0
- data/app/assets/images/iconza/icons/red_move.png +0 -0
- data/app/assets/javascripts/render_tree_helper.js.coffee +82 -0
- data/app/assets/javascripts/sortable_tree/initializer.js.coffee +54 -0
- data/app/assets/stylesheets/sortable_tree.css.scss +106 -0
- data/app/assets/stylesheets/tree.css.scss +26 -29
- data/app/controllers/the_sortable_tree_controller.rb +3 -2
- data/app/helpers/render_sortable_tree_helper.rb +62 -0
- data/app/helpers/render_tree_helper.rb +45 -0
- data/app/helpers/the_sortable_tree_helper.rb +67 -52
- data/app/views/sortable/client/_tree.html.erb +9 -0
- data/app/views/tree/client/_tree.html.erb +23 -0
- data/lib/fake.example +44 -0
- data/lib/generators/the_sortable_tree/views_generator.rb +29 -18
- data/lib/the_sortable_tree.rb +4 -8
- data/lib/the_sortable_tree/engine.rb +1 -1
- data/lib/the_sortable_tree/version.rb +1 -1
- metadata +31 -60
- data/app/assets/images/iconza/blue/add.png +0 -0
- data/app/assets/images/iconza/blue/delete.png +0 -0
- data/app/assets/images/iconza/blue/down.png +0 -0
- data/app/assets/images/iconza/blue/downloads_folder.png +0 -0
- data/app/assets/images/iconza/blue/edit.png +0 -0
- data/app/assets/images/iconza/blue/move.png +0 -0
- data/app/assets/images/iconza/blue/up.png +0 -0
- data/app/assets/images/iconza/gray/down.png +0 -0
- data/app/assets/images/iconza/gray/lock.png +0 -0
- data/app/assets/images/iconza/gray/mail.png +0 -0
- data/app/assets/images/iconza/gray/push_pin.png +0 -0
- data/app/assets/images/iconza/gray/up.png +0 -0
- data/app/assets/images/iconza/red/down.png +0 -0
- data/app/assets/images/iconza/red/newspaper.png +0 -0
- data/app/assets/images/iconza/red/trash.png +0 -0
- data/app/assets/images/iconza/red/up.png +0 -0
- data/app/assets/images/iconza/red/zoom.png +0 -0
- data/app/assets/javascripts/comments/base.js.coffee +0 -46
- data/app/assets/javascripts/sortable/base.js.coffee +0 -47
- data/app/assets/stylesheets/comments_tree.css.scss +0 -84
- data/app/assets/stylesheets/sortable.css.scss +0 -106
- data/app/views/comments/base/_children.html.haml +0 -1
- data/app/views/comments/base/_comment.html.haml +0 -8
- data/app/views/comments/base/_new_comment_form.html.haml +0 -18
- data/app/views/comments/base/_node.html.haml +0 -3
- data/app/views/comments/base/_tree.html.haml +0 -5
- data/app/views/sortable/base/_children.html.haml +0 -1
- data/app/views/sortable/base/_controls.html.haml +0 -16
- data/app/views/sortable/base/_link.html.haml +0 -7
- data/app/views/sortable/base/_new.html.haml +0 -3
- data/app/views/sortable/base/_node.html.haml +0 -3
- data/app/views/sortable/base/_tree.html.haml +0 -12
- data/app/views/tree/base/_children.html.haml +0 -1
- data/app/views/tree/base/_link.html.haml +0 -1
- data/app/views/tree/base/_node.html.haml +0 -3
- data/app/views/tree/base/_tree.html.haml +0 -3
- data/config/locales/en.yml +0 -31
- data/config/locales/ru.yml +0 -31
- data/lib/tasks/the_sortable_tree.rake +0 -4
data/MIT-LICENSE
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright 2009-2013 Ilya N. Zykin (the-teacher), Mikhail Dieterle (Mik-die), Matthew Clark
|
2
4
|
|
3
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
6
|
a copy of this software and associated documentation files (the
|
@@ -17,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,438 +1,237 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
**
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
//= require
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
```
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
```
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
```
|
177
|
-
|
178
|
-
```
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
```
|
183
|
-
|
184
|
-
```
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
t.string :contacts
|
239
|
-
t.text :content
|
240
|
-
end
|
241
|
-
```
|
242
|
-
|
243
|
-
You can call helper with next params:
|
244
|
-
|
245
|
-
``` ruby
|
246
|
-
= sortable_tree @comments, :type => :comments, :title => :topic, :contacts_field => :contacts, :raw_content_field => :content, :content_field => :content
|
247
|
-
```
|
248
|
-
|
249
|
-
### Customization
|
250
|
-
|
251
|
-
TheSortableTree view generator will copy a set of partials from gem to your View directory.
|
252
|
-
|
253
|
-
``` ruby
|
254
|
-
rails g the_sortable_tree:views Model [option]
|
255
|
-
```
|
256
|
-
|
257
|
-
## Examples
|
258
|
-
|
259
|
-
### Customize your tree
|
260
|
-
|
261
|
-
``` ruby
|
262
|
-
rails g the_sortable_tree:views Page
|
263
|
-
```
|
264
|
-
|
265
|
-
And render with partials from **pages/tree/base**
|
266
|
-
|
267
|
-
``` ruby
|
268
|
-
= sortable_tree @pages, :path => 'pages/tree/base'
|
269
|
-
```
|
270
|
-
|
271
|
-
### Customize your sortable tree
|
272
|
-
|
273
|
-
``` ruby
|
274
|
-
rails g the_sortable_tree:views Page sortable
|
275
|
-
```
|
276
|
-
|
277
|
-
And render with partials from **pages/sortable/base**
|
278
|
-
|
279
|
-
``` ruby
|
280
|
-
= sortable_tree @pages, :path => 'pages/sortable/base', :new_url => new_page_path
|
281
|
-
```
|
282
|
-
|
283
|
-
### Customize your comments tree
|
284
|
-
|
285
|
-
``` ruby
|
286
|
-
rails g the_sortable_tree:views Comment comments
|
287
|
-
```
|
288
|
-
|
289
|
-
And render with partials from **comments/comments/base**
|
290
|
-
|
291
|
-
``` ruby
|
292
|
-
= sortable_tree @comments, :path => 'comments/comments/base', :title => :name
|
293
|
-
```
|
294
|
-
|
295
|
-
### Troubleshooting
|
296
|
-
|
297
|
-
If you need to render a part of tree:
|
298
|
-
|
299
|
-
``` ruby
|
300
|
-
@root = Page.root
|
301
|
-
@pages = @root.descendants.nested_set.all
|
302
|
-
```
|
303
|
-
|
304
|
-
``` ruby
|
305
|
-
= @root.inspect
|
306
|
-
= sortable_tree @pages
|
307
|
-
```
|
308
|
-
|
309
|
-
If **TheSortableTree** can't correctly define a Name of your Model, just add **sortable_model** into your Controller:
|
310
|
-
|
311
|
-
``` ruby
|
312
|
-
class Inventory::CategoriesController < ApplicationController
|
313
|
-
include TheSortableTreeController::Rebuild
|
314
|
-
|
315
|
-
def sortable_model
|
316
|
-
Inventory::Category
|
317
|
-
end
|
318
|
-
|
319
|
-
def index
|
320
|
-
@inventory_categories = Inventory::Category.nested_set.all
|
321
|
-
end
|
322
|
-
|
323
|
-
def manage
|
324
|
-
@inventory_categories = Inventory::Category.nested_set.all
|
325
|
-
end
|
326
|
-
end
|
327
|
-
```
|
328
|
-
|
329
|
-
How can I render a **select/options** menu in form? Should I use TheSortableTree?
|
330
|
-
|
331
|
-
No. You should not. TheSortableTree is helper for building composite interfaces. Simple dropdown menu can be rendering with Awesome Nested Set Helper **sorted_nested_set_options**
|
332
|
-
|
333
|
-
There is Example:
|
334
|
-
|
335
|
-
```ruby
|
336
|
-
- sorted_nested_set_options(Catalog, lambda{ |catalog| catalog.lft }) do |catalog, level|
|
337
|
-
- options << content_tag(:option, catalog.title, :value => catalog.id, :class => "level_#{level}")
|
338
|
-
|
339
|
-
= f.select :catalog_id, options, {}
|
340
|
-
```
|
341
|
-
|
342
|
-
### Comments Options
|
343
|
-
|
344
|
-
**node_id** - comment's id which should be set as value of hidden field **parend_id** when Reply link pressed (**:id** by default)
|
345
|
-
|
346
|
-
**contacts_field** - **:email** field by default. If you want to hide contacts field - you should use customization by view generators
|
347
|
-
|
348
|
-
**content_field** - field with prepared comment's content (**:content** by default)
|
349
|
-
|
350
|
-
**raw_content_field** - field with raw comment's content (**:raw_content** by default, you can set it to **:content**)
|
351
|
-
|
352
|
-
### Common Options
|
353
|
-
|
354
|
-
**id** - id field (**:id** by default)
|
355
|
-
|
356
|
-
**title** - title field of node (**:title** by default)
|
357
|
-
|
358
|
-
**path** - path to custom view partials (:path => 'pages/sortable/tree')
|
359
|
-
|
360
|
-
**max_levels** - count of draggable levels or **max reply level** in comments tree. (**3** by default). **Can't be 0 (zero) and negative**
|
361
|
-
|
362
|
-
**namespace** - namespace for admin sections for example. (**nil** by default)
|
363
|
-
|
364
|
-
**opts[:level]** - view helper define level of recursion for each node. You can call **opts[:level]** into view partials
|
365
|
-
|
366
|
-
### Base partial's descriptions
|
367
|
-
|
368
|
-
**_tree** - root container for nested set elements
|
369
|
-
|
370
|
-
**_node** - element of tree (link to current node and nested set of children)
|
371
|
-
|
372
|
-
**_link** - decoration of link to current element of tree
|
373
|
-
|
374
|
-
**_children** - decoration of children
|
375
|
-
|
376
|
-
**_new** - create new element link
|
377
|
-
|
378
|
-
**_controls** - control elements for current node
|
379
|
-
|
380
|
-
### Can I use gem with Rails 2 or Rails 3.0?
|
381
|
-
|
382
|
-
There is no strong dependencies for Rails 3.
|
383
|
-
|
384
|
-
Take files from the gem and put it in your Rails 2 application.
|
385
|
-
|
386
|
-
And fix errors :) Ha-Ha-Ha! You can ask me if you will do it.
|
387
|
-
|
388
|
-
### Changelog
|
389
|
-
|
390
|
-
1.9.4 - rm CoffeeScript document scope, ru locale, fix data-confirm
|
391
|
-
|
392
|
-
1.9.3 - Jeffery Utter patch for coffee script
|
393
|
-
|
394
|
-
1.9.2 - View Generators updated
|
395
|
-
|
396
|
-
1.9.1 - Rewrite with coffee => **assets/javascripts/sortable/base.js.coffee**
|
397
|
-
|
398
|
-
1.9.0 - 1) **Helper API changed!** 2) Comments tree with sand form and reply fu! 3) Way to manual set sortable Model klass into controller.
|
399
|
-
|
400
|
-
1.8.6 - fixed CamelCase names definition (by andisthejackass)
|
401
|
-
|
402
|
-
1.8.5 - helper can rendering a part tree
|
403
|
-
|
404
|
-
1.8.0 - stable release
|
405
|
-
|
406
|
-
### Is it fast?
|
407
|
-
|
408
|
-
Hmmmm...
|
409
|
-
|
410
|
-
* Development env
|
411
|
-
* 584 elements
|
412
|
-
* 3 levels deep
|
413
|
-
|
414
|
-
Rendered by 50 sec.
|
415
|
-
|
416
|
-
I think it is good result for rendering by partials.
|
417
|
-
|
418
|
-
### Can it be faster?
|
419
|
-
|
420
|
-
Perhaps. Read next idea to learn more. There is no implementation now, sorry.
|
421
|
-
|
422
|
-
https://github.com/the-teacher/the_sortable_tree/issues/milestones?with_issues=no
|
423
|
-
|
424
|
-
### ERB vs HAML vs SLIM
|
425
|
-
|
426
|
-
HAML by default. You can use any Template Engine, but convert partials by yourself, plz.
|
427
|
-
|
428
|
-
### Contributors
|
429
|
-
|
430
|
-
* https://github.com/the-teacher
|
431
|
-
* https://github.com/winescout
|
432
|
-
* https://github.com/gbrain
|
433
|
-
* https://github.com/Mik-die
|
434
|
-
|
435
|
-
### Acknowledgments
|
436
|
-
|
437
|
-
* https://github.com/mjsarfatti/nestedSortable
|
438
|
-
* http://iconza.com
|
1
|
+
# TheSortableTree v2.0.0
|
2
|
+
|
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
|
+
|
5
|
+
## Sortable tree. Drag&Drop GUI
|
6
|
+
|
7
|
+

|
8
|
+
|
9
|
+
## Render tree
|
10
|
+
|
11
|
+

|
12
|
+
|
13
|
+
## Keywords
|
14
|
+
|
15
|
+
Awesome nested set, Nested set, Ruby, Rails, Nested set view helper, Sortable nested set, Drag&Drop GUI for nested set, View helper for nested set, render tree
|
16
|
+
|
17
|
+
## Install
|
18
|
+
|
19
|
+
**Gemfile** (Rails 4)
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
gem 'awesome_nested_set' # or any similar gem (gem 'nested_set')
|
23
|
+
gem 'the_sortable_tree'
|
24
|
+
```
|
25
|
+
|
26
|
+
**Gemfile** (Rails 3)
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
gem 'awesome_nested_set'
|
30
|
+
gem 'the_sortable_tree', :branch => "rails_3"
|
31
|
+
```
|
32
|
+
|
33
|
+
Console
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
bundle
|
37
|
+
```
|
38
|
+
|
39
|
+
## Using
|
40
|
+
|
41
|
+
#### JQuery and JavaScripts
|
42
|
+
|
43
|
+
**app/assets/javascripts/application.js**
|
44
|
+
|
45
|
+
Sortable GUI require JQuery libs
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
//= require jquery
|
49
|
+
//= require jquery-ui
|
50
|
+
//= require jquery_ujs
|
51
|
+
```
|
52
|
+
|
53
|
+
Add next JS only for Sortable GUI
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
//= require jquery.ui.nestedSortable
|
57
|
+
//= require sortable_tree/initializer
|
58
|
+
```
|
59
|
+
|
60
|
+
#### Stylesheets
|
61
|
+
|
62
|
+
**app/assets/stylesheets/application.css**
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
*= require tree
|
66
|
+
*= require sortable_tree
|
67
|
+
```
|
68
|
+
|
69
|
+
### Extend your Routes for Sortable GUI
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
resources :pages do
|
73
|
+
collection do
|
74
|
+
get :manage
|
75
|
+
|
76
|
+
# required for Sortable GUI server side actions
|
77
|
+
post :rebuild
|
78
|
+
end
|
79
|
+
end
|
80
|
+
```
|
81
|
+
|
82
|
+
**manage** - just page, where you want render Sortable tree.
|
83
|
+
|
84
|
+
### Extend your Model
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
class Page < ActiveRecord::Base
|
88
|
+
include TheSortableTree::Scopes
|
89
|
+
|
90
|
+
# any code here
|
91
|
+
end
|
92
|
+
```
|
93
|
+
|
94
|
+
### Extend your controller and find your tree
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
class PagesController < ApplicationController
|
98
|
+
include TheSortableTreeController::Rebuild
|
99
|
+
|
100
|
+
def manage
|
101
|
+
@pages = Page.nested_set.select('id, title, content, parent_id').all
|
102
|
+
end
|
103
|
+
|
104
|
+
# any code here
|
105
|
+
end
|
106
|
+
```
|
107
|
+
|
108
|
+
## Render Tree
|
109
|
+
|
110
|
+
**app/views/pages/manage.html.haml**
|
111
|
+
|
112
|
+
```haml
|
113
|
+
%ol.tree= build_server_tree @pages
|
114
|
+
```
|
115
|
+
|
116
|
+
## Render Sortable Tree
|
117
|
+
|
118
|
+
**app/views/pages/manage.html.haml**
|
119
|
+
|
120
|
+
```haml
|
121
|
+
%ol.sortable_tree{ data: { max_levels: 5, rebuild_url: rebuild_pages_url } }
|
122
|
+
= build_server_tree @pages, type: :sortable
|
123
|
+
```
|
124
|
+
|
125
|
+
## build_server_tree options
|
126
|
+
|
127
|
+
**Client side:**
|
128
|
+
|
129
|
+
Required params for sortable GUI! Must be defined at root element of tree.
|
130
|
+
|
131
|
+
1. **max_levels** - maximum depth of nesting
|
132
|
+
2. **rebuild_url** - URL to rebuild method on server side
|
133
|
+
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
%ol.sortable_tree{ data: { max_levels: 3, rebuild_url: rebuild_pages_url } }
|
137
|
+
```
|
138
|
+
|
139
|
+
**Server side:**
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
options[:NAME]
|
143
|
+
```
|
144
|
+
|
145
|
+
Optional params
|
146
|
+
|
147
|
+
1. **id** - id field of node
|
148
|
+
2. **title** - title field of node
|
149
|
+
3. **type** - type of tree [tree|sortable]
|
150
|
+
4. **namespace** - for example: **:admin**. **[]** - by default
|
151
|
+
5. **render_module** - your own Render Tree Helper
|
152
|
+
|
153
|
+
**Rendering runtime params (see code of render helpers):**
|
154
|
+
|
155
|
+
You can use next options, when rendering run:
|
156
|
+
|
157
|
+
1. **level** - level number
|
158
|
+
2. **root** - root flag [true|false]
|
159
|
+
3. **klass** - class name
|
160
|
+
4. **has_children** - has children flag [true|false]
|
161
|
+
5. **children** - array of children
|
162
|
+
|
163
|
+
## Customization
|
164
|
+
|
165
|
+
Try to run next view generators:
|
166
|
+
|
167
|
+
Render helpers for HTML tree generation
|
168
|
+
|
169
|
+
```ruby
|
170
|
+
bundle exec rails g the_sortable_tree:views tree
|
171
|
+
bundle exec rails g the_sortable_tree:views sortable
|
172
|
+
```
|
173
|
+
|
174
|
+
Base Render helper of gem
|
175
|
+
|
176
|
+
```ruby
|
177
|
+
bundle exec rails g the_sortable_tree:views helper
|
178
|
+
```
|
179
|
+
|
180
|
+
Assets of gem
|
181
|
+
|
182
|
+
```ruby
|
183
|
+
bundle exec rails g the_sortable_tree:views assets
|
184
|
+
```
|
185
|
+
|
186
|
+
## I want to know more
|
187
|
+
|
188
|
+
1. [How to change HTML code of tree?](https://github.com/the-teacher/the_sortable_tree/blob/master/docs/How_to_change_HTML_code_of_tree.md)
|
189
|
+
2. [How to create new tree HTML Builder helper?](https://github.com/the-teacher/the_sortable_tree/blob/master/docs/How_to_create_new_tree_Render_Helper.md)
|
190
|
+
3. [I need to render reversed tree](https://github.com/the-teacher/the_sortable_tree/blob/master/docs/I_need_to_render_reversed_tree.md)
|
191
|
+
4. [Gem can't correctly define a Name of your Model](https://github.com/the-teacher/the_sortable_tree/blob/master/docs/How_to_correctly_define_a_Name_of_your_Model.md)
|
192
|
+
5. [ChangeLog](https://github.com/the-teacher/the_sortable_tree/blob/master/docs/ChangeLog.md)
|
193
|
+
|
194
|
+
## Is it fast? Yes, it is!
|
195
|
+
|
196
|
+
BANCHMARK:
|
197
|
+
|
198
|
+
- Server Side, 16.000 nodes, 3 levels
|
199
|
+
- Views: 7999.6ms | ActiveRecord: 79.2ms
|
200
|
+
- WebInspector full time ~ 9.64s
|
201
|
+
|
202
|
+
total: ~**2000 nodes/sec**
|
203
|
+
|
204
|
+
## Looking for maintainers
|
205
|
+
|
206
|
+
Do you want to be open source contributor? There are some ideas:
|
207
|
+
|
208
|
+
Try to create view helpers for:
|
209
|
+
|
210
|
+
1. Mongoid NestedSet
|
211
|
+
2. acts_as_ordered_tree
|
212
|
+
5. Expand tree via AJAX
|
213
|
+
4. Comments Tree gem
|
214
|
+
3. gem Ancestry (???)
|
215
|
+
|
216
|
+
## The MIT License (MIT)
|
217
|
+
|
218
|
+
Copyright 2009-2013 Ilya N. Zykin (the-teacher), Mikhail Dieterle (Mik-die), Matthew Clark
|
219
|
+
|
220
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
221
|
+
a copy of this software and associated documentation files (the
|
222
|
+
"Software"), to deal in the Software without restriction, including
|
223
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
224
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
225
|
+
permit persons to whom the Software is furnished to do so, subject to
|
226
|
+
the following conditions:
|
227
|
+
|
228
|
+
The above copyright notice and this permission notice shall be
|
229
|
+
included in all copies or substantial portions of the Software.
|
230
|
+
|
231
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
232
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
233
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
234
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
235
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
236
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
237
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|