active_admin-acts_as_list 0.0.1 → 0.0.2
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.
@@ -1,62 +1,60 @@
|
|
1
|
-
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
1
|
+
module ActsAsList
|
2
|
+
module ActiveAdminHelper
|
3
|
+
def sortable_columns
|
4
|
+
column "▲▲".html_safe do |resource|
|
5
|
+
link_to("▲▲".html_safe, self.send(:"move_to_top_admin_#{resource.class.model_name.underscore.gsub("/", "_")}_path", resource), :class => "arrow") unless resource.first?
|
6
|
+
end
|
7
|
+
column "▲".html_safe do |resource|
|
8
|
+
link_to("▲".html_safe, self.send(:"move_up_admin_#{resource.class.model_name.underscore.gsub("/", "_")}_path", resource), :class => "arrow") unless resource.first?
|
9
|
+
end
|
10
|
+
column "▼".html_safe do |resource|
|
11
|
+
link_to("▼".html_safe, self.send(:"move_down_admin_#{resource.class.model_name.underscore.gsub("/", "_")}_path", resource), :class => "arrow") unless resource.last?
|
12
|
+
end
|
13
|
+
column "▼▼".html_safe do |resource|
|
14
|
+
link_to("▼▼".html_safe, self.send(:"move_to_bottom_admin_#{resource.class.model_name.underscore.gsub("/", "_")}_path", resource), :class => "arrow") unless resource.last?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def sortable_member_actions
|
19
|
+
member_action :move_to_top do
|
20
|
+
if resource.first?
|
21
|
+
redirect_to :back, :notice => I18n.t('acts_as_list.illegal_move_to_top', :resource => resource_class.to_s.camelize.constantize.model_name.human )
|
22
|
+
return
|
23
|
+
end
|
24
|
+
|
25
|
+
resource.move_to_top
|
26
|
+
redirect_to :back, :notice => I18n.t('acts_as_list.moved_to_top', :resource => resource_class.to_s.camelize.constantize.model_name.human )
|
17
27
|
end
|
18
28
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
resource.move_to_top
|
27
|
-
redirect_to :back, :notice => I18n.t('acts_as_list.moved_to_top', :resource => resource_class.to_s.camelize.constantize.model_name.human )
|
28
|
-
end
|
29
|
+
member_action :move_to_bottom do
|
30
|
+
if resource.last?
|
31
|
+
redirect_to :back, :notice => I18n.t('acts_as_list.illegal_move_to_bottom', :resource => resource_class.to_s.camelize.constantize.model_name.human )
|
32
|
+
return
|
33
|
+
end
|
29
34
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
return
|
34
|
-
end
|
35
|
-
|
36
|
-
resource.move_to_bottom
|
37
|
-
redirect_to :back, :notice => I18n.t('acts_as_list.moved_to_bottom', :resource => resource_class.to_s.camelize.constantize.model_name.human )
|
38
|
-
end
|
39
|
-
|
40
|
-
member_action :move_up do
|
41
|
-
if resource.first?
|
42
|
-
redirect_to :back, :notice => I18n.t('acts_as_list.illegal_move_up', :resource => resource_class.to_s.camelize.constantize.model_name.human )
|
43
|
-
return
|
44
|
-
end
|
45
|
-
|
46
|
-
resource.move_higher
|
47
|
-
redirect_to :back, :notice => I18n.t('acts_as_list.moved_up', :resource => resource_class.to_s.camelize.constantize.model_name.human )
|
48
|
-
end
|
35
|
+
resource.move_to_bottom
|
36
|
+
redirect_to :back, :notice => I18n.t('acts_as_list.moved_to_bottom', :resource => resource_class.to_s.camelize.constantize.model_name.human )
|
37
|
+
end
|
49
38
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
39
|
+
member_action :move_up do
|
40
|
+
if resource.first?
|
41
|
+
redirect_to :back, :notice => I18n.t('acts_as_list.illegal_move_up', :resource => resource_class.to_s.camelize.constantize.model_name.human )
|
42
|
+
return
|
43
|
+
end
|
44
|
+
|
45
|
+
resource.move_higher
|
46
|
+
redirect_to :back, :notice => I18n.t('acts_as_list.moved_up', :resource => resource_class.to_s.camelize.constantize.model_name.human )
|
59
47
|
end
|
48
|
+
|
49
|
+
member_action :move_down do
|
50
|
+
if resource.last?
|
51
|
+
redirect_to :back, :notice => I18n.t('acts_as_list.illegal_move_down', :resource => resource_class.to_s.camelize.constantize.model_name.human )
|
52
|
+
return
|
53
|
+
end
|
54
|
+
|
55
|
+
resource.move_lower
|
56
|
+
redirect_to :back, :notice => I18n.t('acts_as_list.moved_down', :resource => resource_class.to_s.camelize.constantize.model_name.human )
|
57
|
+
end
|
60
58
|
end
|
61
|
-
end
|
62
|
-
end
|
59
|
+
end
|
60
|
+
end
|