Sha256: 9d0df8a43cf2d35aa4f06ef3dc0d36b232d69e3e5cba2afc8ab57930eb4b8c23

Contents?: true

Size: 926 Bytes

Versions: 3

Compression:

Stored size: 926 Bytes

Contents

# frozen_string_literal: true

module Alchemy
  module Admin
    class NodesController < Admin::ResourcesController
      def index
        @root_nodes = Node.language_root_nodes
      end

      def new
        @node = Node.new(
          site: Alchemy::Site.current,
          parent_id: params[:parent_id],
          language: Language.current
        )
      end

      def toggle
        node = Node.find(params[:id])
        node.update(folded: !node.folded)
        if node.folded?
          head :ok
        else
          render partial: 'node', collection: node.children.includes(:page, :children)
        end
      end

      private

      def resource_params
        params.require(:node).permit(
          :site_id,
          :parent_id,
          :language_id,
          :page_id,
          :name,
          :url,
          :title,
          :nofollow,
          :external
        )
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
alchemy_cms-4.4.5 app/controllers/alchemy/admin/nodes_controller.rb
alchemy_cms-4.4.4 app/controllers/alchemy/admin/nodes_controller.rb
alchemy_cms-4.4.3 app/controllers/alchemy/admin/nodes_controller.rb