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
|
# File 'lib/aenea/active_admin/resource_dsl/sortable_actions.rb', line 5
def sortable_member_actions(fallback_route)
member_action :move_to_top do
if resource.first?
flash[:warning] = 'Already at top'
else
resource.move_to_top
flash[:notice] = 'Moved to top'
end
redirect_back fallback_location: Rails.application.routes.url_helpers.send(fallback_route)
end
member_action :move_to_bottom do
if resource.last?
flash[:warning] = 'Already at bottom'
else
resource.move_to_bottom
flash[:notice] = 'Moved to bottom'
end
redirect_back fallback_location: Rails.application.routes.url_helpers.send(fallback_route)
end
member_action :move_up do
if resource.first?
flash[:warning] = 'Already at top'
else
resource.move_higher
flash[:notice] = 'Moved up'
end
redirect_back fallback_location: Rails.application.routes.url_helpers.send(fallback_route)
end
member_action :move_down do
if resource.last?
flash[:warning] = 'Already at bottom'
else
resource.move_lower
flash[:notice] = 'Moved down'
end
redirect_back fallback_location: Rails.application.routes.url_helpers.send(fallback_route)
end
end
|