-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Minor
-
Affects Version/s: PE Milestone 10 (It's Getting Tense)
-
None
Currently, fields.inc files that dynamically show and hide fields follow a pattern of
function updateGadgets(isPageLoad) {
showFields([...], isPageLoad)
}
function jsLocalOnLoad() {
updateGadgets(true);
}
This is noisy, and requires isPageLoad to be repeatedly passed, even though the context is predictable.
A better approach would be for comanage.js::jsOnLoadCallHooks to set a global flag indicating we are in the isPageLoad context, then for showFields and hideFields to examine that flag as needed. Once jsLocalOnLoad returns, the global flag would be set to false. This would avoid the need to pass isPageLoad in every call in every instance of fields.inc.
Relatedly, perhaps jsOnLoadCallHooks could be smart enough to see if the function updateGadgets is defined, and if so call it. This would eliminate the need for most instances of jsLocalOnLoad (though it should remain supported for more complex use cases).