Module

helpers

Members

# static constant formatPhoneNumber

Format a phone number

View Source helpers/helpers.js, line 426

Example
formatPhoneNumber('1234567890') => '(123) 456-7890'

# static constant getSectionChoices

Returns possible choices for a given section and model

View Source helpers/helpers.js, line 232

Methods

# static arrayToDisplay(value, prop, delim) → {array}

Convert an array of objects into a string using prop
Parameters:
Name Type Description
value Array Array to process
prop string Display property (also used for sorting)
delim string String to place between each value

View Source helpers/helpers.js, line 563

array

# static arrayToUrls(value, slug, sameTab, displayProp, idProp) → {object}

Convert an object or array of objects to urls. Intended for use with DetailList/DetailContent component
Parameters:
Name Type Description
value Object | Array thing or things to turn into urls
slug string url slug
sameTab boolean open in same tab
displayProp string display property for sorthing and link text
idProp string id to use with slug to generate url

View Source helpers/helpers.js, line 576

object

# static capitalizeFirstLetter(string) → {string}

Method to capitalize the first letter of a string
Parameters:
Name Type Description
string string

View Source helpers/helpers.js, line 520

The capitalized string
string
Examples
capitalizeFirstLetter('hello') => 'Hello'
capitalizeFirstLetter('Hello') => 'Hello'

# static caseless(valueA, valueB) → {number}

Cases, we don't need no stinking cases.
Parameters:
Name Type Description
valueA *
valueB *

View Source helpers/helpers.js, line 119

- 0 if equal, -1 if valueA < valueB, 1 if valueA > valueB
number
Examples
const result = caseless('a', 'A');
// result === 0
const result = caseless('a', 'b');
// result === -1
const result = caseless('b', 'a');
// result === 1
const result = caseless('a', '');
// result === -1

# static convertToLinkFormat(linkFormat, dataNode) → {string}

Replaces placeholders in a link format string with values from a data node object.
Parameters:
Name Type Description
linkFormat string The link format string with placeholders wrapped in curly braces.
dataNode Object The data node object containing values to replace the placeholders.

View Source helpers/helpers.js, line 613

The link format string with placeholders replaced with values from the data node object.
string

# static createZoomOption(label, value, extent) → {object}

Create a zoom option object
Parameters:
Name Type Description
label *
value *
extent *

View Source helpers/helpers.js, line 197

- zoom option object
object

# static currencyFormatter(inc) → {string}

Return a currency string from either an ag grid cell object or string
Parameters:
Name Type Description
inc object | string ag grid cell params

View Source helpers/helpers.js, line 530

a currency string
string
Example
currencyFormatter(1234.56) => '$1,234.56'

# static dateFormatter(inc) → {string}

Return a date string from either an ag grid cell object or string
Parameters:
Name Type Description
inc string | object The date string or ag grid cell object

View Source helpers/helpers.js, line 448

The date as a string
string

# static dateToString(date) → {string}

Convert a date to a string with zero padding
Parameters:
Name Type Description
date Date

View Source helpers/helpers.js, line 468

The date as a string
string

# static floatCompare(valueA, valueB) → {number}

Used to correctly handle sorting floats
Parameters:
Name Type Description
valueA
valueB

View Source helpers/helpers.js, line 148

- 0 if equal, -1 if valueA < valueB, 1 if valueA > valueB
number
Examples
const result = floatCompare('1.1', '1.2');
// result === -1
const result = floatCompare('1.2', '1.1');
// result === 1
const result = floatCompare('1.1', '1.1');
// result === 0

# static floatFormatter(inc, decimalPlaces) → {string}

Return a currency string from either an ag grid cell object or string
Parameters:
Name Type Description
inc object | string ag grid cell params
decimalPlaces number number of decimal places to round to

View Source helpers/helpers.js, line 546

string

# static headerColor(theme) → {string}

Get the color for the header text
Parameters:
Name Type Description
theme object

View Source helpers/helpers.js, line 481

The color for the header text
string

# static isObject(objValue) → {boolean}

Check if a value is an object
Parameters:
Name Type Description
objValue any

View Source helpers/helpers.js, line 56

- true if object, false if not
boolean
Examples
const result = isObject({ a: 1 });
// result === true
const result = isObject(1);
// result === false
const result = isObject(null);
// result === false
const result = isObject(undefined);
// result === false
const result = isObject('a');
// result === false
const result = isObject([1, 2, 3]);
// result === false
const result = isObject(new Date());
// result === false
const result = isObject(new Map());
// result === false

# static mergeDeep(target, source) → {object}

Deeply clone an object.
Parameters:
Name Type Description
target object object to merge things into
source object data source

View Source helpers/helpers.js, line 12

- cloned object
object
Examples
const result = mergeDeep({ a: 1 }, { b: 2 });
// result === { a: 1, b: 2 }
const result = mergeDeep({ a: 1 }, { a: 2 });
// result === { a: 2 }

# static modifyColorOpacity(color, opacity) → {string}

Useful when you want/need to share an RGBA color in more than one place with different opacity levels. If you want to show a color on a map with opacity 0.6 but want the legend value to use the same color but with opacity 1.0.
Parameters:
Name Type Description
color string an rgba color
opacity number the opacity to convert to

View Source helpers/helpers.js, line 502

An rgba color with it's opacity modified
string

# static objectReducer(obj, path, separator) → {any}

Given an object and a path, return the value at that path. If the path is not found, return undefined.
Parameters:
Name Type Description
obj object object to search
path string path to value
separator string separator for path (default: '.')

View Source helpers/helpers.js, line 97

value at path
any
Example
const obj = { a: { b: { c: 1 } } };
const result = objectReducer(obj, 'a.b.c');
// result === 1

# static objectsToString(items, key, separator) → {string}

Convert array of objects to a string for a given key and separator
Parameters:
Name Type Description
items
key string
separator string

View Source helpers/helpers.js, line 600

string

# static processGenericLayout(layout) → {object}

Process a layout object
Parameters:
Name Type Description
layout object

View Source helpers/helpers.js, line 287

- The processed layout object
object

# static processLayout(layout) → {object}

Simple layout process method to convert the layout object into a format that the layout builder can use. If you are using GenericForm you should be using the useFormLayout and parseFormLayout methods instead.
Parameters:
Name Type Description
layout object The layout object to process

View Source helpers/helpers.js, line 257

- The processed layout object
object

# static sortOn(items, prop) → {Array}

Sorts array of objects by a given prop and returns a copy
Parameters:
Name Type Description
items
prop

View Source helpers/helpers.js, line 174

- sorted array
Array
Example
const result = sortOn([{ label: 'b' }, { label: 'a' }], 'label');
// result === [{ label: 'a' }, { label: 'b' }]

# static specialColor(theme) → {string}

Get the color for the special text
Parameters:
Name Type Description
theme object

View Source helpers/helpers.js, line 490

The color for the special text
string

# static zeroPad(num, size) → {string}

Number with zero padding
Parameters:
Name Type Description
num number Number to pad
size number amount of padding

View Source helpers/helpers.js, line 416

The padded number
string

# static zoomableOption(item, labelProp, valueProp) → {object}

Create a zoom option object from a zoomable item
Parameters:
Name Type Description
item object
fields object fields object
fields.extent object extent object
labelProp string
valueProp string

View Source helpers/helpers.js, line 210

- zoom option object
object

# static zoomablesOptions(zoomables, labelProp, valueProp) → {Array.<Object>}

Get a list of zoom options from a list of zoomable items
Parameters:
Name Type Description
zoomables Array.<Object> list of zoomable items
labelProp string property to use for label
valueProp string property to use for value

View Source helpers/helpers.js, line 221

Array.<Object>

# inner isEmpty(value) → {boolean}

Helper method to check if a value is null, undefined, or ''
Parameters:
Name Type Description
value string | number

View Source helpers/helpers.js, line 62

- true if empty, false if not
boolean
Example
isEmpty('') // true
isEmpty(null) // true
isEmpty(undefined) // true
isEmpty(0) // false