jquery_sortable_tree 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -0
- data/app/helpers/jquery_sortable_tree_helper/render_expandable_tree_helper.rb +0 -6
- data/app/helpers/jquery_sortable_tree_helper/render_indented_options_helper.rb +1 -11
- data/app/helpers/jquery_sortable_tree_helper/render_nested_options_helper.rb +1 -7
- data/app/helpers/jquery_sortable_tree_helper/render_optgroup_helper.rb +11 -0
- data/app/helpers/jquery_sortable_tree_helper/render_sortable_tree_helper.rb +8 -4
- data/app/helpers/jquery_sortable_tree_helper/render_tree_helper.rb +0 -6
- data/app/helpers/jquery_sortable_tree_helper.rb +10 -4
- data/lib/jquery_sortable_tree/version.rb +1 -1
- data/spec/{dummy_app/spec/build_tree_helper.rb → build_tree_helper.rb} +0 -0
- data/spec/dummy_app/Gemfile.lock +1 -1
- data/spec/dummy_app/app/controllers/admin/pages_controller.rb +9 -4
- data/spec/dummy_app/app/controllers/pages_controller.rb +11 -3
- data/spec/dummy_app/app/views/admin/pages/optgroup.html.haml +3 -0
- data/spec/dummy_app/app/views/pages/optgroup.html.haml +3 -0
- data/spec/dummy_app/app/views/welcome/index.html.haml +3 -0
- data/spec/dummy_app/config/application.rb +1 -0
- data/spec/dummy_app/config/routes.rb +9 -17
- data/spec/dummy_app/db/test.db +0 -0
- data/spec/dummy_app/log/development.log +559 -0
- data/spec/dummy_app/log/test.log +21016 -0
- data/spec/dummy_app/tmp/cache/assets/development/sprockets/14805e3ed08782f4b821fe6cfd03d911 +0 -0
- data/spec/dummy_app/tmp/cache/assets/development/sprockets/1e445aefca5bc750ef4f584ec1dc0849 +0 -0
- data/spec/dummy_app/tmp/cache/assets/development/sprockets/28eefd9e9c7ea2e1414cd10a6d184ae5 +0 -0
- data/spec/dummy_app/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy_app/tmp/cache/assets/development/sprockets/3dbf5c413607e86fa3ff1f931887217e +0 -0
- data/spec/dummy_app/tmp/cache/assets/development/sprockets/505027f29aa1c70c5425d19ea9fb77ce +0 -0
- data/spec/dummy_app/tmp/cache/assets/development/sprockets/6016aac84581a1ff8e9503adf790f0eb +0 -0
- data/spec/dummy_app/tmp/cache/assets/development/sprockets/7eecec59a10631fead107d7e8c265910 +0 -0
- data/spec/dummy_app/tmp/cache/assets/development/sprockets/a0ac3dab292e1eb99d5e8a524e6dfded +0 -0
- data/spec/dummy_app/tmp/cache/assets/development/sprockets/a2e4e33192daa77f118bde803b5f469e +0 -0
- data/spec/dummy_app/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy_app/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/{dummy_app/spec/views → views}/pages/index.html.haml_spec.rb +14 -10
- metadata +57 -7
- data/app/inputs/indented_collection_select_input.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 176af5700482ebd2c556ebbaebd76c840561735e
|
4
|
+
data.tar.gz: c510f8471e7283d03bb3dd5dead8385df941a4eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9b0fa92c763b3827e23ff075a36618899d72f198f2fd33c537dacad3aee385c914233ed1bd4c072a691deee894fd866dbbabfdc1268ca54a6a9cd5b077e4c2d
|
7
|
+
data.tar.gz: 94768b423e5e75c85595762b0bfc5c25de6e274f6a1c16dfb2d4b9fcee8adbc9597ea532c66052110f159c967e7463857f1657a5663b269e71ca55e7db69bd7b
|
data/README.md
CHANGED
@@ -29,6 +29,10 @@ Nested Set + Drag&Drop GUI. Very fast! Best render helper! **2000 nodes/sec**. R
|
|
29
29
|
|
30
30
|
![Indented options](docs/indented_options.jpg)
|
31
31
|
|
32
|
+
## Render Optgroup
|
33
|
+
|
34
|
+
![Optgroup](docs/optgroup.jpg)
|
35
|
+
|
32
36
|
## Expandable tree
|
33
37
|
|
34
38
|
![Expandable](docs/expandable.jpg)
|
@@ -161,6 +165,25 @@ build_server_tree(tree, options)
|
|
161
165
|
|
162
166
|
This uses CSS styling, for indenting with spaces, use **indented_options** instead.
|
163
167
|
|
168
|
+
## Render Indented Options Tree
|
169
|
+
|
170
|
+
```haml
|
171
|
+
= select_tag :page_id, indented_options(@pages, :selected => Page.last)
|
172
|
+
```
|
173
|
+
|
174
|
+
**indented_options** is just alias of **build_server_tree(tree, type: :indented_options)**
|
175
|
+
|
176
|
+
## Render Optgroup Tree
|
177
|
+
|
178
|
+
```haml
|
179
|
+
= select_tag :page_id, optgroup(@pages, :selected => Page.last)
|
180
|
+
```
|
181
|
+
|
182
|
+
**optgroup** is just alias of **build_server_tree(tree, type: :indented_options)**
|
183
|
+
The only difference between **indented_options** and **optgroup** is the selectable of parent nodes.
|
184
|
+
Indented options allows to select parent nodes, but optgroup does not.
|
185
|
+
|
186
|
+
|
164
187
|
|
165
188
|
## build_server_tree options
|
166
189
|
|
@@ -9,12 +9,6 @@
|
|
9
9
|
module JquerySortableTreeHelper
|
10
10
|
module RenderExpandableTreeHelper
|
11
11
|
class Render < JquerySortableTreeHelper::RenderSortableTreeHelper::Render
|
12
|
-
attr_accessor :h, :options
|
13
|
-
|
14
|
-
def initialize(h, options)
|
15
|
-
@h, @options = h, options
|
16
|
-
end
|
17
|
-
|
18
12
|
def div_item
|
19
13
|
h.content_tag(:div, handle + expand_button + edit_link + controls, class: :item)
|
20
14
|
end
|
@@ -1,12 +1,6 @@
|
|
1
1
|
module JquerySortableTreeHelper
|
2
2
|
module RenderIndentedOptionsHelper
|
3
|
-
class Render
|
4
|
-
attr_accessor :h, :options
|
5
|
-
|
6
|
-
def initialize(h, options)
|
7
|
-
@h, @options = h, options
|
8
|
-
end
|
9
|
-
|
3
|
+
class Render < JquerySortableTreeHelper::RenderSortableTreeHelper::Render
|
10
4
|
def render_node
|
11
5
|
h.content_tag(:option, title, tag_options) + children
|
12
6
|
end
|
@@ -25,10 +19,6 @@ module JquerySortableTreeHelper
|
|
25
19
|
html_options
|
26
20
|
end
|
27
21
|
|
28
|
-
def node
|
29
|
-
@options[:node]
|
30
|
-
end
|
31
|
-
|
32
22
|
def children
|
33
23
|
@options[:children].html_safe
|
34
24
|
end
|
@@ -1,12 +1,6 @@
|
|
1
1
|
module JquerySortableTreeHelper
|
2
2
|
module RenderNestedOptionsHelper
|
3
|
-
class Render
|
4
|
-
attr_accessor :h, :options
|
5
|
-
|
6
|
-
def initialize(h, options)
|
7
|
-
@h, @options = h, options
|
8
|
-
end
|
9
|
-
|
3
|
+
class Render < JquerySortableTreeHelper::RenderSortableTreeHelper::Render
|
10
4
|
def render_node
|
11
5
|
@h.content_tag(:option, options[:node].send(options[:title]), tag_options) + children
|
12
6
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module JquerySortableTreeHelper
|
2
|
+
module RenderOptgroupHelper
|
3
|
+
class Render < JquerySortableTreeHelper::RenderIndentedOptionsHelper::Render
|
4
|
+
def tag_options
|
5
|
+
html_options = super
|
6
|
+
html_options[:disabled] = 'true' unless options[:children].blank?
|
7
|
+
html_options
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -18,7 +18,7 @@ module JquerySortableTreeHelper
|
|
18
18
|
def render_node
|
19
19
|
return h.content_tag(:li, div_item + children,
|
20
20
|
class: :node,
|
21
|
-
data: { node_id:
|
21
|
+
data: { node_id: node.id }
|
22
22
|
)
|
23
23
|
end
|
24
24
|
|
@@ -31,13 +31,13 @@ module JquerySortableTreeHelper
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def edit_link
|
34
|
-
h.content_tag(:h4, h.link_to(
|
34
|
+
h.content_tag(:h4, h.link_to(node.send(options[:title]), show_path, class: :edit))
|
35
35
|
end
|
36
36
|
|
37
37
|
def show_link
|
38
38
|
h.content_tag(:h4,
|
39
|
-
h.link_to(
|
40
|
-
h.url_for(options[:namespace] + [
|
39
|
+
h.link_to(node.send(options[:title]),
|
40
|
+
h.url_for(options[:namespace] + [node]))
|
41
41
|
)
|
42
42
|
end
|
43
43
|
|
@@ -57,6 +57,10 @@ module JquerySortableTreeHelper
|
|
57
57
|
h.content_tag(:ol, options[:children].html_safe, class: :nested_set) unless options[:children].blank?
|
58
58
|
end
|
59
59
|
|
60
|
+
def node
|
61
|
+
@options[:node]
|
62
|
+
end
|
63
|
+
|
60
64
|
def show_path
|
61
65
|
h.url_for(controller: (options[:controller] || (options[:klass] && options[:klass].pluralize)), action: :show, id: options[:node].id, format: :json)
|
62
66
|
end
|
@@ -9,12 +9,6 @@
|
|
9
9
|
module JquerySortableTreeHelper
|
10
10
|
module RenderTreeHelper
|
11
11
|
class Render < JquerySortableTreeHelper::RenderSortableTreeHelper::Render
|
12
|
-
attr_accessor :h, :options
|
13
|
-
|
14
|
-
def initialize(h, options)
|
15
|
-
@h, @options = h, options
|
16
|
-
end
|
17
|
-
|
18
12
|
def div_item
|
19
13
|
h.content_tag(:div, show_link, class: :item)
|
20
14
|
end
|
@@ -6,7 +6,8 @@ module JquerySortableTreeHelper
|
|
6
6
|
sortable: RenderSortableTreeHelper,
|
7
7
|
expandable: RenderExpandableTreeHelper,
|
8
8
|
nested_options: RenderNestedOptionsHelper,
|
9
|
-
indented_options: RenderIndentedOptionsHelper
|
9
|
+
indented_options: RenderIndentedOptionsHelper,
|
10
|
+
optgroup: RenderOptgroupHelper
|
10
11
|
}.freeze
|
11
12
|
|
12
13
|
###############################################
|
@@ -49,6 +50,7 @@ module JquerySortableTreeHelper
|
|
49
50
|
end
|
50
51
|
|
51
52
|
def fake_node(options)
|
53
|
+
options[:title] ||= 'title'
|
52
54
|
OpenStruct.new(options[:title] => '', id: ':id', children: nil)
|
53
55
|
end
|
54
56
|
|
@@ -82,15 +84,19 @@ module JquerySortableTreeHelper
|
|
82
84
|
end
|
83
85
|
|
84
86
|
def nested_options(tree, options = {})
|
85
|
-
build_server_tree(tree, { type: :nested_options }.merge
|
87
|
+
build_server_tree(tree, { type: :nested_options }.merge(options))
|
86
88
|
end
|
87
89
|
|
88
90
|
def indented_options(tree, options = {})
|
89
|
-
build_server_tree(tree, { type: :indented_options }.merge
|
91
|
+
build_server_tree(tree, { type: :indented_options }.merge(options))
|
90
92
|
end
|
91
93
|
|
92
94
|
def expandable_tree(tree, options = {})
|
93
|
-
build_server_tree(tree, { type: :expandable }.merge
|
95
|
+
build_server_tree(tree, { type: :expandable }.merge(options))
|
96
|
+
end
|
97
|
+
|
98
|
+
def optgroup(tree, options = {})
|
99
|
+
build_server_tree(tree, { type: :optgroup }.merge(options))
|
94
100
|
end
|
95
101
|
|
96
102
|
###############################################
|
File without changes
|
data/spec/dummy_app/Gemfile.lock
CHANGED
@@ -1,20 +1,21 @@
|
|
1
1
|
class Admin::PagesController < ApplicationController
|
2
2
|
include JquerySortableTreeController::Rebuild
|
3
3
|
|
4
|
+
before_action :load_pages, only: [:index, :manage, :nested_options, :indented_options, :optgroup]
|
5
|
+
|
4
6
|
def index
|
5
|
-
@pages = Admin::Page.nested_set.select('id, title, content, parent_id').limit(15)
|
6
7
|
end
|
7
8
|
|
8
9
|
def manage
|
9
|
-
@pages = Admin::Page.nested_set.select('id, title, content, parent_id').limit(15)
|
10
10
|
end
|
11
11
|
|
12
12
|
def nested_options
|
13
|
-
@pages = Admin::Page.nested_set.select('id, title, content, parent_id').limit(15)
|
14
13
|
end
|
15
14
|
|
16
15
|
def indented_options
|
17
|
-
|
16
|
+
end
|
17
|
+
|
18
|
+
def optgroup
|
18
19
|
end
|
19
20
|
|
20
21
|
def node_manage
|
@@ -25,6 +26,10 @@ class Admin::PagesController < ApplicationController
|
|
25
26
|
|
26
27
|
protected
|
27
28
|
|
29
|
+
def load_pages
|
30
|
+
@pages = Admin::Page.nested_set.select('id, title, content, parent_id').limit(15)
|
31
|
+
end
|
32
|
+
|
28
33
|
def sortable_model
|
29
34
|
Admin::Page
|
30
35
|
end
|
@@ -2,16 +2,18 @@ class PagesController < ApplicationController
|
|
2
2
|
include JquerySortableTreeController::Rebuild
|
3
3
|
include JquerySortableTreeController::ExpandNode
|
4
4
|
|
5
|
+
before_action :load_pages, only: [:index, :nested_options, :indented_options, :optgroup]
|
6
|
+
|
5
7
|
def index
|
6
|
-
@pages = Page.nested_set.select('id, title, content, parent_id').limit(15)
|
7
8
|
end
|
8
9
|
|
9
10
|
def nested_options
|
10
|
-
@pages = Page.nested_set.select('id, title, content, parent_id').limit(15)
|
11
11
|
end
|
12
12
|
|
13
13
|
def indented_options
|
14
|
-
|
14
|
+
end
|
15
|
+
|
16
|
+
def optgroup
|
15
17
|
end
|
16
18
|
|
17
19
|
def manage
|
@@ -27,4 +29,10 @@ class PagesController < ApplicationController
|
|
27
29
|
def expand
|
28
30
|
@pages = Page.nested_set.roots.select('id, title, content, parent_id')
|
29
31
|
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def load_pages
|
36
|
+
@pages = Page.nested_set.select('id, title, content, parent_id').limit(15)
|
37
|
+
end
|
30
38
|
end
|
@@ -8,16 +8,19 @@
|
|
8
8
|
%li= link_to 'pages/index (just tree)', pages_path
|
9
9
|
%li= link_to 'pages/nested_options', nested_options_pages_path
|
10
10
|
%li= link_to 'pages/indented_options', indented_options_pages_path
|
11
|
+
%li= link_to 'pages/optgroup', optgroup_pages_path
|
11
12
|
%li= link_to 'pages/manage (sortable tree)', manage_pages_path
|
12
13
|
%li= link_to 'pages/node_manage (sortable tree)', node_manage_pages_path
|
13
14
|
%li= link_to 'pages/expand (expandable tree)', expand_pages_path
|
14
15
|
|
16
|
+
|
15
17
|
%h5 Admin::Pages (model Admin::Pages + namespace :admin)
|
16
18
|
|
17
19
|
%ul
|
18
20
|
%li= link_to '/admin/pages/index (just tree)', admin_pages_path
|
19
21
|
%li= link_to '/admin/pages/nested_options', nested_options_admin_pages_path
|
20
22
|
%li= link_to '/admin/pages/indented_options', indented_options_admin_pages_path
|
23
|
+
%li= link_to '/admin/pages/optgroup', optgroup_admin_pages_path
|
21
24
|
%li= link_to '/admin/pages/manage (sortable tree)', manage_admin_pages_path
|
22
25
|
%li= link_to '/admin/pages/node_manage (sortable tree)', node_manage_admin_pages_path
|
23
26
|
|
@@ -1,17 +1,17 @@
|
|
1
1
|
JquerySortableTreeTest::Application.routes.draw do
|
2
|
-
get
|
3
|
-
|
4
|
-
get "category/manage"
|
2
|
+
get 'category/index'
|
3
|
+
get 'category/manage'
|
5
4
|
|
6
5
|
root to: 'welcome#index'
|
7
6
|
|
8
7
|
resources :pages do
|
9
8
|
collection do
|
10
|
-
get
|
11
|
-
get
|
12
|
-
get
|
13
|
-
get
|
14
|
-
get
|
9
|
+
get :nested_options
|
10
|
+
get :indented_options
|
11
|
+
get :optgroup
|
12
|
+
get :manage
|
13
|
+
get :node_manage
|
14
|
+
get :expand
|
15
15
|
|
16
16
|
post :rebuild
|
17
17
|
post :expand_node
|
@@ -21,7 +21,7 @@ JquerySortableTreeTest::Application.routes.draw do
|
|
21
21
|
namespace :admin do
|
22
22
|
resources :pages do
|
23
23
|
collection do
|
24
|
-
get :nested_options, :indented_options, :manage, :node_manage
|
24
|
+
get :nested_options, :indented_options, :optgroup, :manage, :node_manage
|
25
25
|
post :rebuild
|
26
26
|
end
|
27
27
|
end
|
@@ -42,12 +42,4 @@ JquerySortableTreeTest::Application.routes.draw do
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
45
|
-
|
46
|
-
# resources :comments do
|
47
|
-
# collection do
|
48
|
-
# post :rebuild
|
49
|
-
# get :manage
|
50
|
-
# get :comments
|
51
|
-
# end
|
52
|
-
# end
|
53
45
|
end
|
data/spec/dummy_app/db/test.db
CHANGED
Binary file
|