/***********************************************************************
Namespace -- this should be the file name, but camelcased
***********************************************************************/
Aptify.framework.utility.ensureNameSpaceExists("Aptify.applications.topLevelEntityName.UI");
/***********************************************************************
Layout Control
***********************************************************************/
Aptify.applications.topLevelEntityName.UI.entityNameLayout = function () {
///
/// A layout control instance for the Entity Name Form Template.
///
///
try {
// Inherit from the generic Form Template Layout
Aptify.framework.inheritance.inherit(this, new Aptify.framework.formTemplates.UI.layout());
// Override Form Template Layout methods
// (Delete any you don't override, to avoid confusion)
// (This does not represent a full catalog of overridable methods)
Aptify.framework.inheritance.overrides(this, "beforeLoad", _beforeLoad);
Aptify.framework.inheritance.overrides(this, "afterLoad", _afterLoad);
Aptify.framework.inheritance.overrides(this, "afterSubTemplateLoaded", _afterSubTemplateLoaded);
Aptify.framework.inheritance.overrides(this, "refresh", _refresh);
// Define instance-wide variables, including for Form Template Parts
var _ftl = this;
var _ge = this.getGEObject();
var _domElement;
var _ftpPartName;
var _ftpButtonPartName;
var _ctrlPartName;
// Define overriding functions
// (Delete any you don't override, to avoid confusion)
function _beforeLoad(eventData) {
///
/// Triggered before the load process begins.
///
/// {
/// formTemplateLayout (reference to the FTL being loaded),
/// entity (database entity name being loaded),
/// recordId (database record ID being loaded),
/// domElement (root DOM element id for the FTL being loaded),
/// parentDomElement (if the Form Template is within another Form Template, this is the DOM element id of the parent Form Template's FTL),
/// preventDefault (set to true if default functionality should be canceled; defaults to false),
/// cancel (set to true if the loading process should be canceled; defaults to false)
/// }
///
try {
// Update instance-wide variables from the incoming eventData
_ftl = eventData.formTemplateLayout;
_domElement = eventData.domElement;
// Call parent's beforeLoad()
_ftl.base().beforeLoad();
// Do any beforeLoad work
} catch (ex) {
Aptify.framework.exceptionManager.publish(ex);
}
}
function _afterLoad(eventData) {
///
/// Triggered after the load process is complete and the form template is fully loaded.
///
/// {
/// formTemplateLayout (reference to the loaded FTL),
/// geObject (Generic Entity object for the Form Template),
/// domElement (root DOM element id for the loaded FTL),
/// parentDomElement (if the Form Templates is within another Form Template, this is the DOM element id of the parent Form Template's FTL)
/// }
///
try {
// Update instance-wide variables from the incoming eventData
_ftl = eventData.formTemplateLayout;
_ge = eventData.geObject;
_domElement = eventData.domElement;
// Call parent's afterLoad()
_ftl.base().afterLoad();
// Find Form Template Parts
_ftpPartName = _ftl.findPartsByLayoutKey("PartLayoutKey");
_ftpButtonPartName = _ftl.findPartsByLayoutKey("ButtonPartLayoutKey");
// If we need the actual Form Control corresponding to the part,
// we can get that too.
_ctrlPartName = Aptify.framework.dataControls.UI.getControlFromElement(_ftpPartName);
// Bind click events, etc.
Aptify.framework.utility.UI.bindClick(_ftpButtonPartName, _onButtonPartNameClick);
// Register for notifications
_ge.registerNotification({
event: Aptify.framework.configuration.eventDefinitions.GEFieldValueChanged,
callBack: _geFieldValueChanged
});
// Most actual actions should happen on load and also on refresh,
// so generally we put them in refresh() and call that at the end of afterLoad()
_ftl.refresh();
} catch (ex) {
Aptify.framework.exceptionManager.publish(ex);
}
}
function _afterSubTemplateLoaded(eventData) {
///
/// Triggered after a tab is loaded dynamically.
///
/// {
/// formTemplateLayout (reference to loaded FTL),
/// domElement (root DOM element id for the loaded FTL),
/// formTemplatePartId (ID of current tab's Form Template Part),
/// formTemplatePartLayoutKey (LayoutKey of current tab's Form Template Part)
/// }
///
try {
// Don't update instance-wide variables from the incoming eventData
// It's possible that the subtemplate has its own form template data,
// and we don't want to overwrite unless we're sure we've got the right stuff.
// Call parent's afterSubTemplateLoaded()
_ftl.base().afterSubTemplateLoaded();
// Do any afterSubTemplateLoaded() work
} catch (ex) {
Aptify.framework.exceptionManager.publish(ex);
}
}
function _refresh() {
///
/// Triggered when the Form Template Layout is refreshed.
///
try {
// Call parent's refresh()
_ftl.base().refresh();
// Do any refresh work
} catch (ex) {
Aptify.framework.exceptionManager.publish(ex);
}
}
// Value change dispatcher function
function _geFieldValueChanged(paramData, eventData) {
///
/// Triggered when a GE field value changes
///
/// {
/// GE (the GE object for which the value changed),
/// param (???)
/// }
/// {
/// field (name of the field that changed),
/// value (new value of the field)
/// }
try {
// Switch on the lowercased field name and call any relevant "on value changed" functions
switch (eventData.field.toLowerCase()) {
default:
break;
}
} catch (ex) {
Aptify.framework.exceptionManager.publish(ex);
}
}
} catch (ex2) {
Aptify.framework.exceptionManager.publish(ex2);
}
// Finally, return the constructed layout control instance
return this;
}