htmlgrid 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/htmlgrid/booleanvalue.rb +14 -14
- data/lib/htmlgrid/button.rb +9 -9
- data/lib/htmlgrid/centeredcomposite.rb +21 -20
- data/lib/htmlgrid/component.rb +214 -199
- data/lib/htmlgrid/composite.rb +332 -301
- data/lib/htmlgrid/datevalue.rb +12 -12
- data/lib/htmlgrid/div.rb +9 -9
- data/lib/htmlgrid/divcomposite.rb +44 -43
- data/lib/htmlgrid/divform.rb +8 -8
- data/lib/htmlgrid/divlist.rb +17 -19
- data/lib/htmlgrid/divtemplate.rb +6 -6
- data/lib/htmlgrid/dojotoolkit.rb +54 -48
- data/lib/htmlgrid/errormessage.rb +47 -43
- data/lib/htmlgrid/form.rb +70 -62
- data/lib/htmlgrid/formlist.rb +14 -14
- data/lib/htmlgrid/grid.rb +111 -67
- data/lib/htmlgrid/image.rb +17 -16
- data/lib/htmlgrid/infomessage.rb +15 -14
- data/lib/htmlgrid/input.rb +34 -32
- data/lib/htmlgrid/inputcheckbox.rb +13 -13
- data/lib/htmlgrid/inputcurrency.rb +9 -9
- data/lib/htmlgrid/inputdate.rb +11 -11
- data/lib/htmlgrid/inputfile.rb +13 -12
- data/lib/htmlgrid/inputradio.rb +9 -9
- data/lib/htmlgrid/inputtext.rb +10 -10
- data/lib/htmlgrid/javascript.rb +17 -16
- data/lib/htmlgrid/label.rb +53 -49
- data/lib/htmlgrid/labeltext.rb +8 -8
- data/lib/htmlgrid/link.rb +31 -27
- data/lib/htmlgrid/list.rb +121 -110
- data/lib/htmlgrid/namedcomponent.rb +28 -25
- data/lib/htmlgrid/pass.rb +11 -11
- data/lib/htmlgrid/passthru.rb +20 -17
- data/lib/htmlgrid/popuplink.rb +41 -39
- data/lib/htmlgrid/reset.rb +8 -8
- data/lib/htmlgrid/richtext.rb +22 -20
- data/lib/htmlgrid/select.rb +28 -26
- data/lib/htmlgrid/span.rb +9 -9
- data/lib/htmlgrid/spancomposite.rb +18 -18
- data/lib/htmlgrid/spanlist.rb +9 -9
- data/lib/htmlgrid/staticinput.rb +14 -13
- data/lib/htmlgrid/submit.rb +9 -9
- data/lib/htmlgrid/template.rb +120 -105
- data/lib/htmlgrid/text.rb +9 -9
- data/lib/htmlgrid/textarea.rb +19 -17
- data/lib/htmlgrid/ulcomposite.rb +22 -22
- data/lib/htmlgrid/ullist.rb +9 -9
- data/lib/htmlgrid/urllink.rb +38 -36
- data/lib/htmlgrid/value.rb +9 -9
- data/lib/htmlgrid/version.rb +2 -2
- data/test/stub/cgi.rb +10 -7
- data/test/suite.rb +3 -3
- data/test/test_add_row.rb +12 -13
- data/test/test_component.rb +121 -100
- data/test/test_composite.rb +85 -46
- data/test/test_datevalue.rb +28 -24
- data/test/test_divlist.rb +126 -0
- data/test/test_dojotoolkit.rb +41 -27
- data/test/test_form.rb +89 -73
- data/test/test_formlist.rb +77 -65
- data/test/test_grid.rb +256 -208
- data/test/test_input.rb +37 -31
- data/test/test_interaction_list.rb +106 -70
- data/test/test_label.rb +91 -77
- data/test/test_list.rb +110 -95
- data/test/test_select.rb +35 -30
- data/test/test_template.rb +63 -55
- data/test/test_text.rb +36 -31
- metadata +17 -2
data/lib/htmlgrid/composite.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
|
3
3
|
#
|
4
4
|
# HtmlGrid -- HyperTextMarkupLanguage Framework
|
5
5
|
# Copyright (C) 2003 ywesee - intellectual capital connected
|
@@ -23,41 +23,41 @@
|
|
23
23
|
# htmlgrid@ywesee.com, www.ywesee.com/htmlgrid
|
24
24
|
#
|
25
25
|
# Template -- htmlgrid -- 03.04.2012 -- yasaka@ywesee.com
|
26
|
-
# Template -- htmlgrid -- 23.02.2012 -- mhatakeyama@ywesee.com
|
27
|
-
# Template -- htmlgrid -- 23.10.2002 -- hwyss@ywesee.com
|
26
|
+
# Template -- htmlgrid -- 23.02.2012 -- mhatakeyama@ywesee.com
|
27
|
+
# Template -- htmlgrid -- 23.10.2002 -- hwyss@ywesee.com
|
28
28
|
|
29
|
-
require
|
30
|
-
require
|
31
|
-
require
|
32
|
-
require
|
33
|
-
require
|
34
|
-
require
|
29
|
+
require "htmlgrid/grid"
|
30
|
+
require "htmlgrid/component"
|
31
|
+
require "htmlgrid/value"
|
32
|
+
require "htmlgrid/inputtext"
|
33
|
+
require "htmlgrid/label"
|
34
|
+
require "htmlgrid/text"
|
35
35
|
|
36
|
-
if RUBY_VERSION <
|
36
|
+
if RUBY_VERSION < "1.9"
|
37
37
|
class Hash
|
38
|
-
|
38
|
+
alias_method :key, :index
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
module HtmlGrid
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
def self.component(klass, key, name=nil)
|
56
|
-
methname = klass.to_s.downcase.gsub(
|
43
|
+
class AbstractComposite < Component
|
44
|
+
LABELS = false
|
45
|
+
LEGACY_INTERFACE = true
|
46
|
+
SYMBOL_MAP = {}
|
47
|
+
CSS_MAP = {}
|
48
|
+
CSS_ID_MAP = {}
|
49
|
+
CSS_STYLE_MAP = {}
|
50
|
+
CSS_CLASS = nil
|
51
|
+
CSS_ID = nil
|
52
|
+
DEFAULT_CLASS = Value
|
53
|
+
LOOKANDFEEL_MAP = {}
|
54
|
+
|
55
|
+
def self.component(klass, key, name = nil)
|
56
|
+
methname = klass.to_s.downcase.gsub("::", "_") << "_" << key.to_s
|
57
57
|
define_method(methname) { |*args|
|
58
58
|
model, session = args
|
59
59
|
args = [model.send(key), session || @session, self]
|
60
|
-
if
|
60
|
+
if name
|
61
61
|
args.unshift(name)
|
62
62
|
lookandfeel_map.store(methname.to_sym, name.to_sym)
|
63
63
|
end
|
@@ -66,289 +66,320 @@ module HtmlGrid
|
|
66
66
|
methname.to_sym
|
67
67
|
end
|
68
68
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
val.
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
69
|
+
def init
|
70
|
+
super
|
71
|
+
setup_grid
|
72
|
+
compose
|
73
|
+
end
|
74
|
+
|
75
|
+
def create(component, model = @model)
|
76
|
+
if component.is_a? Class
|
77
|
+
component.new(model, @session, self)
|
78
|
+
elsif component.is_a? Symbol
|
79
|
+
if respond_to?(component, true)
|
80
|
+
args = [model]
|
81
|
+
if self.class::LEGACY_INTERFACE
|
82
|
+
args.push(@session)
|
83
|
+
end
|
84
|
+
send(component, *args)
|
85
|
+
elsif (klass = symbol_map[component])
|
86
|
+
klass.new(component, model, @session, self)
|
87
|
+
else
|
88
|
+
self.class::DEFAULT_CLASS.new(component, model, @session, self)
|
89
|
+
end
|
90
|
+
elsif component.is_a? String
|
91
|
+
val = @lookandfeel.lookup(component) { component.to_s }
|
92
|
+
val.gsub(@@nl2br_ptrn, "<br>")
|
93
|
+
end
|
94
|
+
rescue => exc
|
95
|
+
exc.backtrace.push(sprintf("%s::COMPONENTS[%s] in create(%s)",
|
96
|
+
self.class, components.key(component).inspect, component))
|
97
|
+
raise exc
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
def components
|
103
|
+
@components ||= self.class::COMPONENTS.dup
|
104
|
+
end
|
105
|
+
|
106
|
+
def css_id_map
|
107
|
+
@css_id_map ||= self.class::CSS_ID_MAP.dup
|
108
|
+
end
|
109
|
+
|
110
|
+
def css_map
|
111
|
+
@css_map ||= self.class::CSS_MAP.dup
|
112
|
+
end
|
113
|
+
|
114
|
+
def css_style_map
|
115
|
+
@css_style_map ||= self.class::CSS_STYLE_MAP.dup
|
116
|
+
end
|
117
|
+
|
118
|
+
def labels?
|
119
|
+
self.class::LABELS
|
120
|
+
end
|
121
|
+
|
122
|
+
def lookandfeel_map
|
123
|
+
@lookandfeel_map ||= self.class::LOOKANDFEEL_MAP.dup
|
124
|
+
end
|
125
|
+
|
126
|
+
def symbol_map
|
127
|
+
@symbol_map ||= self.class::SYMBOL_MAP.dup
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
class TagComposite < AbstractComposite
|
132
|
+
def compose(model = @model)
|
133
|
+
components.sort.each { |pos, component|
|
134
|
+
@grid.push(label(create(component, model), component))
|
135
|
+
css = {}
|
136
|
+
if (klass = css_map[pos])
|
137
|
+
css.store("class", klass)
|
138
|
+
end
|
139
|
+
if (id = css_id_map[pos])
|
140
|
+
css.store("id", id)
|
141
|
+
end
|
142
|
+
if (style = css_style_map[pos])
|
143
|
+
css.store("style", style)
|
144
|
+
end
|
145
|
+
@css_grid.push(css.empty? ? nil : css)
|
146
|
+
}
|
147
|
+
end
|
148
|
+
|
149
|
+
def create(component, model = @model)
|
150
|
+
if component.is_a? Class
|
151
|
+
component.new(model, @session, self)
|
152
|
+
elsif component.is_a? Symbol
|
153
|
+
if respond_to?(component, true)
|
154
|
+
send(component, model)
|
155
|
+
elsif (klass = symbol_map[component])
|
156
|
+
klass.new(component, model, @session, self)
|
157
|
+
else
|
158
|
+
self.class::DEFAULT_CLASS.new(component, model, @session, self)
|
159
|
+
end
|
160
|
+
elsif component.is_a? String
|
161
|
+
val = @lookandfeel.lookup(component) { component.to_s }
|
162
|
+
val.gsub(@@nl2br_ptrn, "<br>")
|
163
|
+
end
|
164
|
+
rescue => exc
|
165
|
+
exc.backtrace.push(sprintf("%s::COMPONENTS[%s] in create(%s)",
|
166
|
+
self.class, components.index(component).inspect, component))
|
167
|
+
raise exc
|
168
|
+
end
|
169
|
+
|
170
|
+
def insert_row(ypos, txt, css_class = nil)
|
171
|
+
@grid[ypos, 0] = [[txt]]
|
172
|
+
@css_grid[ypos, 0] = [css_class ? {"class" => css_class} : nil]
|
173
|
+
end
|
174
|
+
|
175
|
+
def label(component, key)
|
176
|
+
if labels? \
|
177
|
+
&& (!component.respond_to?(:label?) || component.label?)
|
178
|
+
label = SimpleLabel.new(key, component, @session, self)
|
179
|
+
[label, component]
|
180
|
+
else
|
181
|
+
component
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
def setup_grid
|
186
|
+
@grid = []
|
187
|
+
@css_grid = []
|
188
|
+
end
|
189
|
+
|
190
|
+
def submit(model = @model, name = event())
|
191
|
+
Submit.new(name, model, @session, self)
|
192
|
+
end
|
193
|
+
|
194
|
+
def tag_attributes(idx = nil)
|
195
|
+
attr = {}
|
196
|
+
if (klass = self.class.const_get(:CSS_CLASS))
|
197
|
+
attr.store("class", klass)
|
198
|
+
end
|
199
|
+
if (id = self.class.const_get(:CSS_ID))
|
200
|
+
attr.store("id", id)
|
201
|
+
end
|
202
|
+
if idx && (css = @css_grid.at(idx))
|
203
|
+
attr.update(css)
|
204
|
+
end
|
205
|
+
attr
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
class Composite < AbstractComposite
|
210
|
+
COLSPAN_MAP = {}
|
211
|
+
COMPONENT_CSS_MAP = {}
|
212
|
+
CSS_MAP = {}
|
213
|
+
DEFAULT_CLASS = InputText
|
214
|
+
VERTICAL = false
|
215
|
+
def compose(model = @model, offset = [0, 0], bg_flag = false)
|
216
|
+
comps = components
|
217
|
+
css = css_map
|
203
218
|
cids = css_id_map
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
[key.size, key]
|
219
|
+
ccss = component_css_map
|
220
|
+
colsp = colspan_map
|
221
|
+
suffix = resolve_suffix(model, bg_flag)
|
222
|
+
comps.keys.concat(css.keys).concat(colsp.keys).uniq.sort_by { |key|
|
223
|
+
[key.size, key]
|
209
224
|
}.each { |key|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
if(id = cids[key] || cids[nkey])
|
225
|
+
nkey = key[0, 2]
|
226
|
+
matrix = resolve_offset(key, offset)
|
227
|
+
nmatrix = resolve_offset(nkey, offset)
|
228
|
+
comp = compose_component(model, comps[key], matrix)
|
229
|
+
if (style = css[key])
|
230
|
+
@grid.add_style(style + suffix, *matrix)
|
231
|
+
elsif (style = css[nkey])
|
232
|
+
@grid.add_style(style + suffix, *nmatrix)
|
233
|
+
end
|
234
|
+
if (id = cids[key] || cids[nkey])
|
220
235
|
comp.css_id = id
|
221
236
|
end
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
# component-styles depend on components having been initialized
|
237
|
+
if (span = colsp[key])
|
238
|
+
@grid.set_colspan(matrix.at(0), matrix.at(1), span)
|
239
|
+
end
|
240
|
+
}
|
241
|
+
# component-styles depend on components having been initialized
|
227
242
|
# -> separate iteration
|
228
243
|
ccss.each { |key, cstyle|
|
229
244
|
matrix = resolve_offset(key, offset)
|
230
245
|
@grid.add_component_style(cstyle + suffix, *matrix)
|
231
246
|
}
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
=
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
super << @grid.to_html(context).force_encoding(
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
247
|
+
# compose_components(model, offset)
|
248
|
+
# compose_css(offset)
|
249
|
+
# compose_colspan(offset)
|
250
|
+
end
|
251
|
+
alias_method :_compose, :compose
|
252
|
+
def compose_colspan(offset)
|
253
|
+
colspan_map.each { |matrix, span|
|
254
|
+
res = resolve_offset(matrix, offset)
|
255
|
+
@grid.set_colspan(res.at(0), res.at(1), span)
|
256
|
+
}
|
257
|
+
end
|
258
|
+
|
259
|
+
def event
|
260
|
+
@container.event if @container.respond_to?(:event)
|
261
|
+
end
|
262
|
+
|
263
|
+
# def explode!
|
264
|
+
# @grid.explode!
|
265
|
+
# super
|
266
|
+
# end
|
267
|
+
def full_colspan
|
268
|
+
raw_span = components.keys.collect { |key|
|
269
|
+
key.at(0)
|
270
|
+
}.max.to_i
|
271
|
+
raw_span > 0 ? raw_span + 1 : nil
|
272
|
+
end
|
273
|
+
|
274
|
+
def insert_row(ypos, txt, css_class = nil)
|
275
|
+
@grid.insert_row(ypos, txt)
|
276
|
+
@grid.set_colspan(0, ypos)
|
277
|
+
@grid.add_style(css_class, 0, ypos) if css_class
|
278
|
+
end
|
279
|
+
|
280
|
+
def to_html(context)
|
281
|
+
@grid.set_attributes(@attributes)
|
282
|
+
super << @grid.to_html(context).force_encoding("utf-8")
|
283
|
+
end
|
284
|
+
|
285
|
+
private
|
286
|
+
|
287
|
+
def back(model = @model, session = @session)
|
288
|
+
bak = HtmlGrid::Button.new(:back, model, session, self)
|
289
|
+
url = @lookandfeel.event_url(:back)
|
290
|
+
bak.set_attribute("onClick", "document.location.href='#{url}';")
|
291
|
+
bak
|
292
|
+
end
|
293
|
+
|
294
|
+
def colspan_map
|
295
|
+
@colspan_map ||= self.class::COLSPAN_MAP.dup
|
296
|
+
end
|
297
|
+
|
298
|
+
def component_css_map
|
299
|
+
@component_css_map ||= self.class::COMPONENT_CSS_MAP.dup
|
300
|
+
end
|
301
|
+
|
302
|
+
def compose_component(model, component, matrix)
|
303
|
+
if component
|
304
|
+
comp = create(component, model)
|
305
|
+
if (tab = matrix.at(3)) && comp.respond_to?(:tabindex=)
|
306
|
+
comp.tabindex = tab
|
307
|
+
end
|
308
|
+
@grid.add(label(comp, component), matrix.at(0), matrix.at(1),
|
309
|
+
self.class::VERTICAL)
|
290
310
|
comp
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
## compose_components: legacy-code
|
315
|
+
def compose_components(model = @model, offset = [0, 0])
|
316
|
+
warn "HtmlGrid::List#compose_components is deprecated"
|
317
|
+
each_component { |matrix, component|
|
318
|
+
res = resolve_offset(matrix, offset)
|
319
|
+
comp = create(component, model)
|
320
|
+
if (tab = matrix.at(3)) && comp.respond_to?(:tabindex=)
|
321
|
+
comp.tabindex = tab
|
322
|
+
end
|
323
|
+
@grid.add(label(comp, component), res.at(0), res.at(1),
|
324
|
+
self.class::VERTICAL)
|
325
|
+
}
|
326
|
+
end
|
327
|
+
|
328
|
+
## compose_css: legacy-code
|
329
|
+
def compose_css(offset = [0, 0], suffix = "")
|
330
|
+
warn "HtmlGrid::List#compose_css is deprecated"
|
331
|
+
each_css { |matrix, style|
|
332
|
+
@grid.add_style(style + suffix, *resolve_offset(matrix, offset))
|
333
|
+
}
|
334
|
+
each_component_css { |matrix, style|
|
335
|
+
@grid.add_component_style(style + suffix, *resolve_offset(matrix, offset))
|
336
|
+
}
|
337
|
+
end
|
338
|
+
|
339
|
+
def each_component(&block)
|
340
|
+
(@sorted_components ||= components.sort).each(&block)
|
341
|
+
end
|
342
|
+
|
343
|
+
def each_component_css(&block)
|
344
|
+
(@sorted_component_css_map ||= component_css_map.sort).each(&block)
|
345
|
+
end
|
346
|
+
|
347
|
+
def each_css(&block)
|
348
|
+
(@sorted_css_map ||= css_map.sort).each(&block)
|
349
|
+
end
|
350
|
+
|
351
|
+
def label(component, key = nil)
|
352
|
+
if labels?
|
353
|
+
HtmlGrid::Label.new(component, @session, lookandfeel_key(key))
|
354
|
+
else
|
355
|
+
component
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
def lookandfeel_key(component)
|
360
|
+
lookandfeel_map.fetch(component) {
|
361
|
+
component
|
362
|
+
}
|
363
|
+
end
|
364
|
+
|
365
|
+
def setup_grid
|
366
|
+
@grid = Grid.new
|
367
|
+
end
|
368
|
+
|
369
|
+
def submit(model = @model, session = @session, name = event())
|
370
|
+
Submit.new(name, model, session, self)
|
371
|
+
end
|
372
|
+
|
373
|
+
def resolve_offset(matrix, offset = [0, 0])
|
374
|
+
result = []
|
375
|
+
matrix.each_with_index { |value, index|
|
376
|
+
result.push(value + offset.at(index).to_i)
|
377
|
+
}
|
378
|
+
result
|
379
|
+
end
|
380
|
+
|
381
|
+
def resolve_suffix(model, bg_flag = false)
|
382
|
+
bg_flag ? self.class::BACKGROUND_SUFFIX : ""
|
383
|
+
end
|
384
|
+
end
|
354
385
|
end
|