sortable_nested_set 0.1.24 → 0.1.25
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.
@@ -3,16 +3,16 @@ include CollectiveIdea::Acts::NestedSet::Helper
|
|
3
3
|
|
4
4
|
module SortableNestedSetHelper
|
5
5
|
def sortable_nested_set_tree(class_or_category)
|
6
|
-
if class_or_category.is_a?
|
6
|
+
if class_or_category.is_a?(Class)
|
7
7
|
@category_class = class_or_category
|
8
|
-
@categories = class_or_category.all
|
8
|
+
@categories = class_or_category.all(:include => class_or_category.sns_items_type, :order => :lft)
|
9
9
|
else
|
10
10
|
@category_class = class_or_category.class
|
11
11
|
@categories = class_or_category.self_and_descendants_with_items
|
12
12
|
@root = class_or_category
|
13
13
|
end
|
14
14
|
|
15
|
-
@sortable_ids = @categories.collect
|
15
|
+
@sortable_ids = @categories.collect(&:id)
|
16
16
|
|
17
17
|
render 'sortable_nested_set/tree',
|
18
18
|
:category_class => @category_class,
|
@@ -3,27 +3,29 @@
|
|
3
3
|
<%= render 'sortable_nested_set/toggle',
|
4
4
|
:category_type => category.class.name.underscore,
|
5
5
|
:id => category.id,
|
6
|
-
:state =>
|
6
|
+
:state => :open %>
|
7
7
|
|
8
8
|
<%= content_tag :span, category, :class => :handle %>
|
9
9
|
|
10
|
-
|
10
|
+
<% unless local_assigns[:show_mega_menu] == false %>
|
11
|
+
<%= content_tag :span, link_to('-', category), :id => "toggle_actions_category_#{category.id}", :class => :mega %>
|
11
12
|
|
12
|
-
<%= content_tag :div, :id => "actions_category_#{category.id}", :class => :links do %>
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
<%= content_tag :div, :id => "actions_category_#{category.id}", :class => :links do %>
|
14
|
+
<%= link_to_unless_current 'show', category %> |
|
15
|
+
<%= link_to 'edit', send("edit_#{cpath}", category) %> |
|
16
|
+
<% unless current_page? send(cpath, category) %>
|
17
|
+
<%= link_to 'remove',
|
18
|
+
send("sns_destroy_category_#{cpath}", category),
|
19
|
+
:confirm => 'Are you sure?',
|
20
|
+
:method => :delete,
|
21
|
+
:remote => true %> |
|
22
|
+
<% end %>
|
23
|
+
<%= link_to "add #{category.class.sns_subcategories_type.to_s.singularize}",
|
24
|
+
send("sns_add_subcategory_#{cpath}", category) %> |
|
25
|
+
<%= link_to "add #{category.class.sns_items_type.to_s.singularize}", send("sns_add_item_#{cpath}", category) %>
|
21
26
|
<% end %>
|
22
|
-
<%= link_to 'add subcategory', send("sns_add_subcategory_#{cpath}", category) %> |
|
23
|
-
<%= link_to 'add item', send("sns_add_item_#{cpath}", category) %>
|
24
27
|
<% end %>
|
25
28
|
|
26
29
|
<%= content_tag :div, :id => "items_#{category.id}", :class => :items do %>
|
27
|
-
<%= render :partial => 'sortable_nested_set/item',
|
28
|
-
:collection => category.sns_items %>
|
30
|
+
<%= render :partial => 'sortable_nested_set/item', :collection => category.sns_items %>
|
29
31
|
<% end %>
|
@@ -1,8 +1,6 @@
|
|
1
1
|
<%= stylesheet_link_tag 'mega_menu', 'menu_tree' %>
|
2
|
-
|
3
2
|
<%= javascript_tag nil, :src => 'http://www.google.com/jsapi' %>
|
4
3
|
<%= javascript_tag "google.load('jquery', '1.4.2')" %>
|
5
|
-
|
6
4
|
<%= javascript_include_tag 'jquery.hoverIntent.minified.js', 'mega_menu' %>
|
7
5
|
|
8
6
|
<%= content_tag :ul, :id => :menu, :class => :menu_links do %>
|
@@ -14,8 +12,10 @@
|
|
14
12
|
<%=raw '</ul></li>' if level <= prev_level %>
|
15
13
|
<%=raw '</ul>' * (prev_level - level) if level < prev_level %>
|
16
14
|
|
17
|
-
<li id="category_<%= category.id %>" class="category"
|
18
|
-
<%= render :partial => 'sortable_nested_set/category',
|
15
|
+
<li id="category_<%= category.id %>" <%=raw 'class="category"' unless category == root %>>
|
16
|
+
<%= render :partial => 'sortable_nested_set/category',
|
17
|
+
:object => category,
|
18
|
+
:locals => {:show_mega_menu => (category != root)} %>
|
19
19
|
|
20
20
|
<ul id="subcategories_<%= category.id %>" class="sub_menu_links">
|
21
21
|
<%= content_tag :li, :class => :placeholder do %>
|
@@ -29,6 +29,8 @@
|
|
29
29
|
<% end %>
|
30
30
|
|
31
31
|
<% unless categories.empty? %>
|
32
|
+
<% cpath = categories.first.class.name.pluralize.underscore + '_path' %>
|
33
|
+
|
32
34
|
<% for category_id in sortable_ids %>
|
33
35
|
<%= sortable_element_reporting_target "items_#{category_id}",
|
34
36
|
:moved,
|
@@ -36,7 +38,7 @@
|
|
36
38
|
:dropOnEmpty => true,
|
37
39
|
:method => :put,
|
38
40
|
:tag => :div,
|
39
|
-
:url =>
|
41
|
+
:url => send("sns_sort_items_#{cpath}") %>
|
40
42
|
<% end %>
|
41
43
|
|
42
44
|
<%= sortable_element_reporting_target :menu,
|
@@ -47,5 +49,5 @@
|
|
47
49
|
:method => :put,
|
48
50
|
:only => [ :category, :placeholder ],
|
49
51
|
:tree => true,
|
50
|
-
:url =>
|
52
|
+
:url => send("sns_sort_categories_#{cpath}", :root => root) %>
|
51
53
|
<% end %>
|
@@ -128,7 +128,7 @@ EOF
|
|
128
128
|
:partial => 'sortable_nested_set/toggle',
|
129
129
|
:locals => { :category_type => params[:category_type],
|
130
130
|
:id => params[:id],
|
131
|
-
:state => (params[:state] ==
|
131
|
+
:state => (params[:state] == :open ? :closed : :open) }
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
@@ -1,7 +1,12 @@
|
|
1
1
|
module ActionDispatch::Routing
|
2
2
|
class Mapper
|
3
3
|
def sortable_nested_set_for(category_type)
|
4
|
+
item_type = category_type.to_s.classify.constantize.sns_items_type
|
5
|
+
|
4
6
|
resources category_type do
|
7
|
+
resources category_type, :as => "sub#{category_type}"
|
8
|
+
resources item_type
|
9
|
+
|
5
10
|
member do
|
6
11
|
get :sns_toggle
|
7
12
|
get :sns_add_subcategory
|
@@ -15,7 +20,7 @@ module ActionDispatch::Routing
|
|
15
20
|
end
|
16
21
|
end
|
17
22
|
|
18
|
-
resources
|
23
|
+
resources item_type do
|
19
24
|
delete :sns_destroy_item, :on => :member, :controller => category_type
|
20
25
|
end
|
21
26
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 25
|
9
|
+
version: 0.1.25
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jason Murad
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-08-
|
17
|
+
date: 2010-08-13 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|