Class: Backend::Content::RowsController

Inherits:
BaseController
  • Object
show all
Includes:
Concerns::Backend::PositionableController
Defined in:
app/controllers/backend/content/rows_controller.rb

Instance Method Summary collapse

Methods included from Concerns::Backend::PositionableController

#update_position

Instance Method Details

#destroyObject



46
47
48
49
# File 'app/controllers/backend/content/rows_controller.rb', line 46

def destroy
  @row.destroy
  redirect_back_to_content('content-rows')
end

#horizontal_alignmentObject



25
26
27
28
29
30
31
# File 'app/controllers/backend/content/rows_controller.rb', line 25

def horizontal_alignment
  align = params[:align].to_s
  align = 'left' unless %w(left center right).include?(align)
  @row.update_attribute :horizontal_alignment, align

  redirect_back_to_content
end

#newObject



6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/backend/content/rows_controller.rb', line 6

def new
  if params[:klass] && params[:id] && params[:locale]
    instance = params[:klass].constantize.find params[:id]
    row = instance.content_rows.create!(locale: params[:locale])

    redirect_to content_path(instance, params[:locale], "content-row-#{row.id}")
  else
    render text: 'Insufficient params. Please provide klass, id and locale.'
  end
end

#toggle_full_widthObject



41
42
43
44
# File 'app/controllers/backend/content/rows_controller.rb', line 41

def toggle_full_width
  @row.update_attribute :full_width, !@row.full_width?
  redirect_back_to_content
end

#updateObject



17
18
19
20
21
22
23
# File 'app/controllers/backend/content/rows_controller.rb', line 17

def update
  if @row.update_attributes allowed_params
    render 'backend/lightbox_saved'
  else
    render :edit
  end
end

#vertical_alignmentObject



33
34
35
36
37
38
39
# File 'app/controllers/backend/content/rows_controller.rb', line 33

def vertical_alignment
  align = params[:align].to_s
  align = 'top' unless %w(top center bottom).include?(align)
  @row.update_attribute :vertical_alignment, align

  redirect_back_to_content
end