Class: Maglev::Editor::SectionsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- Maglev::Editor::SectionsController
- Includes:
- LockVersionConcern
- Defined in:
- app/controllers/maglev/editor/sections_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #sort ⇒ Object
- #update ⇒ Object
Methods included from ResourceIdConcern
Instance Method Details
#create ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/maglev/editor/sections_controller.rb', line 25 def create @section = services.add_section.call( page: current_maglev_page, section_type: params[:section_type], position: params[:position].to_i ) redirect_to edit_editor_section_path(@section[:id], maglev_editing_route_context), flash: newly_added_section_to_flash, notice: flash_t(:success), status: :see_other end |
#destroy ⇒ Object
56 57 58 59 |
# File 'app/controllers/maglev/editor/sections_controller.rb', line 56 def destroy services.delete_section.call(page: current_maglev_page, section_id: params[:id]) redirect_to_sections_path end |
#edit ⇒ Object
37 38 39 |
# File 'app/controllers/maglev/editor/sections_controller.rb', line 37 def edit newly_added_section_to_headers end |
#new ⇒ Object
17 18 19 20 21 22 23 |
# File 'app/controllers/maglev/editor/sections_controller.rb', line 17 def new set_query_and_category_id @position = (params[:position] || -1).to_i @theme_sections = maglev_theme.sections.filter(current_maglev_sections, keyword: @query, category_id: @category_id) render layout: false end |
#show ⇒ Object
13 14 15 |
# File 'app/controllers/maglev/editor/sections_controller.rb', line 13 def show redirect_to edit_editor_section_path(params[:id], maglev_editing_route_context) end |
#sort ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'app/controllers/maglev/editor/sections_controller.rb', line 47 def sort services.sort_sections.call( page: current_maglev_page, section_ids: params[:item_ids], lock_version: params[:lock_version] ) redirect_to_sections_path end |
#update ⇒ Object
41 42 43 44 45 |
# File 'app/controllers/maglev/editor/sections_controller.rb', line 41 def update update_section reload_lock_source flash.now[:notice] = flash_t(:success) end |