Class: Archangel::Backend::EntriesController

Inherits:
Archangel::BackendController show all
Includes:
Controllers::ResourcefulConcern
Defined in:
app/controllers/archangel/backend/entries_controller.rb

Overview

Backend collection entries controller

Instance Method Summary collapse

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

#assign_meta_tags

Methods inherited from ApplicationController

#current_site, #render_401_error, #render_404_error, #render_error

Methods included from Controllers::PaginatableConcern

#page_num, #per_page

Instance Method Details

#sortObject

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))

  authorize entry

  entry.insert_at(sort_resource_params.dig(:sort, :position).to_i)

  render json: { status: :accepted, success: true }, status: :accepted
end