Sha256: 92518a2b200442c8835304206acea843212a34fcc9635e6d6318a2994f381f5b

Contents?: true

Size: 1.21 KB

Versions: 24

Compression:

Stored size: 1.21 KB

Contents

module Alchemy
  module Admin
    class ClipboardController < Alchemy::Admin::BaseController
      authorize_resource class: :alchemy_admin_clipboard
      before_filter :set_clipboard

      def index
        @clipboard_items = model_class.all_from_clipboard(@clipboard)
        respond_to do |format|
          format.html
        end
      end

      def insert
        @item = model_class.find(params[:remarkable_id])
        unless @clipboard.detect { |item| item['id'] == params[:remarkable_id] }
          @clipboard << {
            'id' => params[:remarkable_id],
            'action' => params[:remove] ? 'cut' : 'copy'
          }
        end
        respond_to do |format|
          format.js
        end
      end

      def remove
        @item = model_class.find(params[:remarkable_id])
        @clipboard.delete_if { |item| item['id'] == params[:remarkable_id] }
        respond_to do |format|
          format.js
        end
      end

      def clear
        @clipboard.clear
      end

      private

      def set_clipboard
        @clipboard = get_clipboard(params[:remarkable_type])
      end

      def model_class
        "alchemy/#{params[:remarkable_type]}".classify.constantize
      end

    end
  end
end

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
alchemy_cms-3.2.1 app/controllers/alchemy/admin/clipboard_controller.rb
alchemy_cms-3.1.3 app/controllers/alchemy/admin/clipboard_controller.rb
lc_alchemy_cms-3.2.1 app/controllers/alchemy/admin/clipboard_controller.rb
lc_alchemy_cms-3.2.0 app/controllers/alchemy/admin/clipboard_controller.rb
alchemy_cms-3.2.0 app/controllers/alchemy/admin/clipboard_controller.rb
alchemy_cms-3.2.0.rc1 app/controllers/alchemy/admin/clipboard_controller.rb
alchemy_cms-3.2.0.beta app/controllers/alchemy/admin/clipboard_controller.rb
alchemy_cms-3.1.1 app/controllers/alchemy/admin/clipboard_controller.rb
alchemy_cms-3.0.4 app/controllers/alchemy/admin/clipboard_controller.rb
alchemy_cms-3.1.0 app/controllers/alchemy/admin/clipboard_controller.rb
alchemy_cms-3.1.0.rc3 app/controllers/alchemy/admin/clipboard_controller.rb
alchemy_cms-3.1.0.rc2 app/controllers/alchemy/admin/clipboard_controller.rb
alchemy_cms-3.1.0.rc1 app/controllers/alchemy/admin/clipboard_controller.rb
alchemy_cms-3.1.0.beta6 app/controllers/alchemy/admin/clipboard_controller.rb
alchemy_cms-3.1.0.beta5 app/controllers/alchemy/admin/clipboard_controller.rb
alchemy_cms-3.1.0.beta4 app/controllers/alchemy/admin/clipboard_controller.rb
alchemy_cms-3.0.3 app/controllers/alchemy/admin/clipboard_controller.rb
alchemy_cms-3.1.0.beta3 app/controllers/alchemy/admin/clipboard_controller.rb
alchemy_cms-3.1.0.beta2 app/controllers/alchemy/admin/clipboard_controller.rb
alchemy_cms-3.1.0.beta1 app/controllers/alchemy/admin/clipboard_controller.rb