class HtmlGrid::TagComposite
Public Instance Methods
compose(model = @model)
click to toggle source
# File lib/htmlgrid/composite.rb, line 132 def compose(model = @model) components.sort.each { |pos, component| @grid.push(label(create(component, model), component)) css = {} if (klass = css_map[pos]) css.store("class", klass) end if (id = css_id_map[pos]) css.store("id", id) end if (style = css_style_map[pos]) css.store("style", style) end @css_grid.push(css.empty? ? nil : css) } end
create(component, model = @model)
click to toggle source
# File lib/htmlgrid/composite.rb, line 149 def create(component, model = @model) if component.is_a? Class component.new(model, @session, self) elsif component.is_a? Symbol if respond_to?(component, true) send(component, model) elsif (klass = symbol_map[component]) klass.new(component, model, @session, self) else self.class::DEFAULT_CLASS.new(component, model, @session, self) end elsif component.is_a? String val = @lookandfeel.lookup(component) { component.to_s } val.gsub(@@nl2br_ptrn, "<br>") end rescue => exc exc.backtrace.push(sprintf("%s::COMPONENTS[%s] in create(%s)", self.class, components.key(component).inspect, component)) raise exc end
insert_row(ypos, txt, css_class = nil)
click to toggle source
# File lib/htmlgrid/composite.rb, line 170 def insert_row(ypos, txt, css_class = nil) @grid[ypos, 0] = [[txt]] @css_grid[ypos, 0] = [css_class ? {"class" => css_class} : nil] end
label(component, key)
click to toggle source
# File lib/htmlgrid/composite.rb, line 175 def label(component, key) if labels? \ && (!component.respond_to?(:label?) || component.label?) label = SimpleLabel.new(key, component, @session, self) [label, component] else component end end
setup_grid()
click to toggle source
# File lib/htmlgrid/composite.rb, line 185 def setup_grid @grid = [] @css_grid = [] end
submit(model = @model, name = event())
click to toggle source
# File lib/htmlgrid/composite.rb, line 190 def submit(model = @model, name = event()) Submit.new(name, model, @session, self) end
tag_attributes(idx = nil)
click to toggle source
# File lib/htmlgrid/composite.rb, line 194 def tag_attributes(idx = nil) attr = {} if (klass = self.class.const_get(:CSS_CLASS)) attr.store("class", klass) end if (id = self.class.const_get(:CSS_ID)) attr.store("id", id) end if idx && (css = @css_grid.at(idx)) attr.update(css) end attr end