Sha256: f9f1ff90bebf3c15982ae92773488c0856d3292d87dd24821eeff516819e4d4a

Contents?: true

Size: 1.05 KB

Versions: 9

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module Lcms
  module Engine
    module Admin
      class CurriculumsController < AdminController
        def edit
          @curriculum = CurriculumPresenter.new
        end

        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

        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

        private

        def curriculum_update_params
          params.require(:curriculum).permit(:change_log)
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
lcms-engine-0.5.5 app/controllers/lcms/engine/admin/curriculums_controller.rb
lcms-engine-0.5.4 app/controllers/lcms/engine/admin/curriculums_controller.rb
lcms-engine-0.5.3 app/controllers/lcms/engine/admin/curriculums_controller.rb
lcms-engine-0.5.2 app/controllers/lcms/engine/admin/curriculums_controller.rb
lcms-engine-0.5.1 app/controllers/lcms/engine/admin/curriculums_controller.rb
lcms-engine-0.5.0 app/controllers/lcms/engine/admin/curriculums_controller.rb
lcms-engine-0.4.2 app/controllers/lcms/engine/admin/curriculums_controller.rb
lcms-engine-0.4.1 app/controllers/lcms/engine/admin/curriculums_controller.rb
lcms-engine-0.4.0 app/controllers/lcms/engine/admin/curriculums_controller.rb