Skip to content
This repository was archived by the owner on Aug 1, 2024. It is now read-only.

Commit 887aa46

Browse files
author
Steven C. Buttgereit
committed
Fix purchaseOrder "releasePr" mode initialization
The initialization sequence is foobar when the purchase order form is loaded via releasing a purchase request. In that case, we have to treat the form as re-entrant since the initial load of the form doesn't have the correct mode or record ID until after initialization in many instances (particularly if there's an existing purchase order). In the cases where the ID comes later, we don't have a full initialization sequence and so we have to capture the scenario and force initialization of the scWidget object.
1 parent 6f9e552 commit 887aa46

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

client/scripts/forms/xtuple/purchaseOrder.js

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ try {
3636
MuseUtils.MOD_EXCEPTION,
3737
MuseUtils.MOD_JSPOLYFILL,
3838
MuseUtils.MOD_JS,
39-
MuseUtils.MOD_CONFIG
39+
MuseUtils.MOD_CONFIG,
40+
MuseUtils.MOD_QT
4041
]);
4142

4243
if (typeof MuseSuperChar.Loader === "undefined") {
@@ -81,7 +82,7 @@ try {
8182

8283
// Mutable state
8384
var scWidget = null;
84-
85+
var isFormAlreadyStarted = false;
8586
//--------------------------------------------------------------------
8687
// Get Object References From Screen Definitions
8788
//--------------------------------------------------------------------
@@ -150,12 +151,37 @@ try {
150151
//----------------------------------------------------------------
151152
// Connects/Disconnects
152153
//----------------------------------------------------------------
153-
mywindow["saved(int)"].connect(mySave);
154+
if (!isFormAlreadyStarted) {
155+
mywindow["saved(int)"].connect(mySave);
156+
}
154157
};
155158

156159
//--------------------------------------------------------------------
157160
// Public Interface -- Slots
158161
//--------------------------------------------------------------------
162+
pPublicApi.sModeUpdate = function(pNewModeEnum) {
163+
var resolvedMode = MuseUtils.getModeFromXtpEnumId(pNewModeEnum);
164+
var resolvedId = mywindow.id();
165+
166+
if (
167+
["new", "edit", "view"].includes(resolvedMode) &&
168+
MuseUtils.isValidId(resolvedId)
169+
) {
170+
initSuperChar(resolvedMode, resolvedId);
171+
}
172+
};
173+
174+
pPublicApi.sNewId = function(pNewId) {
175+
var resolvedMode = MuseUtils.getModeFromXtpEnumId(mywindow.mode());
176+
var resolvedId = pNewId;
177+
178+
if (
179+
["new", "edit", "view"].includes(resolvedMode) &&
180+
MuseUtils.isValidId(resolvedId)
181+
) {
182+
initSuperChar(resolvedMode, resolvedId);
183+
}
184+
};
159185

160186
//--------------------------------------------------------------------
161187
// Public Interface -- Functions
@@ -170,9 +196,20 @@ try {
170196

171197
if (["new", "edit", "view"].includes(myMode) && scWidget !== null) {
172198
initSuperChar(myMode, mywindow.id());
199+
} else if (myMode == "releasePr") {
200+
initSuperChar(
201+
MuseUtils.getModeFromXtpEnumId(mywindow.mode()),
202+
mywindow.id() == -1 ? null : mywindow.id()
203+
);
173204
} else {
174205
return;
175206
}
207+
208+
if (!isFormAlreadyStarted) {
209+
mywindow["newMode(int)"].connect(pPublicApi.sModeUpdate);
210+
mywindow["newId(int)"].connect(pPublicApi.sNewId);
211+
isFormAlreadyStarted = true;
212+
}
176213
};
177214

178215
//--------------------------------------------------------------------

0 commit comments

Comments
 (0)