htmlgrid 1.2.0 → 1.2.1

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