Class: Alchemy::Admin::ClipboardController

Inherits:
BaseController show all
Defined in:
app/controllers/alchemy/admin/clipboard_controller.rb

Constant Summary collapse

REMARKABLE_TYPES =
%w[elements pages]

Instance Method Summary collapse

Methods inherited from BaseController

#leave

Methods included from Modules

included, #module_definition_for, register_module

Methods included from Alchemy::AbilityHelper

#current_ability

Methods included from ConfigurationMethods

#configuration, #multi_language?, #multi_site?, #prefix_locale?

Instance Method Details

#clearObject



39
40
41
# File 'app/controllers/alchemy/admin/clipboard_controller.rb', line 39

def clear
  @clipboard.clear
end

#indexObject



11
12
13
14
15
16
# File 'app/controllers/alchemy/admin/clipboard_controller.rb', line 11

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

#insertObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/alchemy/admin/clipboard_controller.rb', line 18

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

#removeObject



31
32
33
34
35
36
37
# File 'app/controllers/alchemy/admin/clipboard_controller.rb', line 31

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