Merge lp:~methanal-developers/methanal/1250847-simpleform-validation into lp:methanal

Proposed by Jonathan Jacobs
Status: Merged
Approved by: Tristan Seligmann
Approved revision: 201
Merged at revision: 199
Proposed branch: lp:~methanal-developers/methanal/1250847-simpleform-validation
Merge into: lp:methanal
Diff against target: 81 lines (+24/-3)
2 files modified
methanal/js/Methanal/View.js (+11/-3)
methanal/js/Methanal/Widgets.js (+13/-0)
To merge this branch: bzr merge lp:~methanal-developers/methanal/1250847-simpleform-validation
Reviewer Review Type Date Requested Status
Tristan Seligmann Approve
Review via email: mp+195056@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Tristan Seligmann (mithrandi) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'methanal/js/Methanal/View.js'
--- methanal/js/Methanal/View.js 2012-07-30 15:36:53 +0000
+++ methanal/js/Methanal/View.js 2013-11-13 13:18:25 +0000
@@ -1437,14 +1437,18 @@
1437Methanal.View.LiveForm.subclass(Methanal.View, 'SimpleForm').methods(1437Methanal.View.LiveForm.subclass(Methanal.View, 'SimpleForm').methods(
1438 function __init__(self, node, controlNames) {1438 function __init__(self, node, controlNames) {
1439 Methanal.View.SimpleForm.upcall(1439 Methanal.View.SimpleForm.upcall(
1440 self, '__init__', node, {'viewOnly': true}, controlNames);1440 self, '__init__', node, {}, controlNames);
1441 self.hideModificationIndicator = true;1441 self.hideModificationIndicator = true;
1442 self.valid = true;
1442 },1443 },
14431444
14441445
1445 function nodeInserted(self) {1446 function nodeInserted(self) {
1446 // Explicitly override LiveForm's "nodeInserted" method, most of the1447 // Explicitly override LiveForm's "nodeInserted" method, most of the
1447 // nodes it attempts to find will not exist in a simple form.1448 // nodes it attempts to find will not exist in a simple form.
1449 if (self.viewOnly === undefined && self.widgetParent.getForm) {
1450 self.viewOnly = self.widgetParent.getForm().viewOnly;
1451 }
1448 },1452 },
14491453
14501454
@@ -1454,11 +1458,13 @@
14541458
14551459
1456 function setValid(self) {1460 function setValid(self) {
1461 self.valid = true;
1457 self.widgetParent.clearError();1462 self.widgetParent.clearError();
1458 },1463 },
14591464
14601465
1461 function setInvalid(self, invalidControls) {1466 function setInvalid(self, invalidControls) {
1467 self.valid = false;
1462 self.widgetParent.setError('');1468 self.widgetParent.setError('');
1463 });1469 });
14641470
@@ -1668,8 +1674,10 @@
1668 Methanal.Util.addElementClass(self.node, 'methanal-control-error');1674 Methanal.Util.addElementClass(self.node, 'methanal-control-error');
1669 self.error = error;1675 self.error = error;
1670 self.widgetParent.checkForErrors();1676 self.widgetParent.checkForErrors();
1671 self._errorTooltip.setText(self.error);1677 if (self.error && self.error.length) {
1672 self._errorTooltip.show();1678 self._errorTooltip.setText(self.error);
1679 self._errorTooltip.show();
1680 }
1673 },1681 },
16741682
16751683
16761684
=== modified file 'methanal/js/Methanal/Widgets.js'
--- methanal/js/Methanal/Widgets.js 2012-11-21 06:18:32 +0000
+++ methanal/js/Methanal/Widgets.js 2013-11-13 13:18:25 +0000
@@ -1362,6 +1362,14 @@
1362 function resultChanged(self, control) {1362 function resultChanged(self, control) {
1363 },1363 },
13641364
1365 function setInvalid(self, invalidControls) {
1366 Methanal.Widgets.LookupForm.upcall(self, 'setInvalid', invalidControls);
1367 if (invalidControls.length === 1 &&
1368 invalidControls[0].name === '__result__') {
1369 self.valid = true;
1370 }
1371 },
1372
13651373
1366 function valueChanged(self, control) {1374 function valueChanged(self, control) {
1367 Methanal.Widgets.LookupForm.upcall(1375 Methanal.Widgets.LookupForm.upcall(
@@ -1375,6 +1383,11 @@
1375 // Trigger Lookup.onChange so the parent form refreshes validators.1383 // Trigger Lookup.onChange so the parent form refreshes validators.
1376 self.widgetParent.onChange(control.node, self._initialisedOnce);1384 self.widgetParent.onChange(control.node, self._initialisedOnce);
13771385
1386 if (!self.valid) {
1387 self.setResults([]);
1388 return;
1389 }
1390
1378 // Don't trigger when the result input is changed or when there are1391 // Don't trigger when the result input is changed or when there are
1379 // validation errors.1392 // validation errors.
1380 if (control.name === '__result__') {1393 if (control.name === '__result__') {

Subscribers

People subscribed via source and target branches

to all changes: