Merge lp:~methanal-developers/methanal/track-saved-and-validity into lp:methanal

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
Reviewer Review Type Date Requested Status
Tristan Seligmann Approve
Review via email: mp+54307@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Tristan Seligmann (mithrandi) wrote :

+ // An unsuccessful submissino will not remove the modified indicator.

I assume this is a typo.

review: Needs Fixing
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
=== modified file 'methanal/js/Methanal/Tests/TestView.js'
--- methanal/js/Methanal/Tests/TestView.js 2011-03-31 10:46:20 +0000
+++ methanal/js/Methanal/Tests/TestView.js 2011-04-11 11:46:38 +0000
@@ -13,13 +13,11 @@
13 */13 */
14Methanal.View.LiveForm.subclass(14Methanal.View.LiveForm.subclass(
15 Methanal.Tests.TestView, 'MockLiveForm').methods(15 Methanal.Tests.TestView, 'MockLiveForm').methods(
16 function __init__(self, controlNames, viewOnly) {16 function __init__(self, controlNames, args/*=undefined*/) {
17 viewOnly = viewOnly || false;17 args = args || {};
18
19 var node = Nevow.Test.WidgetUtil.makeWidgetNode();18 var node = Nevow.Test.WidgetUtil.makeWidgetNode();
20 Methanal.Tests.TestView.MockLiveForm.upcall(19 Methanal.Tests.TestView.MockLiveForm.upcall(
21 self, '__init__', node, viewOnly, controlNames);20 self, '__init__', node, args, controlNames);
22
23 Methanal.Tests.Util.setUpForm(self);21 Methanal.Tests.Util.setUpForm(self);
24 });22 });
2523
@@ -67,7 +65,7 @@
67 /**65 /**
68 * Create a C{Methanal.View.LiveForm}.66 * Create a C{Methanal.View.LiveForm}.
69 */67 */
70 function createForm(self, viewOnly, controls/*=undefined*/,68 function createForm(self, args, controls/*=undefined*/,
71 postFormInsertion/*=undefined*/) {69 postFormInsertion/*=undefined*/) {
72 controls = controls || [];70 controls = controls || [];
73 var controlNames = [];71 var controlNames = [];
@@ -75,7 +73,7 @@
75 controlNames.push(controls[i].name);73 controlNames.push(controls[i].name);
76 }74 }
7775
78 var form = Methanal.Tests.TestView.MockLiveForm(controlNames, viewOnly);76 var form = Methanal.Tests.TestView.MockLiveForm(controlNames, args);
79 Methanal.Tests.Util.setUpForm(form);77 Methanal.Tests.Util.setUpForm(form);
80 Methanal.Util.nodeInserted(form);78 Methanal.Util.nodeInserted(form);
81 if (postFormInsertion) {79 if (postFormInsertion) {
@@ -111,7 +109,9 @@
111 */109 */
112 function test_freezeThaw(self) {110 function test_freezeThaw(self) {
113 var control = self.createControl({'name': 'a'});111 var control = self.createControl({'name': 'a'});
114 var form = self.createForm(false, [control]);112 var args = {
113 'viewOnly': false};
114 var form = self.createForm(args, [control]);
115 form.freeze();115 form.freeze();
116 self.assertIdentical(form._frozen, 1);116 self.assertIdentical(form._frozen, 1);
117 form.freeze();117 form.freeze();
@@ -130,10 +130,14 @@
130 * Setting the form valid / invalid enables / disables the actions.130 * Setting the form valid / invalid enables / disables the actions.
131 */131 */
132 function test_validInvalid(self) {132 function test_validInvalid(self) {
133 var form = self.createForm();133 var args = {
134 'viewOnly': false};
135 var form = self.createForm(args);
134 form.setValid();136 form.setValid();
137 self.assertIdentical(form.valid, true);
135 self.assertIdentical(form.actions._disabled, false);138 self.assertIdentical(form.actions._disabled, false);
136 form.setInvalid();139 form.setInvalid();
140 self.assertIdentical(form.valid, false);
137 self.assertIdentical(form.actions._disabled, true);141 self.assertIdentical(form.actions._disabled, true);
138 },142 },
139143
@@ -146,7 +150,9 @@
146 function test_submission(self) {150 function test_submission(self) {
147 var success;151 var success;
148 var control = self.createControl({'name': 'a'});152 var control = self.createControl({'name': 'a'});
149 var form = self.createForm(false, [control]);153 var args = {
154 'viewOnly': false};
155 var form = self.createForm(args, [control]);
150156
151 function succeed(methodName, data) {157 function succeed(methodName, data) {
152 self.assertIdentical(form.actions._disabled, true);158 self.assertIdentical(form.actions._disabled, true);
@@ -158,22 +164,20 @@
158 return Divmod.Defer.fail('too bad');164 return Divmod.Defer.fail('too bad');
159 };165 };
160166
161 form.submitSuccess = function (data) {
162 self.assertIdentical(form.actions._disabled, false);
163 success = true;
164 };
165 form.submitFailure = function (error) {
166 self.assertIdentical(form.actions._disabled, false);
167 success = false;
168 };
169
170 form.callRemote = succeed;167 form.callRemote = succeed;
168 form.formModified(true);
169 self.assertIdentical(form.modified, true);
171 form.submit();170 form.submit();
172 self.assertIdentical(success, true);171 self.assertIdentical(form.modified, false);
172 self.assertIdentical(form.actions._disabled, false);
173173
174 form.callRemote = fail;174 form.callRemote = fail;
175 form.formModified(true);
176 self.assertIdentical(form.modified, true);
175 form.submit();177 form.submit();
176 self.assertIdentical(success, false);178 // An unsuccessful submission will not remove the modified indicator.
179 self.assertIdentical(form.modified, true);
180 self.assertIdentical(form.actions._disabled, false);
177 },181 },
178182
179183
@@ -251,15 +255,14 @@
251 */255 */
252 function test_formModified(self) {256 function test_formModified(self) {
253 var control = self.createControl({'name': 'a'});257 var control = self.createControl({'name': 'a'});
254 var form = self.createForm(false, [control]);258 var args = {
259 'viewOnly': false,
260 'submitted': true};
261 var form = self.createForm(args, [control]);
255 var containsElementClass = Methanal.Util.containsElementClass;262 var containsElementClass = Methanal.Util.containsElementClass;
256 self.assertIdentical(263 self.assertIdentical(form.modified, false)
257 containsElementClass(form.nodeById('modifiedIndicator'), 'hidden'),
258 true);
259 control.onChange();264 control.onChange();
260 self.assertIdentical(265 self.assertIdentical(form.modified, true)
261 containsElementClass(form.nodeById('modifiedIndicator'), 'hidden'),
262 false);
263 },266 },
264267
265268
@@ -269,7 +272,10 @@
269 function test_formLoaded(self) {272 function test_formLoaded(self) {
270 var success = false;273 var success = false;
271 var control = self.createControl({'name': 'a'});274 var control = self.createControl({'name': 'a'});
272 var form = self.createForm(false, [control], function (form) {275 var args = {
276 'viewOnly': false,
277 'submitted': true};
278 var form = self.createForm(args, [control], function (form) {
273 self.assertIdentical(279 self.assertIdentical(
274 success,280 success,
275 false);281 false);
276282
=== modified file 'methanal/js/Methanal/View.js'
--- methanal/js/Methanal/View.js 2011-03-28 13:23:01 +0000
+++ methanal/js/Methanal/View.js 2011-04-11 11:46:38 +0000
@@ -930,7 +930,7 @@
930 * @type viewOnly: C{boolean}930 * @type viewOnly: C{boolean}
931 * @ivar viewOnly: Are form actions disabled for this form?931 * @ivar viewOnly: Are form actions disabled for this form?
932 *932 *
933 * @type hideModificationIndicator: C{boolean}933 * @type hideModificationIndicator: C{Boolean}
934 * @ivar hideModificationIndicator: Hide the modification indicator for this934 * @ivar hideModificationIndicator: Hide the modification indicator for this
935 * form? Defaults to C{false}.935 * form? Defaults to C{false}.
936 *936 *
@@ -940,6 +940,14 @@
940 * @type actions: L{Methanal.View.ActionContainer}940 * @type actions: L{Methanal.View.ActionContainer}
941 * @ivar actions: Action container widget, this is only assigned once the action941 * @ivar actions: Action container widget, this is only assigned once the action
942 * container widget's C{nodeInserted} method has been called942 * container widget's C{nodeInserted} method has been called
943 *
944 * @type modified: C{Boolean}
945 * @ivar modified: Have any inputs in this LiveForm been modified since
946 * creation or the last successful submission?
947 *
948 * @type valid: C{Boolean}
949 * @ivar valid: Is this LiveForm currently in a valid state, i.e. no
950 * validation errors are present? Defaults to C{true}.
943 */951 */
944Methanal.View.FormBehaviour.subclass(Methanal.View, 'LiveForm').methods(952Methanal.View.FormBehaviour.subclass(Methanal.View, 'LiveForm').methods(
945 function __init__(self, node, args, controlNames) {953 function __init__(self, node, args, controlNames) {
@@ -949,7 +957,8 @@
949 Divmod.warn(957 Divmod.warn(
950 'Use an argument dictionary instead of the "viewOnly"' +958 'Use an argument dictionary instead of the "viewOnly"' +
951 'boolean parameter', Divmod.DeprecationWarning);959 'boolean parameter', Divmod.DeprecationWarning);
952 args = {'viewOnly': args};960 args = {
961 'viewOnly': args};
953 }962 }
954 self.viewOnly = args.viewOnly;963 self.viewOnly = args.viewOnly;
955 self.hideModificationIndicator = args.hideModificationIndicator;964 self.hideModificationIndicator = args.hideModificationIndicator;
@@ -958,6 +967,8 @@
958 }967 }
959 self.controlNames = Methanal.Util.arrayToMapping(controlNames);968 self.controlNames = Methanal.Util.arrayToMapping(controlNames);
960 self._controlNamesOrdered = controlNames;969 self._controlNamesOrdered = controlNames;
970 self.modified = false;
971 self.valid = true;
961 self.formInit();972 self.formInit();
962 },973 },
963974
@@ -1162,6 +1173,7 @@
1162 if (!self.hideModificationIndicator) {1173 if (!self.hideModificationIndicator) {
1163 self.actions.modifiedIndicator(modified);1174 self.actions.modifiedIndicator(modified);
1164 }1175 }
1176 self.modified = modified;
1165 },1177 },
11661178
11671179
@@ -1175,6 +1187,7 @@
1175 * Enable the form for submission.1187 * Enable the form for submission.
1176 */1188 */
1177 function setValid(self) {1189 function setValid(self) {
1190 self.valid = true;
1178 self.actions.enable();1191 self.actions.enable();
1179 },1192 },
11801193
@@ -1183,6 +1196,7 @@
1183 * Disable form submission.1196 * Disable form submission.
1184 */1197 */
1185 function setInvalid(self) {1198 function setInvalid(self) {
1199 self.valid = false;
1186 self.actions.disable();1200 self.actions.disable();
1187 });1201 });
11881202

Subscribers

People subscribed via source and target branches

to all changes: