Class: Alchemy::Admin::ClipboardController

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

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



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

def clear
  @clipboard.clear
end

#indexObject



7
8
9
10
11
12
# File 'app/controllers/alchemy/admin/clipboard_controller.rb', line 7

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

#insertObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/alchemy/admin/clipboard_controller.rb', line 14

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

#removeObject



27
28
29
30
31
32
33
# File 'app/controllers/alchemy/admin/clipboard_controller.rb', line 27

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