Merge lp:~methanal-developers/methanal/1342097-fix-groupinput into lp:methanal

Proposed by Tristan Seligmann
Status: Merged
Merged at revision: 205
Proposed branch: lp:~methanal-developers/methanal/1342097-fix-groupinput
Merge into: lp:methanal
Diff against target: 104 lines (+51/-2)
3 files modified
methanal/js/Methanal/View.js (+32/-0)
methanal/js/Methanal/Widgets.js (+18/-1)
methanal/model.py (+1/-1)
To merge this branch: bzr merge lp:~methanal-developers/methanal/1342097-fix-groupinput
Reviewer Review Type Date Requested Status
Jonathan Jacobs Approve
Review via email: mp+226814@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jonathan Jacobs (jjacobs) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'methanal/js/Methanal/View.js'
2--- methanal/js/Methanal/View.js 2013-11-13 13:14:11 +0000
3+++ methanal/js/Methanal/View.js 2014-07-15 12:42:47 +0000
4@@ -1540,6 +1540,16 @@
5
6 function setInvalid(self) {
7 self.valid = false;
8+ },
9+
10+
11+ /**
12+ * Internal method for determining whether to set C{fullyLoaded} and
13+ * finalise form loading. The FormBehaviour implementation is overridden
14+ * because GroupInput does not have an action container.
15+ */
16+ function _isFullyLoaded(self) {
17+ return self.controlsLoaded && !self.fullyLoaded;
18 });
19
20
21@@ -1590,6 +1600,28 @@
22 self.inputNode = self.getInputNode();
23 self._errorTooltip = Methanal.Util.Tooltip(
24 self.node, null, 'left', 'error-tooltip');
25+ self._checkLoaded();
26+ },
27+
28+
29+ /**
30+ * Check if the parent form should be notified that this input is loaded.
31+ *
32+ * Subclasses can override this if they have additional requirements that
33+ * must be satisfied before declaring themselves as loaded.
34+ */
35+ function _checkLoaded(self) {
36+ self._notifyLoaded();
37+ },
38+
39+
40+ /**
41+ * Notify this input's parent form that this input is loaded.
42+ *
43+ * This method should not be called before C{self.getValue()} is able to
44+ * succeed.
45+ */
46+ function _notifyLoaded(self) {
47 self.reset();
48
49 function _baseValidator(value) {
50
51=== modified file 'methanal/js/Methanal/Widgets.js'
52--- methanal/js/Methanal/Widgets.js 2014-03-14 13:48:19 +0000
53+++ methanal/js/Methanal/Widgets.js 2014-07-15 12:42:47 +0000
54@@ -1133,12 +1133,17 @@
55 Methanal.Widgets.Lookup.upcall(self, '__init__', node, args);
56 self._lookupForm = null;
57 self._waitForForm = Divmod.Defer.Deferred();
58+ self._waitForLookupForm = Divmod.Defer.Deferred();
59 },
60
61
62 function formLoaded(self, form) {
63 self._lookupForm = form;
64- self.getForm()._waitForForm.addCallback(function () {
65+ self._waitForLookupForm.callback(null);
66+ self._waitForLookupForm = Divmod.Defer.Deferred();
67+
68+ var parentForm = self.getForm();
69+ parentForm._waitForForm.addCallback(function () {
70 self._waitForForm.callback(null);
71 self._waitForForm = Divmod.Defer.succeed(null);
72 });
73@@ -1146,6 +1151,18 @@
74
75
76 /**
77+ * Check if the parent form should be notified that this input is loaded.
78+ *
79+ * This input is not loaded until the lookup form has loaded.
80+ */
81+ function _checkLoaded(self) {
82+ self._waitForLookupForm.addCallback(function () {
83+ self._notifyLoaded();
84+ });
85+ },
86+
87+
88+ /**
89 * Handler for the "onchange" DOM event.
90 *
91 * Inform the containing form that our value has changed.
92
93=== modified file 'methanal/model.py'
94--- methanal/model.py 2011-04-29 08:51:24 +0000
95+++ methanal/model.py 2014-07-15 12:42:47 +0000
96@@ -303,7 +303,7 @@
97 if isinstance(attr, attributes.reference):
98 if attr.reftype is None:
99 raise ValueError('%r has no reference type' % (attr,))
100- model = ItemModel(itemClass=attr.reftype, store=store)
101+ model = ItemModel(item=value, itemClass=attr.reftype, store=store)
102 return ReferenceParameter(name=name,
103 value=value,
104 doc=doc,

Subscribers

People subscribed via source and target branches

to all changes: