Classes
-
new MfldTypes( [ fieldData ] )
Constructor for Merjent Fulcrum field types
-
-
new MfldColl()
Constructor for array of Mflds
-
Methods
-
optionIs( opt, option ) → {boolean|null}
Checks Mfld for options.
-
Description
Checks if a field option string contains a specific option. Current options supported: -rdo = radio buttons instead of checkboxes -cb = choice boxes (checkboxes) -hcb = horizontal choice boxes -syn = short yes no (first letter only) -yon = yes no only (no neutral option) -na = replace null values with 'N/A' instead of '---' -hn = hide null values (do not display field if value is null)
Parameters
Name Type Default Description optstring The option string (e.g., '-cb-hcb-rdo').
optionstring The option to check for (e.g., 'cb', 'hcb', 'rdo').
Returns
-
mkMfld( dn [, span [, opt ] ] ) → {Mfld}
Make Merjent Field
-
Description
This function creates a Mfld object which possesess most of the properties as a fulcrum field with the addition of: span, opt
Parameters
Name Type Attributes Default Description dnstring Data name of the field.
spannumber <optional> 4 Span value for the field.
optstring <optional> Option string for the field.
Returns
-
mkMflds( [ arr [, opt [, span ] ] ] ) → {MfldColl}
Make Merjent Fields
-
Description
make Mflds (array of Mfld)
Parameters
Name Type Attributes Default Description arrObject <optional> [] optstring <optional> spannumber <optional> 4 Returns
-
spliceMflds( mflds [, dn [, key ], val ] )
Deprecated
-
Description
Description placeholder
Parameters
Name Type Attributes Default Description mfldsMfldColl dnstring <optional> '' keystring <optional> '' val* Details
-
fldVal( input [, i ] ) → {string}
Field Value
-
Description
This function returns the report HTML formatted value of a field. For null values default return is '---'.
Parameters
Name Type Attributes Default Description inputstring | Mfld field to be formatted. It can be a string of a data_name or a Mfld object.
inumber <optional> only used for repeatable values. index of the value in a repeatable field.
Returns
Examples
fldVal('inspector_name') // returns the value of the inspector_name fieldfldVal('inspector_name', 0) // returns the value of the inspector_name field in the first repeatable section -
getReportVal( [ dn [, mfld [, val ] ] ] ) → {*}
sub-function of fldVal
-
Description
Produces the html string of a field value based on its type and options after checking for repeatable values.
Parameters
Name Type Attributes Default Description dnstring <optional> '' mfld* <optional> val* <optional> val only needed for repeatable values
Returns
-
customynBox( input [, val ] ) → {string}
Custiom Yes No Box
-
Description
get custom yn field as appropriate
opt = -syn | -yno | -rdo -syn only first letter of label (or 3 if neutral)
Parameters
Name Type Attributes Default Description inputstring | Mfld Mfld. Checks neutral_enabled. opt = optionIsShortYN | optionIsYonly | optionIsRadio
val* <optional> val is only used for yn boxes in a repeatable
Returns
Details
-
choiceBoxes( input [, val ] ) → {string}
Create list of checkboxes for choicevalues
-
Description
Creates an HTML string from a choice field with a list of checkboxes for choicevalues
opts = -hcb -hcb is horizontal choiceboxes, default is vertical choiceboxes.
Parameters
Name Type Attributes Default Description input* val* <optional> Returns
-
devUnhide( event ) → {void}
Developer Unhide
-
Description
Sets all fields visible if USERROLE() == 'Owner'
Parameters
Name Type Description event* Returns
Details
-
devEdit( event ) → {void}
Developer Edit
-
Description
Sets all fields editable if USERROLE() == 'Owner'
Parameters
Name Type Description event* Returns
Details
-
setAllRO( [ bol [, exc [, sec ] ] ] ) → {void}
Set All Read-only
-
Description
Sets all fields to readonly or editable or default, except those in the exclude list or not in the section if specified.
Parameters
Name Type Attributes Default Description bolboolean <optional> false Set field to readonly, null sets to default.
excArray.<string> <optional> Array of datanames to exclude
secstring <optional> '' Restrict function to only data names in this section
Returns
Details
-
isMerjentEmail() → {boolean}
-
Description
Checks if current user email ends in'merjent.com'
Returns
Details
-
disableLocationEdit( event ) → {void}
-
Description
Disable editing location
Parameters
Name Type Description event* Returns
Details
-
userInit() → {string}
User Initials
-
Description
Gets current users initials
Returns
Details
-
getReportIDvars( [ reportDate ] ) → {Object}
Get Report ID Variables
-
Description
Get information pieces used to build report id
Parameters
Name Type Attributes Default Description reportDatestring <optional> Returns
Details
-
photoLandscape( event ) → {boolean}
Require photo to be taken landscape
-
Description
Validation for photo orientation, must be called from an ONCHANGE event of a photo field.
Parameters
Name Type Description event* Returns
Details
-
photoSetLoc( event ) → {void}
Photo Set Location
-
Description
Sets record location to the location of the first photo taken
Parameters
Name Type Description event* Returns
Details
-
clearRLAutoPops( event ) → {void}
Clear Record-Link Auto-populates
-
Description
If the value of the record-link field is null, on change, this data event will clear all of the auto-populate fields.
Parameters
Name Type Description event* Returns
Examples
ON('change', 'project_name', clearRLAutoPops)Details
-
popLatLon( [ dn ] ) → {string}
Populate Latitude Longitude
-
Description
For use in data event. Sets value of {data_name} to current lat/lon as a string "lat,lon". Alerts if no GPS info.
Parameters
Name Type Attributes Default Description dnstring <optional> output field data name to write to
Returns
Details
-
photoCheck4Caps( dn ) → {boolean}
Photo Check for Captions
-
Description
Checks photofield for photos without a caption. Returns an Alert.
Parameters
Name Type Description dnstring Returns
Details
-
photoCheckCapLen( dn, max ) → {void}
Photo Check Caption Length
-
Description
Description placeholder
Parameters
Name Type Description dnstring maxnumber Returns
Details
-
makeDnsRow( dns [, exc ] ) → {Object}
Make data_names Row
-
Description
Creates an object from a list of data names. Excludes Labels, Sections and HyperlinkFields.
Parameters
Name Type Attributes Default Description dns* excArray.<string> <optional> [] Returns
Details
-
makeRepRows( repeatableDn [, exc ] ) → {Array.<Object>}
Make Repeatable Rows
-
Description
Converts a repeatable to an Array of Objects. Input repeatable data name.
Parameters
Name Type Attributes Default Description repeatableDnstring excArray.<string> <optional> [] Returns
Details
-
rows2Summary( rows [, exc ] ) → {Array.<string>}
Rows to Summary
-
Description
Converts an array of objects to an array of summary strings, excluding specified keys. Each summary string lists key-value pairs separated by commas.
Parameters
Name Type Attributes Default Description rowsArray.<Object> Array of objects to summarize.
excArray.<string> <optional> [] Array of keys to exclude from summary.
Returns
Details
-
fv2DnRows( rows, dict ) → {Array.<Object>}
Form Values to Data Names Rows
-
Description
Converts an array of Fulcrum rows to an array of objects with data names as keys. Uses a dictionary to map form_value keys to data names.
Parameters
Name Type Description rowsArray.<Object> Array of Fulcrum record objects.
dictObject Dictionary mapping form_value keys to data names.
Returns
Details
-
loadRecords( arr, formID, callback ) → {void}
Load Records
-
Description
Wrapper function for LOADRECORDS() expression.
Parameters
Name Type Description arrArray.<string> formIDstring callbackfunction function to process records and store them to a variable or field. Callback must have one parameter for records. See example.
Returns
Examples
processRecordsCallback(records){ loadedRecords = convertFV2DN(records,loadedFvs) var out = [] for(const record of loadedRecords){ var add = record.scientific_name + ' - ' + record.common_name out.push(add) } SETVALUE('result',out.join('\n')) } M.loadRecords(recIDs,appID,processRecordsCallback)Details
-
getRepDn( dn ) → {string}
Get Repeatable Parent
-
Description
get parent data_name for a field. Returns only the next parent that is a repeatable.
Parameters
Name Type Description dnstring Returns
Examples
getRepDn('inspector_name') // returns 'background'Details
-
digElement( el, collector ) → {void}
Dig Element
-
Description
Recursively collects all data_name:form_value pairs from element. Adds element to collector array. Primarily used as a sub-function within makeFvDict.
Parameters
Name Type Description elObject The parent element to start from.
collectorobject The object to collect elements into.
Returns
Details
-
makeFvDict( form ) → {Object}
Make Form Values Dictionary
-
Description
Input a fulcrum form schema Object and returns a dictionary object of {data_name:form_value}.
Parameters
Name Type Description formObject Fulcrum form schema object.
Returns
Details
-
mkLocalFvDict( el ) → {Object}
Make Local Form Values Dictionary
-
Description
Creates a local dictionary of {form_value:data_name} for fields within the specified element or the entire form if no element is provided.
Parameters
Name Type Default Description elObject | null Fulcrum form element object. If null, uses the entire form.
Returns
Details
-
repeatable2jrows( repDn [, exc ] ) → {Array.<Object>}
Repeatable to JSON Rows
-
Description
Converts a repeatable field's value into an array of objects with data names as keys.
Parameters
Name Type Attributes Default Description repDnstring Data name of the repeatable field.
excArray.<string> <optional> [] Array of data names to exclude.
Returns
Details
-
loadForm( formID, callback ) → {void}
-
Description
Description placeholder
Parameters
Name Type Description formIDstring fulcrum form id
callbackfunction function to process form schema
Returns
Examples
processFormCallback(form){ loadedFvs = M.flipKVpair(this.makeFvDict(form)) } M.loadForm(formID,processFormCallback)Details
-
eachSecDn( secDn, callback ) → {void}
Each Section Data Name
-
Description
Performs callback function on each data name in a section.
Parameters
Name Type Description secDnstring Section data name.
callbackfunction Function to perform for each data name.
Returns
Details
-
clear( dn ) → {void}
-
Description
Clears value in fulcrum field.
Parameters
Name Type Description dnstring Data name to clear.
Returns
Details
-
getRepeatableValues( repVals, dnFv ) → {Object}
-
Description
Description placeholder
Parameters
Name Type Description repVals* this is from VALUE(repeatable data name)
dnFvstring Returns
Details
-
getNestedRepeatable( parentDn, childDn, dnFv ) → {Object}
-
Description
Description placeholder
Parameters
Name Type Description parentDnstring childDnstring dnFvstring Returns
Details
-
timedProcessingMsg( time ) → {void}
Timed Processing Message
-
Description
block input into form with an alert message for a set time in milliseconds.
Parameters
Name Type Description timenumber milliseconds for settimeout
Returns
Details
-
valProcessingMsg( dn, time ) → {void}
Value Processing Message
-
Description
block input into form with an alert message until a value is present in the specified data name or until a settimeout.
Parameters
Name Type Description dnstring timenumber milliseconds for settimeout
Returns
Details
-
mkPhotoDirHandler( photoFldDn [, photoDirDn [, photoCardDn [, secondary ] ] ] ) → {PhotoDirHandler}
-
Description
Factory method for PhotoDirHandler (backward compatibility)
Parameters
Name Type Attributes Default Description photoFldDnstring Photo field data name
photoDirDnstring <optional> "" Direction field data name (degrees)
photoCardDnstring <optional> "" Cardinal direction field data name
secondaryboolean <optional> false Use 16-point compass if true, 8-point if false
Returns
Examples
const photoDirObj = M.mkPhotoDirHandler('photo_field', 'direction_deg', 'direction_cardinal') function changeDir(event){ photoDirObj.popOther(event) } ON('change', photoDirObj.dnDir, changeDir) ON('change', photoDirObj.dnCard, changeDir) ON('add-photo', photoDirObj.photoDn, photoDirObj.extractPhotoDir)Details
-
mkMLoadRecords( formID, enterLoadedData [, fulcrumHelpers ] ) → {MLoadRecords}
-
Description
Factory method for MLoadRecords (backward compatibility)
Parameters
Name Type Attributes Default Description formIDstring Fulcrum form ID
enterLoadedDatafunction Callback function to process loaded records
fulcrumHelpersFulcrumHelpers <optional> this Optional helper instance (defaults to current FulcrumHelpers instance)
Returns
Examples
const appID = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' function processRecords() { const loadedRecords = loader.appRecords const titleList = loadedRecords.map(x => x.scientific_name + ' - ' + x.common_name) SETVALUE('result', titleList.join('\n')) } const loader = M.mkMLoadRecords(appID, processRecords) ON('load-record', loader.getAppFvs) ON('change', 'species_link', loader.loadRecords)Details
Type Definitions
-
MfldOpt
Options for Mfld instances
-
Description
Options for Mfld to specify drawing of values in Merjent pdf reports. Properties are strings starting with -. ie: '-hcb'.
Entire opt property of Mfld is a concatenated string. ie: '-cb-hcb-rdo'
Properties
Name Type Description nastring replaces null values with 'N/A' instead of '---'
synstring short yes no: Positive and negative labels replaced with first character. Neutral replaced with first 3 characters. (ie: Y | N | N/A)
cbstring Display choice values as a list of checkboxes. Checkboxes will be displayed vertically.
hcbstring Modifier for -cb. Checkboxes will be displayed horizontally.
yonstring yes no only: Neutral label will not be displayed.
rdostring Modifier for -cb. Checkboxes will be replaced with radio buttons.
hnstring hide null values: Do not display field if value is null.