Class: Wice::ViewColumn

Inherits:
Object show all
Includes:
ActionView::Helpers::AssetTagHelper, ActionView::Helpers::FormTagHelper, ActionView::Helpers::JavaScriptHelper, ActionView::Helpers::TagHelper
Defined in:
lib/view_columns.rb

Overview

:nodoc:

Constant Summary collapse

FIELDS =

fields defined from the options parameter

[:attribute, :name, :html, :filter, :model, :allow_multiple_selection,
:in_html, :in_csv, :helper_style, :table_alias, :custom_order, :detach_with_id, :ordering, :auto_reload]
@@handled_type =
Hash.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block, options, grid_obj, tname, mtable, cfilter, view) ⇒ ViewColumn

:nodoc:



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/view_columns.rb', line 47

def initialize(block, options, grid_obj, tname, mtable, cfilter, view)  #:nodoc:
  self.cell_rendering_block = block
  self.grid           = grid_obj
  self.table_name     = tname
  self.main_table     = mtable
  self.custom_filter  = cfilter
  @view = view

  FIELDS.each do |field|
    self.send(field.to_s + '=', options[field])
  end
end

Instance Attribute Details

#cell_rendering_blockObject

Returns the value of attribute cell_rendering_block.



43
44
45
# File 'lib/view_columns.rb', line 43

def cell_rendering_block
  @cell_rendering_block
end

#contains_a_text_inputObject (readonly)

Returns the value of attribute contains_a_text_input.



45
46
47
# File 'lib/view_columns.rb', line 45

def contains_a_text_input
  @contains_a_text_input
end

#css_classObject

:nodoc:



63
64
65
# File 'lib/view_columns.rb', line 63

def css_class
  @css_class
end

#custom_filterObject

Returns the value of attribute custom_filter.



43
44
45
# File 'lib/view_columns.rb', line 43

def custom_filter
  @custom_filter
end

#gridObject

Returns the value of attribute grid.



43
44
45
# File 'lib/view_columns.rb', line 43

def grid
  @grid
end

#main_tableObject

Returns the value of attribute main_table.



43
44
45
# File 'lib/view_columns.rb', line 43

def main_table
  @main_table
end

#modelObject

Returns the value of attribute model.



43
44
45
# File 'lib/view_columns.rb', line 43

def model
  @model
end

#table_nameObject

Returns the value of attribute table_name.



43
44
45
# File 'lib/view_columns.rb', line 43

def table_name
  @table_name
end

Class Method Details

.get_column_processor(column_type) ⇒ Object



27
28
29
# File 'lib/view_columns.rb', line 27

def get_column_processor(column_type)
  @@handled_type[column_type] || ViewColumn
end

.load_column_processorsObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/view_columns.rb', line 7

def load_column_processors

  loaded_column_processors = Hash.new
  Wice::COLUMN_PROCESSOR_INDEX.each do |column_type, column_source_file|
    unless loaded_column_processors[column_source_file]
      require "view_columns/#{column_source_file}.rb"
      column_class_name = column_source_file.classify

      unless Wice.const_defined?(column_class_name.intern)
        raise "#{column_source_file}.rb is expected to define #{column_class_name}!"
      end
      column_class = eval("Wice::#{column_class_name}")

      loaded_column_processors[column_source_file] = column_class
    end

    @@handled_type[column_type] = loaded_column_processors[column_source_file]
  end
end

Instance Method Details

#attribute_name_fully_qualified_for_all_but_main_table_columnsObject

bad name, because for the main table the name is not really ‘fully_qualified’



114
115
116
# File 'lib/view_columns.rb', line 114

def attribute_name_fully_qualified_for_all_but_main_table_columns #:nodoc:
  self.main_table ? attribute : table_alias_or_table_name + '.' + attribute
end

#auto_reloading_input_with_negation_checkbox?Boolean

:nodoc:

Returns:

  • (Boolean)


144
145
146
# File 'lib/view_columns.rb', line 144

def auto_reloading_input_with_negation_checkbox?  #:nodoc:
  false
end

:nodoc:

Returns:

  • (Boolean)


136
137
138
# File 'lib/view_columns.rb', line 136

def capable_of_hosting_filter_related_icons?  #:nodoc:
  self.attribute.blank? && self.name.blank? && ! self.filter_shown?
end

#configObject

:nodoc:



87
88
89
# File 'lib/view_columns.rb', line 87

def config  #:nodoc:
  @view.config
end

#controllerObject

:nodoc:



91
92
93
# File 'lib/view_columns.rb', line 91

def controller  #:nodoc:
  @view.controller
end

#detachnessObject

:nodoc:



71
72
73
# File 'lib/view_columns.rb', line 71

def detachness #:nodoc:
  (! detach_with_id.blank?).to_s
end

#filter_shown?Boolean

:nodoc:

Returns:

  • (Boolean)


123
124
125
# File 'lib/view_columns.rb', line 123

def filter_shown? #:nodoc:
  self.attribute && self.filter
end

#filter_shown_in_main_table?Boolean

:nodoc:

Returns:

  • (Boolean)


127
128
129
# File 'lib/view_columns.rb', line 127

def filter_shown_in_main_table? #:nodoc:
  filter_shown? && ! self.detach_with_id
end

#form_parameter_name_id_and_query(v) ⇒ Object

:nodoc:



105
106
107
108
109
110
111
# File 'lib/view_columns.rb', line 105

def form_parameter_name_id_and_query(v) #:nodoc:
  query = form_parameter_template(v)
  query_without_equals_sign = query.sub(/=$/,'')
  parameter_name = CGI.unescape(query_without_equals_sign)
  dom_id = id_out_of_name(parameter_name)
  return query, query_without_equals_sign, parameter_name, dom_id.tr('.', '_')
end

#fully_qualified_attribute_nameObject

:nodoc:



118
119
120
# File 'lib/view_columns.rb', line 118

def fully_qualified_attribute_name #:nodoc:
  table_alias_or_table_name + '.' + attribute
end

#has_auto_reloading_calendar?Boolean

:nodoc:

Returns:

  • (Boolean)


152
153
154
# File 'lib/view_columns.rb', line 152

def has_auto_reloading_calendar?  #:nodoc:
  false
end

#has_auto_reloading_input?Boolean

:nodoc:

Returns:

  • (Boolean)


140
141
142
# File 'lib/view_columns.rb', line 140

def has_auto_reloading_input?  #:nodoc:
  false
end

#has_auto_reloading_select?Boolean

:nodoc:

Returns:

  • (Boolean)


148
149
150
# File 'lib/view_columns.rb', line 148

def has_auto_reloading_select?  #:nodoc:
  false
end

#render_filterObject

:nodoc:



96
97
98
99
# File 'lib/view_columns.rb', line 96

def render_filter #:nodoc:
  params = @grid.filter_params(self)
  render_filter_internal(params)
end

#render_filter_internal(params) ⇒ Object

:nodoc:



101
102
103
# File 'lib/view_columns.rb', line 101

def render_filter_internal(params) #:nodoc:
  '<!-- implement me! -->'
end

#table_alias_or_table_nameObject

:nodoc:



132
133
134
# File 'lib/view_columns.rb', line 132

def table_alias_or_table_name  #:nodoc:
  table_alias || table_name
end

#yield_declarationObject

:nodoc:



75
76
77
78
79
80
81
82
83
84
# File 'lib/view_columns.rb', line 75

def yield_declaration #:nodoc:
  declaration = yield_declaration_of_column_filter
  if declaration
    {
      :filterName => self.name,
      :detached    => detachness,
      :declaration => declaration
    }
  end
end

#yield_declaration_of_column_filterObject

:nodoc:



67
68
69
# File 'lib/view_columns.rb', line 67

def yield_declaration_of_column_filter #:nodoc:
  nil
end