Class: Lcms::Engine::Admin::CurriculumsController

Inherits:
AdminController show all
Defined in:
app/controllers/lcms/engine/admin/curriculums_controller.rb

Constant Summary

Constants inherited from AdminController

AdminController::RE_GOOGLE_FOLDER

Instance Method Summary collapse

Methods inherited from AdminController

settings

Methods included from PathHelper

#dynamic_document_path, #dynamic_material_path, #dynamic_path

Instance Method Details

#childrenObject



11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/lcms/engine/admin/curriculums_controller.rb', line 11

def children
  id = params[:id]
  resources =
    if id == '#'
      Lcms::Engine::Resource.tree.ordered.roots
    else
      Array.wrap(Lcms::Engine::Resource.tree.find(id)&.children)
    end

  render json: resources.map { |res| CurriculumPresenter.new.parse_jstree_node(res) }
end

#editObject



7
8
9
# File 'app/controllers/lcms/engine/admin/curriculums_controller.rb', line 7

def edit
  @curriculum = CurriculumPresenter.new
end

#updateObject



23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/lcms/engine/admin/curriculums_controller.rb', line 23

def update
  @form = CurriculumForm.new(curriculum_update_params)
  if @form.save
    redirect_to lcms_engine.edit_admin_curriculum_path,
                notice: t('.success')
  else
    @curriculum = CurriculumPresenter.new
    render :edit, alert: t('.error')
  end
end