Class: Maglev::Editor::SectionBlocksController

Inherits:
BaseController show all
Defined in:
app/controllers/maglev/editor/section_blocks_controller.rb

Instance Method Summary collapse

Methods included from ResourceIdConcern

#resource_id

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/maglev/editor/section_blocks_controller.rb', line 20

def create
  services.add_section_block.call(
    page: current_maglev_page,
    section_id: @section.id,
    block_type: params[:block_type],
    parent_id: params[:parent_id],
    lock_version: params[:lock_version]
  )
  redirect_to_section_blocks_path
end

#destroyObject



49
50
51
52
53
54
55
56
# File 'app/controllers/maglev/editor/section_blocks_controller.rb', line 49

def destroy
  services.delete_section_block.call(
    page: current_maglev_page,
    section_id: params[:section_id],
    block_id: params[:id]
  )
  redirect_to_section_blocks_path
end

#editObject



31
# File 'app/controllers/maglev/editor/section_blocks_controller.rb', line 31

def edit; end

#indexObject



12
13
14
# File 'app/controllers/maglev/editor/section_blocks_controller.rb', line 12

def index
  @blocks = @section.blocks
end

#showObject



16
17
18
# File 'app/controllers/maglev/editor/section_blocks_controller.rb', line 16

def show
  redirect_to edit_editor_section_block_path(params[:section_id], params[:id], maglev_editing_route_context)
end

#sortObject



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

def sort
  services.sort_section_blocks.call(
    page: current_maglev_page,
    section_id: @section.id,
    block_ids: params[:item_ids],
    parent_id: params[:parent_id],
    lock_version: params[:lock_version]
  )
  redirect_to_section_blocks_path
end

#updateObject



33
34
35
36
# File 'app/controllers/maglev/editor/section_blocks_controller.rb', line 33

def update
  update_section_block
  flash.now[:notice] = flash_t(:success)
end