Sha256: d38e57860ce620a54ba3f93451607d4856de7ab16ab687f69d13b3d8f674abd9

Contents?: true

Size: 1.88 KB

Versions: 1

Compression:

Stored size: 1.88 KB

Contents

module LookingForHelper
  #
  # = Looking For Helper
  #
  # Creates a link tag to open LookingFor search form with the given options.
  #
  # ==== Signatures
  #
  #   looking_for(object_name, method_names, link_body, options = {}, html_options = {})
  #  
  # * <tt>object_name</tt>  - A model name, for example 'Item' or a collection in a one-to-many association (for example 'user.items' if user has many items).
  # * <tt>method_names</tt>  - An array of method names for build the results columns (for example [:id, :code, :description] if id, code, description are attributues of object_name)
  # * <tt>link_body</tt> - The link body
  #
  # ==== options
  #
  # * <tt>:fill</tt>   - Fill html input with value from database ( db_field => input_tag_id ) when a row is selected.
  # * <tt>:width</tt>  - Width of dialog, optional, default 500px.
  # * <tt>:height</tt> - Height of dialog, optional, default 300px.
  #
  # ==== html_options
  #
  # Like html_options in link_to helper but :remote will be always true.
  #
  # ==== Examples
  #
  #   <%= looking_for 'Item',
  #                   [:id,:code,:description],
  #                   'search', 
  #                   { :fill   => {:id          => :item_id,
  #                                 :code        => :item_code,
  #                                 :description => :item_description},
  #                     :width  => 550,
  #                     :height => 360},
  #                   :id   => 'looking_for_items' %>                   

  def looking_for(*args)
    opt      = args[3] || {}
    opt[:controller] = :looking_for
    opt[:action]     = :search
    opt[:width]    ||= 500
    opt[:height]   ||= 300
    opt[:object_name] = args.first
    opt[:method_names] = args[1]
    
    html_opt = args[4] || {}
    html_opt[:remote] = true
        
    link_to args[2], opt, html_opt
  end   
end    

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
looking_for-0.2.0 lib/looking_for/helpers/looking_for_helper.rb