Class: Locomotive::ContentEntriesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/locomotive/content_entries_controller.rb

Instance Method Summary collapse

Instance Method Details

#bulk_destroyObject


77
78
79
80
81
# File 'app/controllers/locomotive/content_entries_controller.rb', line 77

def bulk_destroy
  authorize 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

#createObject


54
55
56
57
58
# File 'app/controllers/locomotive/content_entries_controller.rb', line 54

def create
  authorize ContentEntry
  @content_entry = service.create(content_entry_params)
  respond_with @content_entry, location: -> { location_after_persisting }
end

#destroyObject


83
84
85
86
87
# File 'app/controllers/locomotive/content_entries_controller.rb', line 83

def destroy
  authorize @content_entry
  service.bulk_destroy([*params[:id]])
  respond_with @content_type, location: content_entries_path(current_site, @content_type.slug, default_location_params)
end

#editObject


60
61
62
63
# File 'app/controllers/locomotive/content_entries_controller.rb', line 60

def edit
  authorize @content_entry
  respond_with @content_entry
end

#exportObject


27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/locomotive/content_entries_controller.rb', line 27

def export
  authorize 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

#indexObject


21
22
23
24
25
# File 'app/controllers/locomotive/content_entries_controller.rb', line 21

def index
  authorize ContentEntry
  @content_entries = service.all(list_params)
  respond_with @content_entries
end

#newObject


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_formObject


38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/locomotive/content_entries_controller.rb', line 38

def show_in_form
  authorize @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

#sortObject


71
72
73
74
75
# File 'app/controllers/locomotive/content_entries_controller.rb', line 71

def sort
  authorize ContentEntry, :update?
  service.sort(params[:entries])
  respond_with @content_type, location: content_entries_path(current_site, @content_type.slug)
end

#updateObject


65
66
67
68
69
# File 'app/controllers/locomotive/content_entries_controller.rb', line 65

def update
  authorize @content_entry
  service.update(@content_entry, content_entry_params)
  respond_with @content_entry, location: -> { location_after_persisting }
end