diff --git a/app/controllers/images_controller.rb b/app/controllers/images_controller.rb index ef00821bf..33c2b5498 100644 --- a/app/controllers/images_controller.rb +++ b/app/controllers/images_controller.rb @@ -70,6 +70,7 @@ def show format.html format.json { render json: @image.map(&:fup_json) } end + @image.order(:position) end def update @@ -98,6 +99,12 @@ def update render text: 'success' end + def sort + params[:warpable].each_with_index do |id, index| + @warpable.where(id: id).update_all(position: index+1) + end + end + def destroy @warpable = Warpable.find params[:id] if logged_in? && current_user.can_delete?(@warpable) diff --git a/app/views/images/_index.html.erb b/app/views/images/_index.html.erb index 6f9c58bc7..4edd3f69c 100644 --- a/app/views/images/_index.html.erb +++ b/app/views/images/_index.html.erb @@ -3,7 +3,7 @@
No images uploaded.
<%end%>@@ -70,3 +70,14 @@ <% end %> |