Class: Archangel::Backend::EntriesController
- Inherits:
-
Archangel::BackendController
- Object
- ActionController::Base
- ApplicationController
- Archangel::BackendController
- Archangel::Backend::EntriesController
- Includes:
- Controllers::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 included from Helpers::ActionableConcern
#action, #collection_action?, #member_action?
Methods included from Controllers::MetatagableConcern
Methods inherited from ApplicationController
#current_site, #render_401_error, #render_404_error, #render_error
Methods included from Controllers::PaginatableConcern
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
Parameters
{
"collection_entry": {
"sort": {
"id" => "1234",
"position" => "1"
}
}
38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/archangel/backend/entries_controller.rb', line 38 def sort entry = current_site.entries .where(collection: @collection) .find_by(id: sort_resource_params.dig(:sort, :id)) entry entry.insert_at(sort_resource_params.dig(:sort, :position).to_i) render json: { status: :accepted, success: true }, status: :accepted end |