File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
admin/app/controllers/concerns/solidus_admin Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusAdmin ::Moveable
4
+ extend ActiveSupport ::Concern
5
+
6
+ included do
7
+ before_action :load_moveable , only : [ :move ]
8
+ end
9
+
10
+ def move
11
+ @moveable . insert_at ( params . require ( :position ) . to_i )
12
+
13
+ respond_to do |format |
14
+ format . js { head :no_content }
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def load_moveable
21
+ @moveable = moveable_class . find ( params . require ( :id ) )
22
+ authorize! action_name , @moveable
23
+ end
24
+
25
+ def moveable_class
26
+ "Spree::#{ self . class . name . demodulize . remove ( 'Controller' ) . singularize } " . constantize
27
+ rescue NameError
28
+ raise NameError ,
29
+ "could not infer model class from #{ self . class . name } . Please override `moveable_class` to specify it explicitly."
30
+ end
31
+ end
You can’t perform that action at this time.
0 commit comments