Merge lp:~methanal-developers/methanal/track-saved-and-validity into lp:methanal
- track-saved-and-validity
- Merge into trunk
Proposed by
Jonathan Jacobs
Status: | Merged |
---|---|
Approved by: | Tristan Seligmann |
Approved revision: | 168 |
Merged at revision: | 167 |
Proposed branch: | lp:~methanal-developers/methanal/track-saved-and-validity |
Merge into: | lp:methanal |
Diff against target: |
212 lines (+51/-31) 2 files modified
methanal/js/Methanal/Tests/TestView.js (+35/-29) methanal/js/Methanal/View.js (+16/-2) |
To merge this branch: | bzr merge lp:~methanal-developers/methanal/track-saved-and-validity |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tristan Seligmann | Approve | ||
Review via email: mp+54307@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Jonathan Jacobs (jjacobs) wrote : | # |
> + // An unsuccessful submissino will not remove the modified indicator.
>
> I assume this is a typo.
Fixed.
- 167. By Jonathan Jacobs
-
Fix typo.
Revision history for this message
Tristan Seligmann (mithrandi) wrote : | # |
Bleh. There are conflicts with trunk, now; please resolve them so we can see what the real diff is.
review:
Needs Fixing
Revision history for this message
Jonathan Jacobs (jjacobs) wrote : | # |
> Bleh. There are conflicts with trunk, now; please resolve them so we can see
> what the real diff is.
Done.
- 168. By Jonathan Jacobs
-
Merge trunk and resolve conflicts.
Revision history for this message
Tristan Seligmann (mithrandi) : | # |
review:
Approve
- 169. By Jonathan Jacobs
-
Fix broken test.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'methanal/js/Methanal/Tests/TestView.js' | |||
2 | --- methanal/js/Methanal/Tests/TestView.js 2011-03-31 10:46:20 +0000 | |||
3 | +++ methanal/js/Methanal/Tests/TestView.js 2011-04-11 11:46:38 +0000 | |||
4 | @@ -13,13 +13,11 @@ | |||
5 | 13 | */ | 13 | */ |
6 | 14 | Methanal.View.LiveForm.subclass( | 14 | Methanal.View.LiveForm.subclass( |
7 | 15 | Methanal.Tests.TestView, 'MockLiveForm').methods( | 15 | Methanal.Tests.TestView, 'MockLiveForm').methods( |
11 | 16 | function __init__(self, controlNames, viewOnly) { | 16 | function __init__(self, controlNames, args/*=undefined*/) { |
12 | 17 | viewOnly = viewOnly || false; | 17 | args = args || {}; |
10 | 18 | |||
13 | 19 | var node = Nevow.Test.WidgetUtil.makeWidgetNode(); | 18 | var node = Nevow.Test.WidgetUtil.makeWidgetNode(); |
14 | 20 | Methanal.Tests.TestView.MockLiveForm.upcall( | 19 | Methanal.Tests.TestView.MockLiveForm.upcall( |
17 | 21 | self, '__init__', node, viewOnly, controlNames); | 20 | self, '__init__', node, args, controlNames); |
16 | 22 | |||
18 | 23 | Methanal.Tests.Util.setUpForm(self); | 21 | Methanal.Tests.Util.setUpForm(self); |
19 | 24 | }); | 22 | }); |
20 | 25 | 23 | ||
21 | @@ -67,7 +65,7 @@ | |||
22 | 67 | /** | 65 | /** |
23 | 68 | * Create a C{Methanal.View.LiveForm}. | 66 | * Create a C{Methanal.View.LiveForm}. |
24 | 69 | */ | 67 | */ |
26 | 70 | function createForm(self, viewOnly, controls/*=undefined*/, | 68 | function createForm(self, args, controls/*=undefined*/, |
27 | 71 | postFormInsertion/*=undefined*/) { | 69 | postFormInsertion/*=undefined*/) { |
28 | 72 | controls = controls || []; | 70 | controls = controls || []; |
29 | 73 | var controlNames = []; | 71 | var controlNames = []; |
30 | @@ -75,7 +73,7 @@ | |||
31 | 75 | controlNames.push(controls[i].name); | 73 | controlNames.push(controls[i].name); |
32 | 76 | } | 74 | } |
33 | 77 | 75 | ||
35 | 78 | var form = Methanal.Tests.TestView.MockLiveForm(controlNames, viewOnly); | 76 | var form = Methanal.Tests.TestView.MockLiveForm(controlNames, args); |
36 | 79 | Methanal.Tests.Util.setUpForm(form); | 77 | Methanal.Tests.Util.setUpForm(form); |
37 | 80 | Methanal.Util.nodeInserted(form); | 78 | Methanal.Util.nodeInserted(form); |
38 | 81 | if (postFormInsertion) { | 79 | if (postFormInsertion) { |
39 | @@ -111,7 +109,9 @@ | |||
40 | 111 | */ | 109 | */ |
41 | 112 | function test_freezeThaw(self) { | 110 | function test_freezeThaw(self) { |
42 | 113 | var control = self.createControl({'name': 'a'}); | 111 | var control = self.createControl({'name': 'a'}); |
44 | 114 | var form = self.createForm(false, [control]); | 112 | var args = { |
45 | 113 | 'viewOnly': false}; | ||
46 | 114 | var form = self.createForm(args, [control]); | ||
47 | 115 | form.freeze(); | 115 | form.freeze(); |
48 | 116 | self.assertIdentical(form._frozen, 1); | 116 | self.assertIdentical(form._frozen, 1); |
49 | 117 | form.freeze(); | 117 | form.freeze(); |
50 | @@ -130,10 +130,14 @@ | |||
51 | 130 | * Setting the form valid / invalid enables / disables the actions. | 130 | * Setting the form valid / invalid enables / disables the actions. |
52 | 131 | */ | 131 | */ |
53 | 132 | function test_validInvalid(self) { | 132 | function test_validInvalid(self) { |
55 | 133 | var form = self.createForm(); | 133 | var args = { |
56 | 134 | 'viewOnly': false}; | ||
57 | 135 | var form = self.createForm(args); | ||
58 | 134 | form.setValid(); | 136 | form.setValid(); |
59 | 137 | self.assertIdentical(form.valid, true); | ||
60 | 135 | self.assertIdentical(form.actions._disabled, false); | 138 | self.assertIdentical(form.actions._disabled, false); |
61 | 136 | form.setInvalid(); | 139 | form.setInvalid(); |
62 | 140 | self.assertIdentical(form.valid, false); | ||
63 | 137 | self.assertIdentical(form.actions._disabled, true); | 141 | self.assertIdentical(form.actions._disabled, true); |
64 | 138 | }, | 142 | }, |
65 | 139 | 143 | ||
66 | @@ -146,7 +150,9 @@ | |||
67 | 146 | function test_submission(self) { | 150 | function test_submission(self) { |
68 | 147 | var success; | 151 | var success; |
69 | 148 | var control = self.createControl({'name': 'a'}); | 152 | var control = self.createControl({'name': 'a'}); |
71 | 149 | var form = self.createForm(false, [control]); | 153 | var args = { |
72 | 154 | 'viewOnly': false}; | ||
73 | 155 | var form = self.createForm(args, [control]); | ||
74 | 150 | 156 | ||
75 | 151 | function succeed(methodName, data) { | 157 | function succeed(methodName, data) { |
76 | 152 | self.assertIdentical(form.actions._disabled, true); | 158 | self.assertIdentical(form.actions._disabled, true); |
77 | @@ -158,22 +164,20 @@ | |||
78 | 158 | return Divmod.Defer.fail('too bad'); | 164 | return Divmod.Defer.fail('too bad'); |
79 | 159 | }; | 165 | }; |
80 | 160 | 166 | ||
81 | 161 | form.submitSuccess = function (data) { | ||
82 | 162 | self.assertIdentical(form.actions._disabled, false); | ||
83 | 163 | success = true; | ||
84 | 164 | }; | ||
85 | 165 | form.submitFailure = function (error) { | ||
86 | 166 | self.assertIdentical(form.actions._disabled, false); | ||
87 | 167 | success = false; | ||
88 | 168 | }; | ||
89 | 169 | |||
90 | 170 | form.callRemote = succeed; | 167 | form.callRemote = succeed; |
91 | 168 | form.formModified(true); | ||
92 | 169 | self.assertIdentical(form.modified, true); | ||
93 | 171 | form.submit(); | 170 | form.submit(); |
95 | 172 | self.assertIdentical(success, true); | 171 | self.assertIdentical(form.modified, false); |
96 | 172 | self.assertIdentical(form.actions._disabled, false); | ||
97 | 173 | 173 | ||
98 | 174 | form.callRemote = fail; | 174 | form.callRemote = fail; |
99 | 175 | form.formModified(true); | ||
100 | 176 | self.assertIdentical(form.modified, true); | ||
101 | 175 | form.submit(); | 177 | form.submit(); |
103 | 176 | self.assertIdentical(success, false); | 178 | // An unsuccessful submission will not remove the modified indicator. |
104 | 179 | self.assertIdentical(form.modified, true); | ||
105 | 180 | self.assertIdentical(form.actions._disabled, false); | ||
106 | 177 | }, | 181 | }, |
107 | 178 | 182 | ||
108 | 179 | 183 | ||
109 | @@ -251,15 +255,14 @@ | |||
110 | 251 | */ | 255 | */ |
111 | 252 | function test_formModified(self) { | 256 | function test_formModified(self) { |
112 | 253 | var control = self.createControl({'name': 'a'}); | 257 | var control = self.createControl({'name': 'a'}); |
114 | 254 | var form = self.createForm(false, [control]); | 258 | var args = { |
115 | 259 | 'viewOnly': false, | ||
116 | 260 | 'submitted': true}; | ||
117 | 261 | var form = self.createForm(args, [control]); | ||
118 | 255 | var containsElementClass = Methanal.Util.containsElementClass; | 262 | var containsElementClass = Methanal.Util.containsElementClass; |
122 | 256 | self.assertIdentical( | 263 | self.assertIdentical(form.modified, false) |
120 | 257 | containsElementClass(form.nodeById('modifiedIndicator'), 'hidden'), | ||
121 | 258 | true); | ||
123 | 259 | control.onChange(); | 264 | control.onChange(); |
127 | 260 | self.assertIdentical( | 265 | self.assertIdentical(form.modified, true) |
125 | 261 | containsElementClass(form.nodeById('modifiedIndicator'), 'hidden'), | ||
126 | 262 | false); | ||
128 | 263 | }, | 266 | }, |
129 | 264 | 267 | ||
130 | 265 | 268 | ||
131 | @@ -269,7 +272,10 @@ | |||
132 | 269 | function test_formLoaded(self) { | 272 | function test_formLoaded(self) { |
133 | 270 | var success = false; | 273 | var success = false; |
134 | 271 | var control = self.createControl({'name': 'a'}); | 274 | var control = self.createControl({'name': 'a'}); |
136 | 272 | var form = self.createForm(false, [control], function (form) { | 275 | var args = { |
137 | 276 | 'viewOnly': false, | ||
138 | 277 | 'submitted': true}; | ||
139 | 278 | var form = self.createForm(args, [control], function (form) { | ||
140 | 273 | self.assertIdentical( | 279 | self.assertIdentical( |
141 | 274 | success, | 280 | success, |
142 | 275 | false); | 281 | false); |
143 | 276 | 282 | ||
144 | === modified file 'methanal/js/Methanal/View.js' | |||
145 | --- methanal/js/Methanal/View.js 2011-03-28 13:23:01 +0000 | |||
146 | +++ methanal/js/Methanal/View.js 2011-04-11 11:46:38 +0000 | |||
147 | @@ -930,7 +930,7 @@ | |||
148 | 930 | * @type viewOnly: C{boolean} | 930 | * @type viewOnly: C{boolean} |
149 | 931 | * @ivar viewOnly: Are form actions disabled for this form? | 931 | * @ivar viewOnly: Are form actions disabled for this form? |
150 | 932 | * | 932 | * |
152 | 933 | * @type hideModificationIndicator: C{boolean} | 933 | * @type hideModificationIndicator: C{Boolean} |
153 | 934 | * @ivar hideModificationIndicator: Hide the modification indicator for this | 934 | * @ivar hideModificationIndicator: Hide the modification indicator for this |
154 | 935 | * form? Defaults to C{false}. | 935 | * form? Defaults to C{false}. |
155 | 936 | * | 936 | * |
156 | @@ -940,6 +940,14 @@ | |||
157 | 940 | * @type actions: L{Methanal.View.ActionContainer} | 940 | * @type actions: L{Methanal.View.ActionContainer} |
158 | 941 | * @ivar actions: Action container widget, this is only assigned once the action | 941 | * @ivar actions: Action container widget, this is only assigned once the action |
159 | 942 | * container widget's C{nodeInserted} method has been called | 942 | * container widget's C{nodeInserted} method has been called |
160 | 943 | * | ||
161 | 944 | * @type modified: C{Boolean} | ||
162 | 945 | * @ivar modified: Have any inputs in this LiveForm been modified since | ||
163 | 946 | * creation or the last successful submission? | ||
164 | 947 | * | ||
165 | 948 | * @type valid: C{Boolean} | ||
166 | 949 | * @ivar valid: Is this LiveForm currently in a valid state, i.e. no | ||
167 | 950 | * validation errors are present? Defaults to C{true}. | ||
168 | 943 | */ | 951 | */ |
169 | 944 | Methanal.View.FormBehaviour.subclass(Methanal.View, 'LiveForm').methods( | 952 | Methanal.View.FormBehaviour.subclass(Methanal.View, 'LiveForm').methods( |
170 | 945 | function __init__(self, node, args, controlNames) { | 953 | function __init__(self, node, args, controlNames) { |
171 | @@ -949,7 +957,8 @@ | |||
172 | 949 | Divmod.warn( | 957 | Divmod.warn( |
173 | 950 | 'Use an argument dictionary instead of the "viewOnly"' + | 958 | 'Use an argument dictionary instead of the "viewOnly"' + |
174 | 951 | 'boolean parameter', Divmod.DeprecationWarning); | 959 | 'boolean parameter', Divmod.DeprecationWarning); |
176 | 952 | args = {'viewOnly': args}; | 960 | args = { |
177 | 961 | 'viewOnly': args}; | ||
178 | 953 | } | 962 | } |
179 | 954 | self.viewOnly = args.viewOnly; | 963 | self.viewOnly = args.viewOnly; |
180 | 955 | self.hideModificationIndicator = args.hideModificationIndicator; | 964 | self.hideModificationIndicator = args.hideModificationIndicator; |
181 | @@ -958,6 +967,8 @@ | |||
182 | 958 | } | 967 | } |
183 | 959 | self.controlNames = Methanal.Util.arrayToMapping(controlNames); | 968 | self.controlNames = Methanal.Util.arrayToMapping(controlNames); |
184 | 960 | self._controlNamesOrdered = controlNames; | 969 | self._controlNamesOrdered = controlNames; |
185 | 970 | self.modified = false; | ||
186 | 971 | self.valid = true; | ||
187 | 961 | self.formInit(); | 972 | self.formInit(); |
188 | 962 | }, | 973 | }, |
189 | 963 | 974 | ||
190 | @@ -1162,6 +1173,7 @@ | |||
191 | 1162 | if (!self.hideModificationIndicator) { | 1173 | if (!self.hideModificationIndicator) { |
192 | 1163 | self.actions.modifiedIndicator(modified); | 1174 | self.actions.modifiedIndicator(modified); |
193 | 1164 | } | 1175 | } |
194 | 1176 | self.modified = modified; | ||
195 | 1165 | }, | 1177 | }, |
196 | 1166 | 1178 | ||
197 | 1167 | 1179 | ||
198 | @@ -1175,6 +1187,7 @@ | |||
199 | 1175 | * Enable the form for submission. | 1187 | * Enable the form for submission. |
200 | 1176 | */ | 1188 | */ |
201 | 1177 | function setValid(self) { | 1189 | function setValid(self) { |
202 | 1190 | self.valid = true; | ||
203 | 1178 | self.actions.enable(); | 1191 | self.actions.enable(); |
204 | 1179 | }, | 1192 | }, |
205 | 1180 | 1193 | ||
206 | @@ -1183,6 +1196,7 @@ | |||
207 | 1183 | * Disable form submission. | 1196 | * Disable form submission. |
208 | 1184 | */ | 1197 | */ |
209 | 1185 | function setInvalid(self) { | 1198 | function setInvalid(self) { |
210 | 1199 | self.valid = false; | ||
211 | 1186 | self.actions.disable(); | 1200 | self.actions.disable(); |
212 | 1187 | }); | 1201 | }); |
213 | 1188 | 1202 |
+ // An unsuccessful submissino will not remove the modified indicator.
I assume this is a typo.