Class: Maglev::Editor::SectionsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- Maglev::Editor::SectionsController
- 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
24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/maglev/editor/sections_controller.rb', line 24 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
54 55 56 57 |
# File 'app/controllers/maglev/editor/sections_controller.rb', line 54 def destroy services.delete_section.call(page: current_maglev_page, section_id: params[:id]) redirect_to_sections_path end |
#edit ⇒ Object
36 37 38 |
# File 'app/controllers/maglev/editor/sections_controller.rb', line 36 def edit newly_added_section_to_headers end |
#new ⇒ Object
16 17 18 19 20 21 22 |
# File 'app/controllers/maglev/editor/sections_controller.rb', line 16 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
12 13 14 |
# File 'app/controllers/maglev/editor/sections_controller.rb', line 12 def show redirect_to edit_editor_section_path(params[:id], maglev_editing_route_context) end |
#sort ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'app/controllers/maglev/editor/sections_controller.rb', line 45 def sort current_maglev_page.reorder_sections(params[:item_ids], params[:lock_version]) if current_maglev_page.save redirect_to_sections_path else render_index_with_error end end |
#update ⇒ Object
40 41 42 43 |
# File 'app/controllers/maglev/editor/sections_controller.rb', line 40 def update update_section flash.now[:notice] = flash_t(:success) end |