src/lib/extensions/util.service.ts
constructor()
|
| Public adjustPrecision | ||||||||||||||||||||
adjustPrecision(value: number, decimals: number, factor: number)
|
||||||||||||||||||||
|
Method to avoid displaying precision issues of javascript floating-point arithmetic. This method was mostly designed for percentage values, when we multiply by 100 a number between 0 and 1, which can trigger the precision issues, but can be used for other cases.
Parameters :
Returns :
any
|
| Public applyCeilOrFloor | ||||||||
applyCeilOrFloor(value: Decimal)
|
||||||||
|
Apply ceil if the value is greater than zero, otherwise, apply the floor.
Parameters :
Returns :
any
The rounded value |
| Public arrayContainsAll | ||||||||||||||||
arrayContainsAll(array: any[], subset: any[], propertiesToEvaluate?: string[])
|
||||||||||||||||
|
Check if an array contains all elements from a list
Parameters :
Returns :
boolean
true if array contains all |
| Public arrayMerge | ||||||||||||||||
arrayMerge(source1: T[], source2: T[], property: string)
|
||||||||||||||||
Type parameters :
|
||||||||||||||||
|
This methods merges two object arrays of the same type, using a property as key. Example: let target = [{name: a, title: "title a", subTitle: "subTitle a"}, {name: b, title: "title b", subTitle: "subTitle b"}] let source = [{name: a, title: "new title a"}, {name: c, title: "test c", subTitle: "subTitle c"}] let result = arrayMerge(target, source, "name") Result will be: [{name: a, title: "new title a", subTitle: "subTitle a"}, {name: b, title: "title b", subTitle: "subTitle b"}, {name: c, title: "test c", subTitle: "subTitle c"}]
Parameters :
Returns :
T[]
|
| Public base64stringToByteArray | ||||||||
base64stringToByteArray(base64String: string)
|
||||||||
|
Converts a base64 string to byte array
Parameters :
Returns :
any[]
|
| Public bet | ||||||||
bet(probability: number)
|
||||||||
|
Place a bet and receive a pseudo random result (true or false) (win or loose) with a certain a probability of wining
Parameters :
Returns :
boolean
boolean (true=win or false=loose) |
| Public buildUrl | ||||||
buildUrl(snapshot: ActivatedRouteSnapshot)
|
||||||
|
Builds an url from an activated route snapshot.
Parameters :
Returns :
string
|
| Public buildUrlByConfig |
buildUrlByConfig(config: any, resource?: string)
|
|
Returns :
string
|
| Public byteArrayToBase64String | ||||||||
byteArrayToBase64String(bytes: Uint8Array)
|
||||||||
|
Converts an array of Bytes into a Base64 string
Parameters :
Returns :
string
Base64 string |
| Public calculateColorContrast | ||||||||||||
calculateColorContrast(backgroundColor: string, foregroundColor: string)
|
||||||||||||
|
Calculate color contrast between a background color and a foreground color https://stackoverflow.com/questions/9733288/how-to-programmatically-calculate-the-contrast-ratio-between-two-colors
Parameters :
Returns :
number
|
| Public calculateColorGradient | |||||||||||||||||||||||||
calculateColorGradient(rgbaColorA: string, rgbaColorB: string, percentage: number, alpha: number)
|
|||||||||||||||||||||||||
|
Calculates the color gradient between two colors Does not keep alpha to calculate gradient
Parameters :
Returns :
string
|
| Public camelize | ||||||
camelize(stringToCamelize: string)
|
||||||
|
Parameters :
Returns :
string
|
| Public capitalizeFirstLetter | ||||||
capitalizeFirstLetter(string)
|
||||||
|
Capitalize first letter. Note that the search is case insensitive
Parameters :
Returns :
string
string with the first letter capitalized |
| Public changeFontIconSize |
changeFontIconSize(currentFontClass: string, newSize: IconSize)
|
|
Returns :
string
|
| Public changes | ||||||||||||||||||||||||||||||||||||||||
changes(oldArray: T[], newArray: T[], idProperty: string, propertiesToCompare?: string[], compareFunction?: (a?: T,b?: T) => void, considerVoidValues?: boolean, considerEmptyStrings?: boolean)
|
||||||||||||||||||||||||||||||||||||||||
Type parameters :
|
||||||||||||||||||||||||||||||||||||||||
|
Compares two arrays (old and new) to get the changes between them: New items, Updated items, Removed Items and Untouched Items to check if the element changed (default behavior will evaluate a 'deep equal', so try to avoid the default behavior and provide properties to compare)
Parameters :
Returns :
literal type
the changes in format {added: any[], updated: any[], removed: any[], untouched: any[]} |
| Public checkMat | |||||||||||||||||||||||||
checkMat(mat: number[][], start: literal type, range: literal type, valueToCheck: number)
|
|||||||||||||||||||||||||
|
Check if a given value exists in the supplied matrix
Parameters :
Returns :
boolean
True if value found in the range of the supplied matrix |
| Public checkNestedPropertyByArray | ||||||||||||
checkNestedPropertyByArray(sourceObject: Object, propertyArray: string[])
|
||||||||||||
|
This method check if the properties given exist on the object For example, considering the next object literal: sourceObject: { prop1: { prop2 : { prop3: 123 } } } Passing the following path ["prop1", "prop2", "prop3"] will return true if all properties exist
Parameters :
Returns :
boolean
returns true if properties exist and false otherwise |
| Public checkNestedPropertyByPath | ||||||||||||
checkNestedPropertyByPath(sourceObject: T, path: PropertyPath<T>)
|
||||||||||||
Type parameters :
|
||||||||||||
|
This method check if the properties given exist on the object For example, considering the next object literal: sourceObject: { prop1: { prop2 : { prop3: 123 } } } Passing the following path "prop1.prop2.prop3" will return true if all properties exist
Parameters :
Returns :
boolean
returns true if properties exist and false otherwise |
| Public colorHEXtoRGBA | ||||||||||||
colorHEXtoRGBA(hexColor: string, alfa?: number)
|
||||||||||||
|
Converts a color string representation (components) from HEX format to RGB[A] format
Parameters :
Returns :
string
color string representation in the format "#XXXXXX" |
| Public colorHSLtoRGB | ||||||||
colorHSLtoRGB(color: string)
|
||||||||
|
Converts a color string representation (components) from HSL format to RGB[A] format
Parameters :
Returns :
{ r: any; g: any; b: any; }
color values in the format "{r: number, g: number, b: number}" |
| Public colorRGBAtoHEX | ||||||||
colorRGBAtoHEX(rgbaColor: string)
|
||||||||
|
Converts a color string representation (components) from RGB[A] format to HEX format
Parameters :
Returns :
string
color string representation in the format "#XXXXXX" |
| Public colorRGBtoHSL | ||||||||
colorRGBtoHSL(color: string)
|
||||||||
|
Converts a color string representation (components) from RGB[A] format to HSL format
Parameters :
Returns :
literal type
color values in the format "{hue: number, saturation: number, lightness: number}" |
| Public compare | ||||||||||||||||
compare(firstValue: any, secondValue: any, fieldOperator: Cmf.Foundation.Common.FieldOperator)
|
||||||||||||||||
|
Compares two values using a given field operator. This methods assumes that the given values can be properly compared using the given fieldOperator
Parameters :
Returns :
boolean
true if the comparison is true |
| Public compareColors | ||||||||||||||||||||
compareColors(colorA: string, colorB: string, similarityOffset: number)
|
||||||||||||||||||||
|
Checks if two colors are equal 0 means that colors must be completely equal, 1 means that colors are completely different
Parameters :
Returns :
boolean
if the two colors are similar or not |
| Public compareComplexTypes | ||||||||||||
compareComplexTypes(first: ComplexType, second: ComplexType)
|
||||||||||||
|
Compares the two provided complex types
Parameters :
Returns :
boolean
|
| Public convertCssColorToRGB | ||||||||
convertCssColorToRGB(color: string)
|
||||||||
|
Converts css valid color to a RGB string Validated cases:
Parameters :
Returns :
string
color string |
| Public convertCssColorToRGBComponents |
convertCssColorToRGBComponents(color: string, normalize?: boolean)
|
|
Converts css valid color to RGB components separated in numbers Validated cases:
Returns :
literal type
color components |
| Public convertFileSize | ||||||||||||||||
convertFileSize(value: any, from: FileSizeUnit, to: FileSizeUnit)
|
||||||||||||||||
|
Convert from source file size unit to target file size unit
Parameters :
Returns :
number
|
| Public convertObjectToMap | ||||||
convertObjectToMap(object: Record
|
||||||
Type parameters :
|
||||||
|
Convert Object to Map
Parameters :
Returns :
Map<string, T>
Map after conversion |
| Public convertToReadableFileSize | ||||||||||||||||
convertToReadableFileSize(value: any, from: FileSizeUnit, to: FileSizeUnit)
|
||||||||||||||||
|
Convert from value to readable file size unit
Parameters :
Returns :
string
|
| Public createObject | ||||||||||||
createObject(constructor, properties: Partial<>)
|
||||||||||||
Type parameters :
|
||||||||||||
|
Creates an object using the constructor and assigns the provided properties.
Parameters :
Returns :
T
|
| Public createWebWorker | ||||||||||||
createWebWorker(data: string, isCode?: boolean)
|
||||||||||||
|
Create a new web worker
Parameters :
Returns :
any
|
| Public curry | |||||||||
curry(func: Function, ...args: any[])
|
|||||||||
|
Parameters :
Returns :
Function
|
| Public decamelize |
decamelize(camelCase: string, delimiter: string)
|
|
Returns :
string
|
| Public deduceReferenceTypeFromInstance | ||||||||
deduceReferenceTypeFromInstance(instance: Cmf.Foundation.Common.Base.CoreBase)
|
||||||||
|
Deduce reference type from instance
Parameters :
Returns :
ReferenceType
instance's ReferenceType |
| Public deepAssign | |||||||||
deepAssign(target: T, ...sources: T[])
|
|||||||||
Type parameters :
|
|||||||||
|
This methods merges any given sources into the target object
Parameters :
Returns :
T
|
| Public deepClone | ||||||||||||||||
deepClone(value: T, levelsToClone?: number, cloneSameObjectsOnce?: boolean)
|
||||||||||||||||
Type parameters :
|
||||||||||||||||
|
Deep clone an object/array/map. In a Map both keys and values are cloned. Functions are not cloned. and the respective reference is reused (default = true)
Parameters :
Returns :
T
|
| Public deleteAllCookies |
deleteAllCookies()
|
|
Delete all cookies
Returns :
void
|
| Public deleteCookieByName | ||||||||
deleteCookieByName(name: string)
|
||||||||
|
Delete a cookie
Parameters :
Returns :
void
|
| Public deleteNestedPropertyByArray | ||||||||||||
deleteNestedPropertyByArray(sourceObject: Object, propertyArray: string[])
|
||||||||||||
|
This method deletes a property from an object based on the supplied path. For example, considering the next object literal: sourceObject: { prop1: { prop2 : { prop3: 123 prop4: 456 } } } Passing an array literal like ["prop1", "prop2", "prop3"] will delete property "prop3". The resulting source object would be: sourceObject: { prop1: { prop2 : { prop4: 456 } } }
Parameters :
Returns :
boolean
returns false if a given property was not found and true if the field was deleted sucessfully |
| Public deleteNestedPropertyByPath | ||||||||||||
deleteNestedPropertyByPath(sourceObject: T, path: PropertyPath<T>)
|
||||||||||||
Type parameters :
|
||||||||||||
|
This method deletes a property from an object based on the supplied path. For example, considering the next object literal: sourceObject: { prop1: { prop2 : { prop3: 123 prop4: 456 } } } Passing the path "prop1.prop2.prop3" will delete property "prop3". The resulting source object would be: sourceObject: { prop1: { prop2 : { prop4: 456 } } }
Parameters :
Returns :
boolean
returns false if a given property was not found and true if the field was deleted successfully |
| Public durationToString | ||||||||||||
durationToString(duration: moment.Duration, format: string)
|
||||||||||||
|
Transforms a moment duration into a string in the format sent as an input
Parameters :
Returns :
string
|
| Public endsWith |
endsWith(original: string, suffix: string)
|
|
Returns :
boolean
|
| Public escapeHtml | ||||||||
escapeHtml(unsafe: string)
|
||||||||
|
Escapes HTML special characters in a string
Parameters :
Returns :
string
string escaped |
| Public escapeRegExp | ||||||||
escapeRegExp(string: string)
|
||||||||
|
Escapes a string to be used in a RegExp
Parameters :
Returns :
string
|
| Public fade | ||||||||||||
fade(color: string, percentage?: number)
|
||||||||||||
|
Applies a transparency to a color in the formats RGB[A] or HEX
Parameters :
Returns :
string
color string representation in the format 'rgba(r,g,b,a)' |
| Public fillMat | |||||||||||||||||||||||||
fillMat(mat: number[][], start: literal type, range: literal type, valueToAdd: number)
|
|||||||||||||||||||||||||
|
Fills (or creates) a matrix within the supplied range
Parameters :
Returns :
[][]
Created/Update matrix |
| Public generateColorsArray | ||||||||||||
generateColorsArray(numberOfColors: number, useDefault: boolean)
|
||||||||||||
|
Generates an array of colors
Parameters :
Returns :
string[]
|
| Public generateColorsToArrayOfItems | ||||||||||||||||
generateColorsToArrayOfItems(items: any[], colorField: string, useDefault: boolean)
|
||||||||||||||||
|
Generates a different color for each item of an array and puts the value in a "color field"
Parameters :
Returns :
any[]
|
| Public generateHashCode | ||||||||
generateHashCode(text: string)
|
||||||||
|
Generate HashCode from string
Parameters :
Returns :
string
|
| Public getCookieByName | ||||||||
getCookieByName(name: string)
|
||||||||
|
Gets the value of the cookie with the given name.
Parameters :
Returns :
string
The value of the cookie, or null if named cookie doesn't exist. |
| Public getCssVariable | ||||||||
getCssVariable(variable: string)
|
||||||||
|
Retrieves a value from a CSS variable from the DOM
Parameters :
Returns :
string
variable value |
| Public getElementByFieldPath | ||||||||||||||||
getElementByFieldPath(fieldPath: string, fieldValue: any, collection: any[])
|
||||||||||||||||
|
Gets an element with a specific field from the provided collection
Parameters :
Returns :
any
|
| Public getElementById | ||||||||||||
getElementById(id: string, collection: any[])
|
||||||||||||
|
Gets an element with a specific id from the provided collection
Parameters :
Returns :
any
|
| Public getEnumValue | ||||||||||||
getEnumValue(value: string | number, enumObj: object | string)
|
||||||||||||
|
Based on a value (string | number) searches for that value in the supplied enum object (or string with the Enum's FullName), and always returns a number.
Parameters :
Returns :
number
|
| Public getFileMimeType | ||||||||||||
getFileMimeType(fileName: string, contentTypeTableArray: Object[])
|
||||||||||||
|
Given a file name (with extension), and the list of available mime types will return the correct mime type
Parameters :
Returns :
string
|
| Public getHTMLText | ||||||||
getHTMLText(html: string)
|
||||||||
|
Get HTML text from string
Parameters :
Returns :
string
the html text content |
| Public getIndexByFieldPath | ||||||||||||||||
getIndexByFieldPath(fieldPath: string, fieldValue: any, collection: any[])
|
||||||||||||||||
|
Gets an element with a specific field from the provided collection
Parameters :
Returns :
number
|
| Public getIndexById | ||||||||||||
getIndexById(id: string, collection: any[])
|
||||||||||||
|
Gets an element index with a specific id from the provided collection
Parameters :
Returns :
number
|
| Public getInputSelection | ||||||
getInputSelection(input: HTMLInputElement)
|
||||||
|
Gets the current selection range of the provided html input
Parameters :
Returns :
InputSelectionRange
|
| Public getInstancesFromContext | ||||||||
getInstancesFromContext(context: any)
|
||||||||
|
Get the available instances from the context
Parameters :
Returns :
Cmf.Foundation.Common.Base.CoreBase[]
|
| Public getNumericValue | ||||||
getNumericValue(value: any)
|
||||||
|
Gets the numeric value of the passed value (could be string, number or decimal.js object)
Parameters :
Returns :
any
|
| Public getNumericValueStr | ||||||
getNumericValueStr(value: any)
|
||||||
|
Gets the numeric value of the passed value (could be string, number or decimal.js object)
Parameters :
Returns :
string
|
| Public getObjectByNamespace | |||||||||
getObjectByNamespace(startObject: Object, namespaceArray: string[])
|
|||||||||
|
Parameters :
Returns :
any
|
| Public getObjectProperties | ||||||||||||||||||||
getObjectProperties(object: any, levelsToLoad: number, currentLvl: number)
|
||||||||||||||||||||
|
Get Object Properties with levels to load of an object instance. Useful to send in service inputs where only this information is needed, avoiding extra payload on service request.
Parameters :
Returns :
any
|
| Public getObjectThatImplementsFunction |
getObjectThatImplementsFunction(object: any, functionToLook: string)
|
|
Returns :
any
|
| Public getReadableFileSizeUnit | ||||||||
getReadableFileSizeUnit(value: any)
|
||||||||
|
Returns the highest order of magnitude for the size value
Parameters :
Returns :
FileSizeUnit
the highest order of magnitude for the size value |
| Public getScript | ||||||
getScript(script: string)
|
||||||
|
Parameters :
Returns :
Promise<any>
|
| Public getScripts | ||||||
getScripts(...scripts: (string | string[])[])
|
||||||
|
Parameters :
Returns :
Promise<any[]>
|
| Public getThemeColor | ||||||||||||
getThemeColor(colorCSSVariable: string, fade?: number)
|
||||||||||||
|
Retrieves color from the theme
EX:
Parameters :
Returns :
string
variable value in RGBA format (Ex: 'rgba(255,255,255,0.5)') |
| Public getTypeString | ||||||||
getTypeString(type: SimpleType | ComplexType)
|
||||||||
|
Gets a string representation of a SimpleType or a ComplexType
Parameters :
Returns :
string
|
| Public getValidOperatorsForType | ||||||||
getValidOperatorsForType(type: ComplexType)
|
||||||||
|
Get all valid field operators for a given type
Parameters :
Returns :
Cmf.Foundation.Common.FieldOperator[]
collection of field operators |
| Public getWeekDays |
getWeekDays()
|
|
Returns all the week days. The day number is 1-based index, which means that 'Sunday' is day 1 and so on.
Returns :
WeekDay[]
|
| Public hasInvalidEmails | |||||||||||||||
hasInvalidEmails(emails: string[], invalidEmails: string[])
|
|||||||||||||||
|
Checks if a given value is of type valid for email regex pattern
Parameters :
Returns :
boolean
True if there is any invalid email in the list, false otherwise |
| Public humanizeDuration | |||||||||||||||||||||||||
humanizeDuration(duration: moment.Duration, shortFormat?: boolean, precision?: TimeUnit, separator: string)
|
|||||||||||||||||||||||||
|
Humanize a duration printing it to a string in the format: (EX: 2 hours 1 minute)
Parameters :
Returns :
string
|
| Public humanizeDurationInSeconds | ||||||||||||
humanizeDurationInSeconds(durationInSeconds: number, timeunit: TimeUnit)
|
||||||||||||
|
Humanize duration in seconds
Parameters :
Returns :
string
the humanized duration |
| Public includesIgnoreCase |
includesIgnoreCase(a: string, b: string)
|
|
Check if a string is null or does not contain text
Returns :
boolean
|
| Public inferPropertyType | ||||||
inferPropertyType(value: any)
|
||||||
|
Infer Simple Type from value
Parameters :
Returns :
PropertyType
|
| Public inferStringValueAccordingToPropertyType | ||||||
inferStringValueAccordingToPropertyType(value: any)
|
||||||
|
Infer string value according to Property Type
Parameters :
Returns :
string
|
| Public instanceof | ||||||||||||||||||||
instanceof(objectToTest: Object, constructor, objectToTestConstructor?: Function, rootObject?: Object)
|
||||||||||||||||||||
Type parameters :
|
||||||||||||||||||||
|
Checks if a passed object is an instance of the passed constructor function pass in the Material constructor right away to test if a Material object is an EntityInstance. the method will extract a constructor to use. For instance, to test Material against EntityInstance, one can pass in the root "Cmf" object so all properties are navigated until the Material constructor is found. The method will have a commodity of checking the Material constructor name and still be able to use the "Cmf" root object without even passing this parameter.
Parameters :
Returns :
T
True in case the object is really an instance of, false otherwise. |
| Public isDuration | ||||||||
isDuration(value: moment.Duration)
|
||||||||
|
Checks if supplied duration is duration Used in scenarios where the object was cloned and the moment.IsDuration no longer works
Parameters :
Returns :
boolean
True if is duration (has function asMilliseconds, false otherwise) |
| Public isEqual | ||||||||||||||||||||||||
isEqual(object: any, other: any, propertiesToCompare?: string[], considerVoidValues?: boolean, considerEmptyStrings?: boolean)
|
||||||||||||||||||||||||
|
Performs a deep comparison between the two objects, to determine if they should be considered equal. For Maps its compare its keys and values using underscore isEqual For other type of object it compares automatically using underscore isEqual method
Parameters :
Returns :
boolean
True if |
| Public isHexColor | ||||||||
isHexColor(hex: string)
|
||||||||
|
Determines whether is hex color
Parameters :
Returns :
boolean
true if hex color |
| Public isInteger | ||||
isInteger(value)
|
||||
|
Checks if a passed value is integer
Parameters :
Returns :
string | number | Decimal
|
| Public isJsonString | ||||||||
isJsonString(str: string)
|
||||||||
|
Check if the given string contains valid JSON.
Parameters :
Returns :
boolean
|
| Public isNullOrEmpty | ||||||||
isNullOrEmpty(value: string)
|
||||||||
|
Check if a string is null or does not contain text
Parameters :
Returns :
boolean
true, if the provided string is nullish or if it's empty |
| Public isNullOrWhiteSpace | ||||||
isNullOrWhiteSpace(value)
|
||||||
|
Check if a string is null or contains only whitespace
Parameters :
Returns :
boolean
true, if the provided string is nullish or if it's only whitespace |
| Public isNumeric | ||||
isNumeric(value)
|
||||
|
Checks if a passed value is numeric
Parameters :
Returns :
string | number | Decimal
|
| Public isPromise | ||||
isPromise(value)
|
||||
|
Checks if a given value is o type
Parameters :
Returns :
any
|
| Public isValidCssColor | ||||||||
isValidCssColor(color: string)
|
||||||||
|
Determines whether is a valid css color Validated cases:
Parameters :
Returns :
boolean
|
| Public isValidEmail | ||||||||
isValidEmail(email: string)
|
||||||||
|
Checks if a given value is o type valid for email regex pattern
Parameters :
Returns :
boolean
True if email value matches the email pattern |
| Public mapUnique | ||||||||||||
mapUnique(array: any[], iterator: (item: any,index: number) => void)
|
||||||||||||
|
Performs the same as the Array.map function but the result comes without repeated values
Parameters :
Returns :
any[]
mapped array with unique values |
| Public momentToTicks | ||||||||
momentToTicks(momentDate: moment.Moment)
|
||||||||
|
Creates the number of ticks from a moment date object.
Parameters :
Returns :
number
|
| Public nameOf | ||||||||
nameOf(name: Extract
|
||||||||
Type parameters :
|
||||||||
|
Get the property name of T if exists (error otherwise) Note: use this to force strongly-typed checks when using interfaces
Parameters :
Returns :
string
The same property name Note: use this to force strongly-typed checks when using interfaces |
| Public navigateNestedPropertyByArray | ||||||||||||
navigateNestedPropertyByArray(sourceObject: Object, propertyArray: string[])
|
||||||||||||
|
This method navigates an object based on a set of properties. For example, considering the next object literal: sourceObject: { prop1: { prop2 : { prop3: 123 } } } Passing an array literal like ["prop1", "prop2", "prop3"] will return 123. The method navigates all nested objects based on an array of properties
Parameters :
Returns :
any
returns null if a given property was not found or the value of all met properties |
| Public navigateNestedPropertyByPath | ||||||||||||
navigateNestedPropertyByPath(sourceObject: T, path: PropertyPath<T>)
|
||||||||||||
Type parameters :
|
||||||||||||
|
This method navigates an object based on a set of properties. For example, considering the next object literal: sourceObject: { prop1: { prop2 : { prop3: 123 } } } Passing the following path "prop1.prop2.prop3" will return 123. The method navigates all nested objects based on the provided path
Parameters :
Returns :
any
returns null if a given property was not found or the value of all met properties |
| Public navigateNestedPropertyByString | ||||||||||||
navigateNestedPropertyByString(sourceObject: Object, property: string)
|
||||||||||||
|
This method navigates an object based on a single property. For example, considering the next object literal: sourceObject: { prop1: { prop1 : { prop1: 123 } } } Passing the string literal "prop1" will return 123. The method navigates all nested objects for the same property until the last level the property is available.
Parameters :
Returns :
any
returns the last value where the property was found, null, if none was found |
| Public openOrDownloadFile | ||||||||||||||||
openOrDownloadFile(file: Blob | string, fileName: string, isToOpen: boolean)
|
||||||||||||||||
|
Open or download a File
Parameters :
Returns :
void
|
| Public parseType | ||||||||
parseType(type: SimpleType | ComplexType)
|
||||||||
|
Parses a type (simple or complex), the result is always a ComplexType. Used mainly for type comparison
Parameters :
Returns :
ComplexType
Complex type |
| Public partialClone | ||||||||||||
partialClone(obj: T, propertiesToClone: string[])
|
||||||||||||
Type parameters :
|
||||||||||||
|
Return a copy of the object containing only the specified properties
Parameters :
Returns :
T
|
| Public pascalize | ||||||
pascalize(stringToPascalize: string)
|
||||||
|
Parameters :
Returns :
string
|
| Public prettifyVersionedObject | ||||||||||||
prettifyVersionedObject(object: Cmf.Foundation.BusinessObjects.EntityVersion, isToShowVersion: boolean)
|
||||||||||||
|
It prettifies an versioned object with the following format
Parameters :
Returns :
string
|
| Public printDocument | ||||||||
printDocument(documentContent: string)
|
||||||||
|
Prints and html element content using browser printing.
Parameters :
Returns :
void
|
| Public removeFromCollection | ||||||||||||||||||||
removeFromCollection(itemsToRemove: any[], collection: any[], itemsToRemovePath?: string, collectionPath?: string)
|
||||||||||||||||||||
|
Remove supplied items from the supplied collection
Parameters :
Returns :
any[]
The update array |
| Public removeMultipleSpaces | |||||||||||||||
removeMultipleSpaces(text: string, allowDoubleSpacesInNames)
|
|||||||||||||||
|
Removes multiple spaces from a string and trims it
Parameters :
Returns :
string
|
| Public round | ||||||||||||||||||||
round(n: number, roundingError?: number, dp: number)
|
||||||||||||||||||||
|
Round to a maximum amount of decimal places
Parameters :
Returns :
number
|
| Public sanitize | ||||||||
sanitize(source: string)
|
||||||||
|
Sanitize string with DOMPurify
Parameters :
Returns :
string
A string that can be written into a DOM element using innerHTML |
| Public separateNameByUpperCase | ||||||||
separateNameByUpperCase(name: string)
|
||||||||
|
Separates any given name by the upper case characters
Parameters :
Returns :
string
|
| Public setInputCaretPos | |||||||||
setInputCaretPos(input: HTMLInputElement, pos: number)
|
|||||||||
|
Sets the caret position of a html input
Parameters :
Returns :
void
|
| Public setInputSelection | ||||||||||||
setInputSelection(input: HTMLInputElement, selectionStart: number, selectionEnd: number)
|
||||||||||||
|
Sets the selection range of a html input
Parameters :
Returns :
void
|
| Public setNestedPropertyByArray | ||||||||||||||||||||
setNestedPropertyByArray(sourceObject: Object, propertyArray: string[], value: any, createFields: boolean)
|
||||||||||||||||||||
|
This method updates a property of an object, based on the set of properties and a new value. sourceObject: { prop1: { prop2 : { prop3: 123 } } } Passing an array literal like ["prop1", "prop2", "prop3"] and a value like "456", will change prop3 from "123" to "456". It creates nested objects along the way
Parameters :
Returns :
boolean
returns false if a given property was not found and true if the field was updated successfully |
| Public setNestedPropertyByPath | ||||||||||||||||||||
setNestedPropertyByPath(sourceObject: T, path: PropertyPath<T>, value: any, createFields: boolean)
|
||||||||||||||||||||
Type parameters :
|
||||||||||||||||||||
|
This method updates a property of an object, based on the set of properties and a new value. sourceObject: { prop1: { prop2 : { prop3: 123 } } } Passing an array literal like ["prop1", "prop2", "prop3"] and a value like "456", will change prop3 from "123" to "456". The method navigates all nested objects based on an array of properties
Parameters :
Returns :
boolean
returns false if a given property was not found and true if the field was updated successfully |
| Public simulateDragAndDropEvent | |||||||||||||||||||||||||
simulateDragAndDropEvent(sourceSelector: string, targetSelector: string, sourceIndex: number, targetIndex: number)
|
|||||||||||||||||||||||||
|
Simulate drag & drop event
Parameters :
Returns :
void
|
| Public Async sleep | ||||||||
sleep(ms: number)
|
||||||||
|
Custom sleep async method
Parameters :
Returns :
Promise<void>
|
| Public sort | ||||||||||||||||
sort(collection: T[], path?: string, fieldSort?: Cmf.Foundation.Common.FieldSort)
|
||||||||||||||||
Type parameters :
|
||||||||||||||||
|
Sorts an array of objects by a given property path (alphabetically ascending/descending) Example: collection = [{"x":{"y":"d"},"z":"a"},{"x":{"y":"c"},"z":"b"}]; sort(collection, "x.y", Cmf.Foundation.Common.FieldSort.Ascending) = [{"x":{"y":"c"},"z":"b"},{"x":{"y":"d"},"z":"a"}] sort(collection, "z", Cmf.Foundation.Common.FieldSort.Descending) = [{"x":{"y":"c"},"z":"b"},{"x":{"y":"d"},"z":"a"}]
Parameters :
Returns :
T[]
|
| Public strLike |
strLike(source: string, search: string)
|
|
Searches the source string for the given search string, the behavior is similar to the well know SQL like operator. Note that the search is case insensitive
Returns :
boolean
|
| Public supportsMimeType | ||||||||
supportsMimeType(mimeType: string)
|
||||||||
|
Check if browser supports mime type so that we can open file directly on browser
Parameters :
Returns :
boolean
|
| Public ticksToDuration | ||||||||
ticksToDuration(ticks: number)
|
||||||||
|
Create a moment duration from ticks.
Parameters :
Returns :
moment.Duration
|
| Public ticksToMoment | ||||||||
ticksToMoment(ticks: number)
|
||||||||
|
Create a moment date in UTC from ticks.
Parameters :
Returns :
moment.Moment
|
| Public toBoolean | ||||||
toBoolean(value)
|
||||||
|
Converts the provided value to a boolean. If the provided value is a string, the following values are converted to true (case insensitive):
Parameters :
Returns :
boolean
The boolean representation of the value |
| Public toDecimal | ||||||
toDecimal(value: string)
|
||||||
|
Parameters :
Returns :
Decimal
|
| Public toLong | ||||||
toLong(value: string)
|
||||||
|
Parameters :
Returns :
Decimal
|
| Public uniqueId | ||||||
uniqueId(prefix?: string)
|
||||||
|
Get unique id based on the current date
Parameters :
Returns :
string
|
| Public uuidv4 |
uuidv4()
|
|
Generate UUID
Returns :
any
|
| Public waitFor | ||||||||||||
waitFor(stopCondition: () => void, timeout?: number)
|
||||||||||||
|
WaitFor Try to execute an action periodically until the stop condition is met or the number of tries reach 0
Parameters :
Returns :
Promise<boolean>
|
| Public _ |
Type : _.UnderscoreStatic
|
Default value : _
|
| Public distributionListMailValidator | ||||
Type : ValueValidator
|
||||
Default value : ((distributionList: string) => {
return Promise.resolve(this.isValidEmail(distributionList));
})
|
||||
|
Validate that a string representing a distribution list is well formed. |
||||
|
Parameters :
|
| Public each |
Default value : $.each
|
| Public extend |
Default value : $.extend
|
| Public integerValidator | ||||
Type : ValueValidator
|
||||
Default value : ((number: string) => {
return Promise.resolve(this.isInteger(number));
})
|
||||
|
Validate that a string representing a integer is well formed. |
||||
|
Parameters :
|
| Public numericValidator | ||||
Type : ValueValidator
|
||||
Default value : ((number: string) => {
return Promise.resolve(this.isNumeric(number));
})
|
||||
|
Validate that a string representing a number is well formed. |
||||
|
Parameters :
|
| Public uniq |
Default value : _.uniq
|
| iconRegex |
geticonRegex()
|