Module: Toolbox::DefaultController::HelperMethods

Defined in:
lib/toolbox/default_controller.rb

Instance Method Summary collapse

Instance Method Details



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/toolbox/default_controller.rb', line 22

def context_menu_link(rec, context = nil)
  if controller.respond_to? :menu_config
    context_records = []
    # get the record in show-mode
    context_records << get_record if get_record.is_a? ActiveRecord::Base
    context_records << context if context
    p = {}
    context_records.each { |r| p["#{r.class.name.to_s}_id".to_sym] = r }
    ctx_url =send("context_menu_#{rec.class.to_s.underscore}_path".to_sym, rec, p)
    link_to_function('&#9660;', "show_context_menu(event, '#{ctx_url}')")
  else
    ''
  end
end

#get_recordObject



18
19
20
# File 'lib/toolbox/default_controller.rb', line 18

def get_record
  instance_variable_get ('@' + controller.model_name).to_sym
end

#toolbox_includesObject

returns html necessary to load javascript and css to make the toolbox work



38
39
40
41
42
43
44
45
46
# File 'lib/toolbox/default_controller.rb', line 38

def toolbox_includes()
  return "" if @toolbox_already_included
  @toolbox_already_included = true


  js = javascript_include_tag "toolbox-#{Toolbox::VERSION}/toolbox", "toolbox-#{Toolbox::VERSION}/popup"
  cs = stylesheet_link_tag 'toolbox/context_menu', 'toolbox/popup', 'toolbox/toolbox'
  js + "\n" + cs + "\n"
end