class RailsDbAdmin::Extjs::JsonColumnBuilder

Public Class Methods

build_column_from_column_obj(column) click to toggle source
# File lib/rails_db_admin/extjs/json_column_builder.rb, line 4
def self.build_column_from_column_obj(column)
  self.send("build_#{column.type.to_s}_column", column.name)
end
build_grid_columns(columns, add_fake_id = false) click to toggle source

construct an array of column objects based on a AR connection.columns object

# File lib/rails_db_admin/extjs/json_column_builder.rb, line 10
def self.build_grid_columns(columns, add_fake_id = false)
  grid_columns = columns.collect do |column|
    RailsDbAdmin::Extjs::JsonColumnBuilder.build_column_from_column_obj(column)
  end
  if add_fake_id
    grid_columns << {:header => "fake_id",
                     :type => "number",
                     :dataIndex => "fake_id",
                     :hidden => true}
  end
  grid_columns
end
build_readonly_column(column_name) click to toggle source
# File lib/rails_db_admin/extjs/json_column_builder.rb, line 35
def self.build_readonly_column(column_name)
  {
      :header => column_name,
      :type => 'string',
      :dataIndex => column_name,
      :width => 150
  }
end
build_store_fields(columns, add_fake_id = false) click to toggle source
# File lib/rails_db_admin/extjs/json_column_builder.rb, line 23
def self.build_store_fields(columns, add_fake_id = false)
  grid_fields = columns.collect do |column|
    {:name => column.name}
  end

  if add_fake_id
    grid_fields << {:name => "fake_id"}
  end

  grid_fields
end

Private Class Methods

build_boolean_column(column_name) click to toggle source
# File lib/rails_db_admin/extjs/json_column_builder.rb, line 47
def self.build_boolean_column(column_name)
  {
      :header => column_name,
      :type => 'boolean',
      :dataIndex => column_name,
      :width => 150,
      :editor => {:xtype => 'booleancolumneditor'},
      :renderer => NonEscapeJsonString.new("Compass.ErpApp.Desktop.Applications.RailsDbAdmin.renderBooleanColumn")
  }
end
build_date_column(column_name) click to toggle source
# File lib/rails_db_admin/extjs/json_column_builder.rb, line 58
def self.build_date_column(column_name)
  hash = {
      :header => column_name,
      :type => 'date',
      :dataIndex => column_name,
      :width => 150,
  }
  hash[:editor] = {:xtype => 'textfield'} if (column_name != "created_at" && column_name != "updated_at")

  hash
end
build_datetime_column(column_name) click to toggle source
# File lib/rails_db_admin/extjs/json_column_builder.rb, line 70
def self.build_datetime_column(column_name)
  hash = {
      :header => column_name,
      :type => 'date',
      :dataIndex => column_name,
      :width => 150,
  }
  hash[:editor] = {:xtype => 'textfield'} if (column_name != "created_at" && column_name != "updated_at")

  hash
end
build_decimal_column(column_name) click to toggle source
# File lib/rails_db_admin/extjs/json_column_builder.rb, line 114
def self.build_decimal_column(column_name)
  hash = {
      :header => column_name,
      :type => 'float',
      :dataIndex => column_name,
      :width => 150,
  }
  hash[:editor] = {:xtype => 'textfield'} if column_name != "id"

  hash
end
build_float_column(column_name) click to toggle source
# File lib/rails_db_admin/extjs/json_column_builder.rb, line 126
def self.build_float_column(column_name)
  hash = {
      :header => column_name,
      :type => 'float',
      :dataIndex => column_name,
      :width => 150,
  }
  hash[:editor] = {:xtype => 'textfield'} if column_name != "id"

  hash
end
build_hstore_column(column_name) click to toggle source
# File lib/rails_db_admin/extjs/json_column_builder.rb, line 138
def self.build_hstore_column(column_name)
  {
      :header => column_name,
      :type => 'string',
      :dataIndex => column_name,
      :width => 150
  }
end
build_integer_column(column_name) click to toggle source
# File lib/rails_db_admin/extjs/json_column_builder.rb, line 102
def self.build_integer_column(column_name)
  hash = {
      :header => column_name,
      :type => 'number',
      :dataIndex => column_name,
      :width => 150,
  }
  hash[:editor] = {:xtype => 'textfield'} if column_name != "id"

  hash
end
build_string_column(column_name) click to toggle source
# File lib/rails_db_admin/extjs/json_column_builder.rb, line 82
def self.build_string_column(column_name)
  {
      :header => column_name,
      :type => 'string',
      :dataIndex => column_name,
      :width => 150,
      :editor => {:xtype => 'textfield'}
  }
end
build_text_column(column_name) click to toggle source
# File lib/rails_db_admin/extjs/json_column_builder.rb, line 92
def self.build_text_column(column_name)
  {
      :header => column_name,
      :type => 'string',
      :dataIndex => column_name,
      :width => 150,
      :editor => {:xtype => 'textarea'}
  }
end