Class: Archangel::Backend::EntriesController
- Inherits:
-
Archangel::BackendController
- Object
- ActionController::Base
- ApplicationController
- Archangel::BackendController
- Archangel::Backend::EntriesController
- Includes:
- Controllers::Backend::ResourcefulConcern
- Defined in:
- app/controllers/archangel/backend/entries_controller.rb
Overview
Backend collection entries controller
Instance Method Summary collapse
-
#sort ⇒ Object
Update collection entry sort order.
Methods included from Controllers::ResourcefulConcern
#create, #destroy, #edit, #index, #new, #show, #update
Methods inherited from ApplicationController
#current_site, #render_401_error, #render_404_error, #render_error
Methods included from PaginatableConcern
Methods included from ActionableConcern
#action, #collection_action?, #edit_action?, #index_action?, #member_action?, #new_action?, #restful_action?, #save_action?, #show_action?
Instance Method Details
#sort ⇒ Object
Update collection entry sort order
Formats
JSON
Params
[String] slug - the collection slug
Request
POST /backend/collections/:slug/entries/sort
POST /backend/collections/:slug/entries/sort.json
Paramaters
{
"collection_entry": {
"sort": ["0" => "1234", "1" => "5678", "2" => "4321"]
}
}
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/archangel/backend/entries_controller.rb', line 34 def sort parent_resource_content sort_order = sort_resource_params.fetch(:sort) ApplicationRecord.transaction do sort_order.each do |index, entry_id| entry = current_site.entries .where(collection: @collection) .find_by(id: entry_id.to_i) entry entry.set_list_position(index) end end render json: { success: true }, status: :accepted end |