Class: HtmlGrid::TagComposite
Constant Summary
AbstractComposite::CSS_CLASS, AbstractComposite::CSS_ID, AbstractComposite::CSS_ID_MAP, AbstractComposite::CSS_MAP, AbstractComposite::CSS_STYLE_MAP, AbstractComposite::DEFAULT_CLASS, AbstractComposite::LABELS, AbstractComposite::LEGACY_INTERFACE, AbstractComposite::LOOKANDFEEL_MAP, AbstractComposite::SYMBOL_MAP
Constants inherited
from Component
Component::CSS_CLASS, Component::CSS_ID, Component::HTML_ATTRIBUTES, Component::HTTP_HEADERS, Component::LABEL
Instance Attribute Summary
Attributes inherited from Component
#attributes, #dojo_tooltip, #model, #value
Instance Method Summary
collapse
component, #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=, #to_html
Instance Method Details
#compose(model = @model) ⇒ Object
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
# 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) ⇒ Object
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
# 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) ⇒ Object
170
171
172
173
|
# 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) ⇒ Object
175
176
177
178
179
180
181
182
183
|
# 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 ⇒ Object
185
186
187
188
|
# File 'lib/htmlgrid/composite.rb', line 185
def setup_grid
@grid = []
@css_grid = []
end
|
#submit(model = @model, name = event()) ⇒ Object
190
191
192
|
# File 'lib/htmlgrid/composite.rb', line 190
def submit(model = @model, name = event())
Submit.new(name, model, @session, self)
end
|
#tag_attributes(idx = nil) ⇒ Object
194
195
196
197
198
199
200
201
202
203
204
205
206
|
# 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
|