htmlgrid 1.1.7 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) 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 -197
  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 +121 -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 +141 -91
  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 -26
  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 +66 -55
  69. data/test/test_text.rb +36 -31
  70. metadata +17 -4
  71. data/TooltipDialog.txt +0 -73
  72. data/interaction_no_inline.txt +0 -1216
data/test/test_label.rb CHANGED
@@ -21,91 +21,105 @@
21
21
  # ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zuerich, Switzerland
22
22
  # htmlgrid@ywesee.com, www.ywesee.com/htmlgrid
23
23
  #
24
- # TestLabel -- htmlgrid -- 26.11.2002 -- hwyss@ywesee.com
24
+ # TestLabel -- htmlgrid -- 26.11.2002 -- hwyss@ywesee.com
25
25
 
26
26
  $: << File.dirname(__FILE__)
27
27
  $: << File.expand_path("../lib", File.dirname(__FILE__))
28
28
 
29
- require 'minitest/autorun'
30
- require 'stub/cgi'
31
- require 'htmlgrid/label'
32
- require 'htmlgrid/composite'
29
+ require "minitest/autorun"
30
+ require "stub/cgi"
31
+ require "htmlgrid/label"
32
+ require "htmlgrid/composite"
33
33
 
34
34
  class TestLabel < Minitest::Test
35
- class StubLabelState
36
- attr_reader :errors
37
- def initialize(errors={})
38
- @errors = errors
39
- end
40
- end
41
- class StubLabelModel
42
- end
43
- class StubLabelSession
44
- attr_writer :state
45
- def state
46
- @state ||= StubLabelState.new
47
- end
48
- def lookup(key)
49
- case key
50
- when :componentname
51
- 'Label'
52
- when :named_component
53
- 'Named Label'
54
- end
55
- end
56
- def lookandfeel
57
- self
58
- end
59
- def error(key)
60
- state.errors[key]
61
- end
62
- end
63
- class StubLabelComponent < HtmlGrid::Component
64
- attr_accessor :mey
65
- def initialize(model, session=nil, container=nil)
35
+ class StubLabelState
36
+ attr_reader :errors
37
+ def initialize(errors = {})
38
+ @errors = errors
39
+ end
40
+ end
41
+
42
+ class StubLabelModel
43
+ end
44
+
45
+ class StubLabelSession
46
+ attr_writer :state
47
+ def state
48
+ @state ||= StubLabelState.new
49
+ end
50
+
51
+ def lookup(key)
52
+ case key
53
+ when :componentname
54
+ "Label"
55
+ when :named_component
56
+ "Named Label"
57
+ end
58
+ end
59
+
60
+ def lookandfeel
61
+ self
62
+ end
63
+
64
+ def error(key)
65
+ state.errors[key]
66
+ end
67
+ end
68
+
69
+ class StubLabelComponent < HtmlGrid::Component
70
+ attr_accessor :mey
71
+ def initialize(model, session = nil, container = nil)
66
72
  @mey = nil
67
73
  super
68
74
  end
69
- def to_html(context)
70
- 'component'
71
- end
72
- def label?
73
- true
74
- end
75
- def name
76
- :componentname
77
- end
78
- def css_class
79
- @mey
80
- end
81
- end
82
- class StubLabelComposite < HtmlGrid::Composite
83
- COMPONENTS = {
84
- [0,0] => StubLabelComponent,
85
- [0,1] => :named_component,
86
- }
87
- LABELS = true
88
- def named_component(model, session)
89
- @named_component ||= StubLabelComponent.new(model, session, self)
90
- end
91
- end
92
- def setup
93
- @session = StubLabelSession.new
94
- #@label = HtmlGrid::Label.new(component)
95
- end
96
- def test_to_html1
97
- composite = StubLabelComposite.new(StubLabelModel.new, @session)
98
- expected = '<TABLE cellspacing="0"><TR>'
99
- expected << '<TD><LABEL for="componentname">Label</LABEL></TD>'
100
- expected << '<TD>component</TD></TR>'
101
- expected << '<TR><TD><LABEL for="componentname">Named Label</LABEL></TD>'
102
- expected << '<TD>component</TD></TR></TABLE>'
103
- assert_equal(expected, composite.to_html(CGI.new))
104
- end
105
- def test_to_html2
106
- @session.state = StubLabelState.new({:named_component => 'ein Error'})
107
- composite = StubLabelComposite.new(StubLabelModel.new, @session)
75
+
76
+ def to_html(context)
77
+ "component"
78
+ end
79
+
80
+ def label?
81
+ true
82
+ end
83
+
84
+ def name
85
+ :componentname
86
+ end
87
+
88
+ def css_class
89
+ @mey
90
+ end
91
+ end
92
+
93
+ class StubLabelComposite < HtmlGrid::Composite
94
+ COMPONENTS = {
95
+ [0, 0] => StubLabelComponent,
96
+ [0, 1] => :named_component
97
+ }
98
+ LABELS = true
99
+ def named_component(model, session)
100
+ @named_component ||= StubLabelComponent.new(model, session, self)
101
+ end
102
+ end
103
+
104
+ def setup
105
+ @session = StubLabelSession.new
106
+ # @label = HtmlGrid::Label.new(component)
107
+ end
108
+
109
+ def test_to_html1
110
+ composite = StubLabelComposite.new(StubLabelModel.new, @session)
111
+ expected = '<TABLE cellspacing="0"><TR>'
112
+ expected << '<TD><LABEL for="componentname">Label</LABEL></TD>'
113
+ expected << "<TD>component</TD></TR>"
114
+ expected << '<TR><TD><LABEL for="componentname">Named Label</LABEL></TD>'
115
+ expected << "<TD>component</TD></TR></TABLE>"
116
+ assert_equal(expected, composite.to_html(CGI.new))
117
+ end
118
+
119
+ def test_to_html2
120
+ @session.state = StubLabelState.new({named_component: "ein Error"})
121
+ composite = StubLabelComposite.new(StubLabelModel.new, @session)
108
122
  expected = '<TABLE cellspacing="0"><TR><TD><LABEL for="componentname">Label</LABEL></TD><TD>component</TD></TR><TR><TD><LABEL for="componentname" class="error">Named Label</LABEL></TD><TD>component</TD></TR></TABLE>'
109
- assert_equal(expected, composite.to_html(CGI.new))
110
- end
123
+ assert_equal(expected, composite.to_html(CGI.new))
124
+ end
111
125
  end
data/test/test_list.rb CHANGED
@@ -21,118 +21,133 @@
21
21
  # ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zuerich, Switzerland
22
22
  # htmlgrid@ywesee.com, www.ywesee.com/htmlgrid
23
23
  #
24
- # TestList -- htmlgrid -- 03.03.2003 -- hwyss@ywesee.com
24
+ # TestList -- htmlgrid -- 03.03.2003 -- hwyss@ywesee.com
25
25
 
26
26
  $: << File.dirname(__FILE__)
27
27
  $: << File.expand_path("../lib", File.dirname(__FILE__))
28
28
 
29
- require 'minitest/autorun'
30
- require 'htmlgrid/list'
31
- require 'stub/cgi'
32
- require 'test_helper'
29
+ require "minitest/autorun"
30
+ require "htmlgrid/list"
31
+ require "stub/cgi"
32
+ require "test_helper"
33
33
 
34
34
  module HtmlGrid
35
- class List < Composite
36
- attr_reader :grid
37
- public :lookandfeel_key
38
- end
35
+ class List < Composite
36
+ attr_reader :grid
37
+ public :lookandfeel_key
38
+ end
39
39
  end
40
+
40
41
  class StubListViewColumnNames < HtmlGrid::List
41
- LOOKANDFEEL_MAP = {
42
- :raffi => :waltert,
43
- :andy => :schrafl,
44
- }
45
- COMPONENTS = {}
42
+ LOOKANDFEEL_MAP = {
43
+ raffi: :waltert,
44
+ andy: :schrafl
45
+ }
46
+ COMPONENTS = {}
46
47
  end
48
+
47
49
  class StubList < HtmlGrid::List
48
- attr_reader :model
49
- COMPONENTS = {
50
- [0,0] => :jaguar,
51
- [1,0] => :panther,
52
- }
53
- CSS_MAP = {
54
- [0,0] => 'flecken',
55
- [1,0] => 'schwarz',
56
- }
57
- SORT_HEADER = false
58
- SORT_DEFAULT = :foo
50
+ attr_reader :model
51
+ COMPONENTS = {
52
+ [0, 0] => :jaguar,
53
+ [1, 0] => :panther
54
+ }
55
+ CSS_MAP = {
56
+ [0, 0] => "flecken",
57
+ [1, 0] => "schwarz"
58
+ }
59
+ SORT_HEADER = false
60
+ SORT_DEFAULT = :foo
59
61
  end
62
+
60
63
  class StubListLookandfeel
61
- def lookup(key)
62
- key
63
- end
64
- def attributes(key)
65
- {}
66
- end
64
+ def lookup(key)
65
+ key
66
+ end
67
+
68
+ def attributes(key)
69
+ {}
70
+ end
67
71
  end
72
+
68
73
  class StubListSession
69
- attr_accessor :event
70
- def lookandfeel
71
- StubListLookandfeel.new
72
- end
74
+ attr_accessor :event
75
+ def lookandfeel
76
+ StubListLookandfeel.new
77
+ end
73
78
  end
79
+
74
80
  class StubListModel
75
- attr_reader :foo
76
- def initialize(foo)
77
- @foo = foo
78
- end
79
- def jaguar
80
- 'Jaguar'
81
- end
82
- def panther
83
- 'Panther'
84
- end
85
- end
81
+ attr_reader :foo
82
+ def initialize(foo)
83
+ @foo = foo
84
+ end
85
+
86
+ def jaguar
87
+ "Jaguar"
88
+ end
89
+
90
+ def panther
91
+ "Panther"
92
+ end
93
+ end
86
94
 
87
95
  class TestList < Minitest::Test
88
- def setup
89
- model = [
90
- StubListModel.new(3),
91
- StubListModel.new(2),
92
- StubListModel.new(4),
93
- StubListModel.new(1),
94
- ]
95
- @list = StubList.new(model, StubListSession.new)
96
- end
97
- def test_compose
98
- @list.compose
99
- assert_equal(5, @list.grid.height)
100
- assert_equal(2, @list.grid.width)
101
- end
102
- def test_default_sort
103
- foos = @list.model.collect { |item| item.foo }
104
- expected = [ 1,2,3,4 ]
105
- assert_equal(expected, foos)
106
- end
107
- def test_header
108
- expected = '<TABLE cellspacing="0"><TR><TH title="th_jaguar_title">th_jaguar</TH><TH title="th_panther_title">th_panther</TH>'
109
- assert_equal(0, @list.to_html(CGI.new).index(expected))
110
- end
111
- def test_lookandfeel_key
112
- list = StubListViewColumnNames.new([], StubListSession.new)
113
- assert_equal(:waltert, list.lookandfeel_key(:raffi))
114
- assert_equal(:hannes, list.lookandfeel_key(:hannes))
115
- end
116
- def test_nil_robust
96
+ def setup
97
+ model = [
98
+ StubListModel.new(3),
99
+ StubListModel.new(2),
100
+ StubListModel.new(4),
101
+ StubListModel.new(1)
102
+ ]
103
+ @list = StubList.new(model, StubListSession.new)
104
+ end
105
+
106
+ def test_compose
107
+ @list.compose
108
+ assert_equal(5, @list.grid.height)
109
+ assert_equal(2, @list.grid.width)
110
+ end
111
+
112
+ def test_default_sort
113
+ foos = @list.model.collect { |item| item.foo }
114
+ expected = [1, 2, 3, 4]
115
+ assert_equal(expected, foos)
116
+ end
117
+
118
+ def test_header
119
+ expected = '<TABLE cellspacing="0"><TR><TH title="th_jaguar_title">th_jaguar</TH><TH title="th_panther_title">th_panther</TH>'
120
+ assert_equal(0, @list.to_html(CGI.new).index(expected))
121
+ end
122
+
123
+ def test_lookandfeel_key
124
+ list = StubListViewColumnNames.new([], StubListSession.new)
125
+ assert_equal(:waltert, list.lookandfeel_key(:raffi))
126
+ assert_equal(:hannes, list.lookandfeel_key(:hannes))
127
+ end
128
+
129
+ def test_nil_robust
117
130
  StubList.new(nil, StubListSession.new)
118
- end
119
- def test_suffix
120
- @list.compose
121
- expected = {
122
- [0,1] => "flecken",
123
- [1,1] => "schwarz",
124
- [0,2] => "flecken-bg",
125
- [1,2] => "schwarz-bg",
126
- [0,3] => "flecken",
127
- [1,3] => "schwarz",
128
- [0,4] => "flecken-bg",
129
- [1,4] => "schwarz-bg",
130
- }
131
- expected.each { |key, value|
132
- assert_equal(value, @list.grid.field_attribute("class", *key))
133
- }
134
- end
135
- def test_title
136
- assert_equal('th_jaguar_title', @list.grid.field_attribute('title', 0, 0))
137
- end
131
+ end
132
+
133
+ def test_suffix
134
+ @list.compose
135
+ expected = {
136
+ [0, 1] => "flecken",
137
+ [1, 1] => "schwarz",
138
+ [0, 2] => "flecken-bg",
139
+ [1, 2] => "schwarz-bg",
140
+ [0, 3] => "flecken",
141
+ [1, 3] => "schwarz",
142
+ [0, 4] => "flecken-bg",
143
+ [1, 4] => "schwarz-bg"
144
+ }
145
+ expected.each { |key, value|
146
+ assert_equal(value, @list.grid.field_attribute("class", *key))
147
+ }
148
+ end
149
+
150
+ def test_title
151
+ assert_equal("th_jaguar_title", @list.grid.field_attribute("title", 0, 0))
152
+ end
138
153
  end
data/test/test_select.rb CHANGED
@@ -21,50 +21,55 @@
21
21
  # ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zuerich, Switzerland
22
22
  # htmlgrid@ywesee.com, www.ywesee.com/htmlgrid
23
23
  #
24
- # TestSelect -- htmlgrid -- 10.03.2003 -- hwyss@ywesee.com
24
+ # TestSelect -- htmlgrid -- 10.03.2003 -- hwyss@ywesee.com
25
25
 
26
26
  $LOAD_PATH << File.expand_path("../lib", File.dirname(__FILE__))
27
27
  $LOAD_PATH << File.dirname(__FILE__)
28
28
 
29
- require 'minitest/autorun'
30
- require 'htmlgrid/select'
31
- require 'stub/cgi'
29
+ require "minitest/autorun"
30
+ require "htmlgrid/select"
31
+ require "stub/cgi"
32
32
 
33
33
  class StubSelectLookandfeel
34
- def attributes(key)
35
- {}
36
- end
37
- def lookup(key)
38
- {
39
- 'foofoo' => 'Foo Nr. 1',
40
- 'foobar' => 'Foo Nr. 2',
41
- 'barfoo' => 'Bar Nr. 1',
42
- 'barbar' => 'Bar Nr. 2',
43
- 'foovals' => 'FooLabel',
44
- }.fetch(key)
45
- end
34
+ def attributes(key)
35
+ {}
36
+ end
37
+
38
+ def lookup(key)
39
+ {
40
+ "foofoo" => "Foo Nr. 1",
41
+ "foobar" => "Foo Nr. 2",
42
+ "barfoo" => "Bar Nr. 1",
43
+ "barbar" => "Bar Nr. 2",
44
+ "foovals" => "FooLabel"
45
+ }.fetch(key)
46
+ end
46
47
  end
48
+
47
49
  class StubSelectSession
48
- def valid_values(key)
49
- [ 'foofoo', 'foobar', 'barfoo', 'barbar' ]
50
- end
51
- def lookandfeel
52
- StubSelectLookandfeel.new
53
- end
50
+ def valid_values(key)
51
+ ["foofoo", "foobar", "barfoo", "barbar"]
52
+ end
53
+
54
+ def lookandfeel
55
+ StubSelectLookandfeel.new
56
+ end
54
57
  end
58
+
55
59
  class StubSelectData
56
- def foovals
57
- 'foobar'
58
- end
60
+ def foovals
61
+ "foobar"
62
+ end
59
63
  end
60
64
 
61
65
  class TestSelect < Minitest::Test
62
- def setup
63
- @component = HtmlGrid::Select.new(:foovals, StubSelectData.new,
64
- StubSelectSession.new)
65
- end
66
+ def setup
67
+ @component = HtmlGrid::Select.new(:foovals, StubSelectData.new,
68
+ StubSelectSession.new)
69
+ end
70
+
66
71
  def test_to_html
67
- assert_equal(<<-SEL.gsub(/\n|^\s*/, ''), @component.to_html(CGI.new).to_s)
72
+ assert_equal(<<-SEL.gsub(/\n|^\s*/, ""), @component.to_html(CGI.new).to_s)
68
73
  <SELECT name="foovals">
69
74
  <OPTION value="foofoo">Foo Nr. 1</OPTION>
70
75
  <OPTION value="foobar" selected>Foo Nr. 2</OPTION>