Class: Locomotive::ContentEntriesController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- Locomotive::ContentEntriesController
- Defined in:
- app/controllers/locomotive/content_entries_controller.rb
Instance Method Summary collapse
- #bulk_destroy ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #export ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show_in_form ⇒ Object
- #sort ⇒ Object
- #update ⇒ Object
Instance Method Details
#bulk_destroy ⇒ Object
77 78 79 80 81 |
# File 'app/controllers/locomotive/content_entries_controller.rb', line 77 def bulk_destroy ContentEntry, :destroy? service.bulk_destroy(params[:ids].split(',')) respond_with @content_type, location: content_entries_path(current_site, @content_type.slug, default_location_params) end |
#create ⇒ Object
54 55 56 57 58 |
# File 'app/controllers/locomotive/content_entries_controller.rb', line 54 def create ContentEntry @content_entry = service.create(content_entry_params) respond_with @content_entry, location: -> { location_after_persisting } end |
#destroy ⇒ Object
83 84 85 86 87 |
# File 'app/controllers/locomotive/content_entries_controller.rb', line 83 def destroy @content_entry service.bulk_destroy([*params[:id]]) respond_with @content_type, location: content_entries_path(current_site, @content_type.slug, default_location_params) end |
#edit ⇒ Object
60 61 62 63 |
# File 'app/controllers/locomotive/content_entries_controller.rb', line 60 def edit @content_entry respond_with @content_entry end |
#export ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/locomotive/content_entries_controller.rb', line 27 def export ContentEntry, :index? @content_entries = @content_type.ordered_entries respond_with @content_entries, { filename: @content_type.slug, col_sep: ';', content_type: @content_type, host: request.host_with_port } end |
#index ⇒ Object
21 22 23 24 25 |
# File 'app/controllers/locomotive/content_entries_controller.rb', line 21 def index ContentEntry @content_entries = service.all(list_params) respond_with @content_entries end |
#new ⇒ Object
49 50 51 52 |
# File 'app/controllers/locomotive/content_entries_controller.rb', line 49 def new @content_entry = @content_type.entries.build(params[:content_entry] ? content_entry_params : {}) respond_with @content_entry end |
#show_in_form ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/locomotive/content_entries_controller.rb', line 38 def show_in_form @content_entry, :show? _content_type = current_site.content_types.where(slug: params[:parent_slug]).first @field = _content_type.entries_custom_fields.find(params[:field_id]) render partial: 'entry', locals: { slug: params[:slug], item: @content_entry, field: @field } end |
#sort ⇒ Object
71 72 73 74 75 |
# File 'app/controllers/locomotive/content_entries_controller.rb', line 71 def sort ContentEntry, :update? service.sort(params[:entries]) respond_with @content_type, location: content_entries_path(current_site, @content_type.slug) end |
#update ⇒ Object
65 66 67 68 69 |
# File 'app/controllers/locomotive/content_entries_controller.rb', line 65 def update @content_entry service.update(@content_entry, content_entry_params) respond_with @content_entry, location: -> { location_after_persisting } end |