class PropertyGrid::GroupProperty

A container for a property within a group.

Attributes

property_collection[RW]
property_name[RW]
property_type[RW]
property_var[RW]

Public Class Methods

new(var, name, property_type, collection = nil) click to toggle source

some of these use jquery: jqueryui.com/

# File lib/property_grid.rb, line 59
def initialize(var, name, property_type, collection = nil)
  @property_var = var
  @property_name = name
  @property_type = property_type
  @property_collection = collection
end

Public Instance Methods

get_erb(form_type) click to toggle source

Returns the erb for a given form type. This code handles the construction of the web control that will display the content of a property in the property grid. The web page must utilize a field_for … |f| for this construction to work.

# File lib/property_grid.rb, line 78
def get_erb(form_type)
  erb = "<%= f.#{form_type.type_name} :#{@property_var}"
  erb << ", class: '#{form_type.class_name}'" if form_type.class_name.present?
  erb << ", #{@property_collection}" if @property_collection.present? && @property_type == :list
  erb << ", options_from_collection_for_select(f.object.records, :id, :name, f.object.#{@property_var})" if @property_collection.present? && @property_type == :db_list
  erb << "%>"

  erb
end
get_input_control() click to toggle source

returns the ERB for this property as defined by its property_type

# File lib/property_grid.rb, line 67
def get_input_control
  form_type = PropertyGridTypes.get_property_type_map[@property_type]
  raise "Property '#{@property_type}' is not mapped to an input control" if form_type.nil?
  erb = get_erb(form_type)

  erb
end