Class: HtmlGrid::Composite

Inherits:
AbstractComposite show all
Defined in:
lib/htmlgrid/composite.rb

Direct Known Subclasses

CenteredComposite, Form, List, Template

Constant Summary collapse

COLSPAN_MAP =
{}
COMPONENT_CSS_MAP =
{}
CSS_MAP =
{}
DEFAULT_CLASS =
InputText
VERTICAL =
false

Constants inherited from AbstractComposite

AbstractComposite::CSS_CLASS, AbstractComposite::CSS_ID, AbstractComposite::CSS_ID_MAP, AbstractComposite::CSS_STYLE_MAP, AbstractComposite::LABELS, AbstractComposite::LEGACY_INTERFACE, AbstractComposite::LOOKANDFEEL_MAP, AbstractComposite::SYMBOL_MAP

Constants inherited from Component

HtmlGrid::Component::CSS_CLASS, HtmlGrid::Component::CSS_ID, HtmlGrid::Component::HTML_ATTRIBUTES, HtmlGrid::Component::HTTP_HEADERS, HtmlGrid::Component::LABEL

Instance Attribute Summary

Attributes inherited from Component

#attributes, #dojo_tooltip, #model, #value

Instance Method Summary collapse

Methods inherited from AbstractComposite

component, #create, #init

Methods inherited from Component

#_to_html, #autofill?, #css_class, #css_class=, #css_id, #css_id=, #dojo_dynamic_html, #dojo_parse_on_load, #dojo_tag, #dojo_title=, #dynamic_html, #escape, #escape_symbols, #formname, #http_headers, #initialize, #label?, #onclick=, #onload=, #onsubmit=, #set_attribute, #tabindex=

Constructor Details

This class inherits a constructor from HtmlGrid::Component

Instance Method Details

#compose(model = @model, offset = [0, 0], bg_flag = false) ⇒ Object Also known as: _compose



215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/htmlgrid/composite.rb', line 215

def compose(model = @model, offset = [0, 0], bg_flag = false)
  comps = components
  css = css_map
  cids = css_id_map
  ccss = component_css_map
  colsp = colspan_map
  suffix = resolve_suffix(model, bg_flag)
  comps.keys.concat(css.keys).concat(colsp.keys).uniq.sort_by { |key|
    [key.size, key]
  }.each { |key|
    nkey = key[0, 2]
    matrix = resolve_offset(key, offset)
    nmatrix = resolve_offset(nkey, offset)
    comp = compose_component(model, comps[key], matrix)
    if (style = css[key])
      @grid.add_style(style + suffix, *matrix)
    elsif (style = css[nkey])
      @grid.add_style(style + suffix, *nmatrix)
    end
    if (id = cids[key] || cids[nkey])
      comp.css_id = id
    end
    if (span = colsp[key])
      @grid.set_colspan(matrix.at(0), matrix.at(1), span)
    end
  }
  # component-styles depend on components having been initialized
  # -> separate iteration
  ccss.each { |key, cstyle|
    matrix = resolve_offset(key, offset)
    @grid.add_component_style(cstyle + suffix, *matrix)
  }
  #       compose_components(model, offset)
  #       compose_css(offset)
  #       compose_colspan(offset)
end

#compose_colspan(offset) ⇒ Object



252
253
254
255
256
257
# File 'lib/htmlgrid/composite.rb', line 252

def compose_colspan(offset)
  colspan_map.each { |matrix, span|
    res = resolve_offset(matrix, offset)
    @grid.set_colspan(res.at(0), res.at(1), span)
  }
end

#eventObject



259
260
261
# File 'lib/htmlgrid/composite.rb', line 259

def event
  @container.event if @container.respond_to?(:event)
end

#full_colspanObject

def explode!

  @grid.explode!
  super
end


267
268
269
270
271
272
# File 'lib/htmlgrid/composite.rb', line 267

def full_colspan
  raw_span = components.keys.collect { |key|
    key.at(0)
  }.max.to_i
  raw_span > 0 ? raw_span + 1 : nil
end

#insert_row(ypos, txt, css_class = nil) ⇒ Object



274
275
276
277
278
# File 'lib/htmlgrid/composite.rb', line 274

def insert_row(ypos, txt, css_class = nil)
  @grid.insert_row(ypos, txt)
  @grid.set_colspan(0, ypos)
  @grid.add_style(css_class, 0, ypos) if css_class
end

#to_html(context) ⇒ Object



280
281
282
283
# File 'lib/htmlgrid/composite.rb', line 280

def to_html(context)
  @grid.set_attributes(@attributes)
  super << @grid.to_html(context).force_encoding("utf-8")
end