@serenity-is / Modules / corelib/q

Module: corelib/q

This is the main entry point for @serenity-is/corelib/q module. This module mainly contains helper functions.

The types from this module are available by importing from "@serenity-is/corelib/q":

import { htmlEncode, notifyInfo } from "serenity-is/corelib/q"
notifyInfo(htmlEncode("&'<>"));

When using classic namespaces instead of the ESM modules, the types and functions in this module are directly available from the global Q namespace. e.g. Q.htmlEncode("&'<>")

Table of contents

Namespaces

Enumerations

Classes

Interfaces

Type Aliases

Variables

Functions

Type Aliases

Dictionary

Ƭ Dictionary<TItem>: Object

Type parameters

Name
TItem

Index signature

▪ [key: string]: TItem

Defined in

src/q/system.ts:1


GroupByElement

Ƭ GroupByElement<TItem>: Object

A group item returned by groupBy().

Type parameters

Name
TItem

Type declaration

Name Type Description
items TItem[] the items in the group
key string key of the group
order number index of the item in inOrder array
start number index of the first item of this group in the original array

Defined in

src/q/arrays.ts:43


GroupByResult

Ƭ GroupByResult<TItem>: Object

Return type of the groupBy function.

Type parameters

Name
TItem

Type declaration

Name Type
byKey { [key: string]: GroupByElement<TItem>; }
inOrder GroupByElement<TItem>[]

Defined in

src/q/arrays.ts:57


Grouping

Ƭ Grouping<TItem>: Object

Type parameters

Name
TItem

Index signature

▪ [key: string]: TItem[]

Defined in

src/q/arrays.ts:169


NotifyMap

Ƭ NotifyMap: Object

Type declaration

Name Type
iconClass string
message? string
title? string
type string

Defined in

src/q/toastr2.ts:40


ToastContainerOptions

Ƭ ToastContainerOptions: Object

Type declaration

Name Type
containerId? string
positionClass? string
target? string

Defined in

src/q/toastr2.ts:5


ToastrOptions

Ƭ ToastrOptions: ToastContainerOptions & { closeButton?: boolean ; closeClass?: string ; closeDuration?: number | false ; closeEasing?: boolean ; closeHtml?: string ; closeMethod?: boolean ; closeOnHover?: boolean ; escapeHtml?: boolean ; extendedTimeOut?: number ; hideDuration?: number ; iconClass?: string ; messageClass?: string ; newestOnTop?: boolean ; onCloseClick?: (event: Event) => void ; onHidden?: () => void ; onShown?: () => void ; onclick?: (event: MouseEvent) => void ; positionClass?: string ; preventDuplicates?: boolean ; rtl?: boolean ; showDuration?: number ; tapToDismiss?: boolean ; target?: string ; timeOut?: number ; titleClass?: string ; toastClass?: string }

Defined in

src/q/toastr2.ts:11


Type

Ƭ Type: Function | Object

Defined in

src/q/system.ts:84

Variables

Config

Config: Object

Type declaration

Name Type Description
applicationPath string This is the root path of your application. If your application resides under http://localhost/mysite/, your root path is "mysite/". This variable is automatically initialized by reading from a element with ID "ApplicationPath" from current page, which is usually located in your _LayoutHead.cshtml file
bootstrapMessages boolean Set this to true, to prefer bootstrap dialogs over jQuery UI dialogs by default for message dialogs
emailAllowOnlyAscii boolean Email validation by default only allows ASCII characters. Set this to true if you want to allow unicode.
notLoggedInHandler Function This is an optional method for handling when user is not logged in. If a users session is expired and when a NotAuthorized response is received from a service call, Serenity will call this handler, so you may intercept it and notify user about this situation and ask if she wants to login again...
responsiveDialogs boolean Obsolete defaulted to false before for backward compatibility, now its true by default
rootNamespaces string[] This is the list of root namespaces that may be searched for types. For example, if you specify an editor type of "MyEditor", first a class with name "MyEditor" will be searched, if not found, search will be followed by "Serenity.MyEditor" and "MyApp.MyEditor" if you added "MyApp" to the list of root namespaces. You should usually add your application root namespace to this list in ScriptInitialization.ts file.

Defined in

src/q/config.ts:1


Culture

Culture: Locale

Defined in

src/q/formatting.ts:89


Invariant

Invariant: Locale

Defined in

src/q/formatting.ts:36


defaultNotifyOptions

defaultNotifyOptions: ToastrOptions

Defined in

src/q/notify.ts:10

Functions

Criteria

Criteria(field): CriteriaBuilder

Creates a new criteria builder containg the passed field name.

Parameters

Name Type Description
field string The field name.

Returns

CriteriaBuilder

Defined in

src/q/criteria.ts:747


addAttribute

addAttribute(type, attr): void

Parameters

Name Type
type any
attr any

Returns

void

Defined in

src/q/system.ts:605


addEmptyOption

addEmptyOption(select): void

Adds an empty option to the select.

Parameters

Name Type Description
select JQuery | HTMLSelectElement the select element

Returns

void

Defined in

src/q/html.ts:8


addOption

addOption(select, key, text): void

Adds an option to the select.

Parameters

Name Type
select JQuery | HTMLSelectElement
key string
text string

Returns

void

Defined in

src/q/html.ts:15


addTypeMember

addTypeMember(type, member): TypeMember

Parameters

Name Type
type any
member TypeMember

Returns

TypeMember

Defined in

src/q/system.ts:279


addValidationRule

addValidationRule(element, eventClass, rule): JQuery

Parameters

Name Type
element JQuery
eventClass string
rule (p1: JQuery) => string

Returns

JQuery

Defined in

src/q/validation.ts:231


alert

alert(message, options?): void

Obsolete

use alertDialog

Parameters

Name Type
message string
options? AlertOptions

Returns

void

Defined in

src/q/dialogs.ts:320


alertDialog

alertDialog(message, options?): void

Displays an alert dialog

See

AlertOptions

Example

alertDialog("An error occured!"); }

Parameters

Name Type Description
message string The message to display
options? AlertOptions Additional options.

Returns

void

Defined in

src/q/dialogs.ts:320


any

any<TItem>(array, predicate): boolean

Tests if any of array elements matches given predicate. Prefer Array.some() over this function (e.g. [1, 2, 3].some(predicate)).

Type parameters

Name
TItem

Parameters

Name Type Description
array TItem[] Array to test.
predicate (x: TItem) => boolean Predicate to test elements.

Returns

boolean

True if any element matches.

Defined in

src/q/arrays.ts:7


attrEncode

attrEncode(s): string

Obsolete

use htmlEncode as it also encodes quotes

Parameters

Name Type
s any

Returns

string

Defined in

src/q/html.ts:100


autoFullHeight

autoFullHeight(element): void

Parameters

Name Type
element JQuery

Returns

void

Defined in

src/q/layout.ts:7


baseValidateOptions

baseValidateOptions(): JQueryValidation.ValidationOptions

Returns

JQueryValidation.ValidationOptions

Defined in

src/q/validation.ts:154


blockUI

blockUI(options): void

Uses jQuery BlockUI plugin to block access to whole page (default) or a part of it, by using a transparent overlay covering the whole area.

Remarks

If options are not specified, this function blocks whole page with a transparent overlay. Default z-order of the overlay div is 2000, so a higher z-order shouldn't be used in page.

Parameters

Name Type Description
options JQBlockUIOptions Parameters for the BlockUI plugin

Returns

void

Defined in

src/q/blockui.ts:36


blockUndo

blockUndo(): void

Unblocks the page.

Returns

void

Defined in

src/q/blockui.ts:60


bsModalMarkup

bsModalMarkup(title, body, modalClass?, escapeHtml?): HTMLDivElement

Builds HTML DIV element for a Bootstrap modal dialog

Parameters

Name Type Default value Description
title string undefined Modal title
body string undefined Modal body, it will not be HTML encoded, so make sure it is encoded
modalClass? string undefined Optional class to add to the modal element
escapeHtml boolean true True to html encode body, default is true

Returns

HTMLDivElement

Defined in

src/q/dialogs.ts:147


canLoadScriptData

canLoadScriptData(name): boolean

Parameters

Name Type
name string

Returns

boolean

Defined in

src/q/scriptdata.ts:270


cast

cast(instance, type): any

Parameters

Name Type
instance any
type Type

Returns

any

Defined in

src/q/system.ts:195


centerDialog

centerDialog(el): void

Parameters

Name Type
el JQuery

Returns

void

Defined in

src/q/layout.ts:133


clearKeys

clearKeys(d): void

Parameters

Name Type
d any

Returns

void

Defined in

src/q/system.ts:335


clearOptions

clearOptions(select): void

Clears the options in the select element

Parameters

Name Type
select JQuery

Returns

void

Defined in

src/q/html.ts:23


closePanel

closePanel(element, e?): void

Closes a panel, triggering panelbeforeclose and panelclose events. If the panelbeforeclose prevents the default, the operation is cancelled.

Parameters

Name Type Description
element HTMLElement | JQuery The panel element
e? Event The event triggering the close

Returns

void

Defined in

src/q/dialogs.ts:594


coalesce

coalesce(a, b): any

Parameters

Name Type
a any
b any

Returns

any

Defined in

src/q/system.ts:3


compareStringFactory

compareStringFactory(order): (a: string, b: string) => number

Parameters

Name Type
order string

Returns

fn

▸ (a, b): number

Parameters
Name Type
a string
b string
Returns

number

Defined in

src/q/formatting.ts:60


confirm

confirm(message, onYes, options?): void

Obsolete

use confirmDialog

Parameters

Name Type
message string
onYes () => void
options? ConfirmOptions

Returns

void

Defined in

src/q/dialogs.ts:388


confirmDialog

confirmDialog(message, onYes, options?): void

Display a confirmation dialog

See

ConfirmOptions

Example

confirmDialog("Are you sure you want to delete?", () => { 
    // do something when yes is clicked
}

Parameters

Name Type Description
message string The message to display
onYes () => void Callback for Yes button click
options? ConfirmOptions Additional options.

Returns

void

Defined in

src/q/dialogs.ts:388


count

count<TItem>(array, predicate): number

Counts number of array elements that matches a given predicate.

Type parameters

Name
TItem

Parameters

Name Type Description
array TItem[] Array to test.
predicate (x: TItem) => boolean Predicate to test elements.

Returns

number

Defined in

src/q/arrays.ts:16


dbText

dbText(prefix): (key: string) => string

Parameters

Name Type
prefix string

Returns

fn

▸ (key): string

Parameters
Name Type
key string
Returns

string

Defined in

src/q/localtext.ts:15


dbTryText

dbTryText(prefix): (key: string) => string

Parameters

Name Type
prefix string

Returns

fn

▸ (key): string

Parameters
Name Type
key string
Returns

string

Defined in

src/q/localtext.ts:57


debounce

debounce<T>(func, wait?, immediate?): DebouncedFunction<T>

Returns a function, that, as long as it continues to be invoked, will not be triggered. The function also has a property 'clear' that can be used to clear the timer to prevent previously scheduled executions, and flush method to invoke scheduled executions now if any.

Source

underscore.js

Type parameters

Name Type
T extends (...args: any) => any

Parameters

Name Type Description
func T -
wait? number The function will be called after it stops being called for N milliseconds.
immediate? boolean If passed, trigger the function on the leading edge, instead of the trailing.

Returns

DebouncedFunction<T>

Defined in

src/q/debounce.ts:39


deepClone

deepClone<T>(a, a2?, a3?): T

Type parameters

Name Type
T any

Parameters

Name Type
a T
a2? any
a3? any

Returns

T

Defined in

src/q/system.ts:23


delegateCombine

delegateCombine(delegate1, delegate2): any

Parameters

Name Type
delegate1 any
delegate2 any

Returns

any

Defined in

src/q/system.ts:342


delegateRemove

delegateRemove(delegate1, delegate2): any

Parameters

Name Type
delegate1 any
delegate2 any

Returns

any

Defined in

src/q/system.ts:454


dialogButtonToBS

dialogButtonToBS(x): HTMLButtonElement

Parameters

Name Type
x DialogButton

Returns

HTMLButtonElement

Defined in

src/q/dialogs.ts:168


dialogButtonToUI

dialogButtonToUI(x): any

Parameters

Name Type
x DialogButton

Returns

any

Defined in

src/q/dialogs.ts:183


endsWith

endsWith(s, suffix): boolean

Checks if the string ends with the specified substring.

Parameters

Name Type Description
s string String to check.
suffix string Suffix to check.

Returns

boolean

True if the string ends with the specified substring.

Defined in

src/q/strings.ts:7


executeEverytimeWhenVisible

executeEverytimeWhenVisible(element, callback, callNowIfVisible): void

Parameters

Name Type
element JQuery
callback Function
callNowIfVisible boolean

Returns

void

Defined in

src/q/layouttimer.ts:154


executeOnceWhenVisible

executeOnceWhenVisible(element, callback): void

Parameters

Name Type
element JQuery
callback Function

Returns

void

Defined in

src/q/layouttimer.ts:138


extend

extend<T>(a, b): T

Type parameters

Name Type
T any

Parameters

Name Type
a T
b T

Returns

T

Defined in

src/q/system.ts:16


fieldsProxy

fieldsProxy<TRow>(): Readonly<Record<keyof TRow, string>>

Type parameters

Name
TRow

Returns

Readonly<Record<keyof TRow, string>>

Defined in

src/q/system.ts:538


findElementWithRelativeId

findElementWithRelativeId(element, relativeId, context?): JQuery

Finds the first element with the given relative id to the source element. It can handle underscores in the source element id.

Parameters

Name Type Description
element JQuery the source element
relativeId string the relative id to the source element
context? HTMLElement the context element (optional)

Returns

JQuery

the element with the given relative id to the source element.

Defined in

src/q/html.ts:35

findElementWithRelativeId(element, relativeId, context?): HTMLElement

Finds the first element with the given relative id to the source element. It can handle underscores in the source element id.

Parameters

Name Type Description
element HTMLElement the source element
relativeId string the relative id to the source element
context? HTMLElement the context element (optional)

Returns

HTMLElement

the element with the given relative id to the source element.

Defined in

src/q/html.ts:44


first

first<TItem>(array, predicate): TItem

Gets first element in an array that matches given predicate similar to LINQ's First. Throws an error if no match is found.

Type parameters

Name
TItem

Parameters

Name Type Description
array TItem[] Array to test.
predicate (x: TItem) => boolean Predicate to test elements.

Returns

TItem

First element that matches.

Defined in

src/q/arrays.ts:32


format

format(format, ...prm): string

Parameters

Name Type
format string
...prm any[]

Returns

string

Defined in

src/q/formatting.ts:209


formatDate

formatDate(d, format?, locale?): string

Parameters

Name Type
d string | Date
format? string
locale? Locale

Returns

string

Defined in

src/q/formatting.ts:519


formatDayHourAndMin

formatDayHourAndMin(n): string

Parameters

Name Type
n number

Returns

string

Defined in

src/q/formatting.ts:687


formatISODateTimeUTC

formatISODateTimeUTC(d): string

Parameters

Name Type
d Date

Returns

string

Defined in

src/q/formatting.ts:706


formatNumber

formatNumber(num, format?, decOrLoc?, grp?): string

Parameters

Name Type
num number
format? string
decOrLoc? string | NumberFormat
grp? string

Returns

string

Defined in

src/q/formatting.ts:240


getAttributes

getAttributes(type, attrType, inherit?): any[]

Parameters

Name Type
type any
attrType any
inherit? boolean

Returns

any[]

Defined in

src/q/system.ts:228


getBaseType

getBaseType(type): any

Parameters

Name Type
type any

Returns

any

Defined in

src/q/system.ts:203


getColumns

getColumns(key): PropertyItem[]

Parameters

Name Type
key string

Returns

PropertyItem[]

Defined in

src/q/scriptdata.ts:230


getColumnsAsync

getColumnsAsync(key): Promise<PropertyItem[]>

Parameters

Name Type
key string

Returns

Promise<PropertyItem[]>

Defined in

src/q/scriptdata.ts:238


getColumnsData

getColumnsData(key): PropertyItemsData

Parameters

Name Type
key string

Returns

PropertyItemsData

Defined in

src/q/scriptdata.ts:234


getColumnsDataAsync

getColumnsDataAsync(key): Promise<PropertyItemsData>

Parameters

Name Type
key string

Returns

Promise<PropertyItemsData>

Defined in

src/q/scriptdata.ts:242


getCookie

getCookie(name): any

Parameters

Name Type
name string

Returns

any

Defined in

src/q/services.ts:8


getForm

getForm(key): PropertyItem[]

Parameters

Name Type
key string

Returns

PropertyItem[]

Defined in

src/q/scriptdata.ts:246


getFormAsync

getFormAsync(key): Promise<PropertyItem[]>

Parameters

Name Type
key string

Returns

Promise<PropertyItem[]>

Defined in

src/q/scriptdata.ts:254


getFormData

getFormData(key): PropertyItemsData

Parameters

Name Type
key string

Returns

PropertyItemsData

Defined in

src/q/scriptdata.ts:250


getFormDataAsync

getFormDataAsync(key): Promise<PropertyItemsData>

Parameters

Name Type
key string

Returns

Promise<PropertyItemsData>

Defined in

src/q/scriptdata.ts:258


getGlobalThis

getGlobalThis(): any

Returns

any

Defined in

src/q/system.ts:116


getHighlightTarget

getHighlightTarget(el): HTMLElement

Parameters

Name Type
el HTMLElement

Returns

HTMLElement

Defined in

src/q/validation.ts:146


getInstanceType

getInstanceType(instance): any

Parameters

Name Type
instance any

Returns

any

Defined in

src/q/system.ts:158


getLookup

getLookup<TItem>(key): Lookup<TItem>

Type parameters

Name
TItem

Parameters

Name Type
key string

Returns

Lookup<TItem>

Defined in

src/q/scriptdata.ts:214


getLookupAsync

getLookupAsync<TItem>(key): Promise<Lookup<TItem>>

Type parameters

Name
TItem

Parameters

Name Type
key string

Returns

Promise<Lookup<TItem>>

Defined in

src/q/scriptdata.ts:218


getMembers

getMembers(type, memberTypes): TypeMember[]

Parameters

Name Type
type any
memberTypes MemberType

Returns

TypeMember[]

Defined in

src/q/system.ts:262


getNested

getNested(from, name): any

Parameters

Name Type
from any
name string

Returns

any

Defined in

src/q/system.ts:98


getRemoteData

getRemoteData<TData>(key): TData

Type parameters

Name Type
TData any

Parameters

Name Type
key string

Returns

TData

Defined in

src/q/scriptdata.ts:206


getRemoteDataAsync

getRemoteDataAsync<TData>(key): Promise<TData>

Type parameters

Name Type
TData any

Parameters

Name Type
key string

Returns

Promise<TData>

Defined in

src/q/scriptdata.ts:210


getStateStore

getStateStore(key?): any

Parameters

Name Type
key? string

Returns

any

Defined in

src/q/system.ts:365


getTemplate

getTemplate(key): string

Parameters

Name Type
key string

Returns

string

Defined in

src/q/scriptdata.ts:262


getTemplateAsync

getTemplateAsync(key): Promise<string>

Parameters

Name Type
key string

Returns

Promise<string>

Defined in

src/q/scriptdata.ts:266


getType

getType(name, target?): Type

Parameters

Name Type
name string
target? any

Returns

Type

Defined in

src/q/system.ts:120


getTypeFullName

getTypeFullName(type): string

Parameters

Name Type
type Type

Returns

string

Defined in

src/q/system.ts:146


getTypeNameProp

getTypeNameProp(type): string

Parameters

Name Type
type Type

Returns

string

Defined in

src/q/system.ts:138


getTypeShortName

getTypeShortName(type): string

Parameters

Name Type
type Type

Returns

string

Defined in

src/q/system.ts:151


getTypes

getTypes(from?): any[]

Parameters

Name Type
from? any

Returns

any[]

Defined in

src/q/system.ts:310


groupBy

groupBy<TItem>(items, getKey): GroupByResult<TItem>

Groups an array with keys determined by specified getKey() callback. Resulting object contains group objects in order and a dictionary to access by key. This is similar to LINQ's ToLookup function with some additional details like start index.

Type parameters

Name
TItem

Parameters

Name Type Description
items TItem[] Array to group.
getKey (x: TItem) => any Function that returns key for each item.

Returns

GroupByResult<TItem>

GroupByResult object.

Defined in

src/q/arrays.ts:70


htmlEncode

htmlEncode(s): string

Html encodes a string (encodes single and double quotes, & (ampersand), > and < characters)

Parameters

Name Type Description
s any String (or number etc.) to be HTML encoded

Returns

string

Defined in

src/q/html.ts:100


iframeDialog

iframeDialog(options): void

Display a dialog that shows an HTML block in an IFRAME, which is usually returned from server callbacks

Parameters

Name Type Description
options IFrameDialogOptions The options

Returns

void

Defined in

src/q/dialogs.ts:457


indexOf

indexOf<TItem>(array, predicate): number

Gets index of first element in an array that matches given predicate.

Type parameters

Name
TItem

Parameters

Name Type Description
array TItem[] Array to test.
predicate (x: TItem) => boolean Predicate to test elements.

Returns

number

Defined in

src/q/arrays.ts:103


information

information(message, onOk?, options?): void

Obsolete

use informationDialog

Parameters

Name Type
message string
onOk? () => void
options? ConfirmOptions

Returns

void

Defined in

src/q/dialogs.ts:517


informationDialog

informationDialog(message, onOk?, options?): void

Display an information dialog

See

ConfirmOptions

Example

informationDialog("Operation complete", () => { 
    // do something when OK is clicked
}

Parameters

Name Type Description
message string The message to display
onOk? () => void Callback for OK button click
options? ConfirmOptions Additional options.

Returns

void

Defined in

src/q/dialogs.ts:517


initFormType

initFormType(typ, nameWidgetPairs): void

Parameters

Name Type
typ Function
nameWidgetPairs any[]

Returns

void

Defined in

src/q/system.ts:492


initFullHeightGridPage

initFullHeightGridPage(gridDiv, opt?): void

Parameters

Name Type
gridDiv JQuery
opt? Object
opt.noRoute? boolean

Returns

void

Defined in

src/q/layout.ts:12


initializeTypes

initializeTypes(root, pre, limit): void

Parameters

Name Type
root any
pre string
limit number

Returns

void

Defined in

src/q/system.ts:621


insert

insert(obj, index, item): void

Inserts an item to the array at specified index. Prefer Array.splice unless you need to support IE.

Throws

Error if object does not support insert.

Example

insert([1, 2, 3], 1, 4); // [1, 4, 2, 3]
insert({ insert: (index, item) => { this.splice(index, 0, item); } }

Parameters

Name Type Description
obj any Array or array like object to insert to.
index number Index to insert at.
item any Item to insert.

Returns

void

Defined in

src/q/arrays.ts:122


isArray

isArray(arg): arg is any[]

Determines if the object is an array. Prefer Array.isArray over this function (e.g. Array.isArray(obj)).

Example

isArray([1, 2, 3]); // true
isArray({}); // false

Parameters

Name Type
arg any

Returns

arg is any[]

True if the object is an array.

Defined in

../../../../../Users/volka/AppData/Local/pnpm/global/5/.pnpm/typescript@4.9.3/node_modules/typescript/lib/lib.es5.d.ts:1491


isAssignableFrom

isAssignableFrom(target, type): boolean

Parameters

Name Type
target any
type Type

Returns

boolean

Defined in

src/q/system.ts:171


isBS3

isBS3(): boolean

Returns true if Bootstrap 3 is loaded

Returns

boolean

Defined in

src/q/dialogs.ts:109


isBS5Plus

isBS5Plus(): boolean

Returns true if Bootstrap 5+ is loaded

Returns

boolean

Defined in

src/q/dialogs.ts:117


isEmptyOrNull

isEmptyOrNull(s): boolean

Checks if the string is empty or null.

Parameters

Name Type Description
s string String to check.

Returns

boolean

True if the string is empty or null.

Defined in

src/q/strings.ts:16


isEnum

isEnum(type): boolean

Parameters

Name Type
type any

Returns

boolean

Defined in

src/q/system.ts:487


isInstanceOfType

isInstanceOfType(instance, type): boolean

Parameters

Name Type
instance any
type Type

Returns

boolean

Defined in

src/q/system.ts:181


isTrimmedEmpty

isTrimmedEmpty(s): boolean

Checks if the string is empty or null or whitespace.

Parameters

Name Type Description
s string String to check.

Returns

boolean

True if the string is empty or null or whitespace.

Defined in

src/q/strings.ts:25


isValue

isValue(a): boolean

Parameters

Name Type
a any

Returns

boolean

Defined in

src/q/system.ts:7


keyOf

keyOf<T>(prop): keyof T

Type parameters

Name
T

Parameters

Name Type
prop keyof T

Returns

keyof T

Defined in

src/q/system.ts:542


layoutFillHeight

layoutFillHeight(element): void

Parameters

Name Type
element JQuery

Returns

void

Defined in

src/q/layout.ts:74


layoutFillHeightValue

layoutFillHeightValue(element): number

Parameters

Name Type
element JQuery

Returns

number

Defined in

src/q/layout.ts:59


loadValidationErrorMessages

loadValidationErrorMessages(): void

Returns

void

Defined in

src/q/validation.ts:113


localText

localText(key): string

Parameters

Name Type
key string

Returns

string

Defined in

src/q/localtext.ts:4


localeFormat

localeFormat(format, l, ...prm): string

Parameters

Name Type
format string
l Locale
...prm any[]

Returns

string

Defined in

src/q/formatting.ts:213


newBodyDiv

newBodyDiv(): JQuery

Creates a new DIV and appends it to the body.

Returns

JQuery

the new DIV element.

Defined in

src/q/html.ts:114


notifyError

notifyError(message, title?, options?): void

Parameters

Name Type
message string
title? string
options? ToastrOptions

Returns

void

Defined in

src/q/notify.ts:78


notifyInfo

notifyInfo(message, title?, options?): void

Parameters

Name Type
message string
title? string
options? ToastrOptions

Returns

void

Defined in

src/q/notify.ts:74


notifySuccess

notifySuccess(message, title?, options?): void

Parameters

Name Type
message string
title? string
options? ToastrOptions

Returns

void

Defined in

src/q/notify.ts:70


notifyWarning

notifyWarning(message, title?, options?): void

Parameters

Name Type
message string
title? string
options? ToastrOptions

Returns

void

Defined in

src/q/notify.ts:66


outerHtml

outerHtml(element): string

Returns the outer HTML of the element.

Parameters

Name Type
element JQuery

Returns

string

Defined in

src/q/html.ts:121


padLeft

padLeft(s, len, ch?): any

Pads the string to the left with the specified character.

Parameters

Name Type Default value Description
s string | number undefined String to pad.
len number undefined Target length of the string.
ch string ' ' Character to pad with.

Returns

any

Padded string.

Defined in

src/q/strings.ts:36


parseCriteria

parseCriteria(expression, params?): any[]

Parses a criteria expression to Serenity Criteria array format. The string may optionally contain parameters like A >= @p1 and B < @p2.

Example

parseCriteria('A >=

P1

and B < @p2', { p1: 5, p2: 4 }) // [[[a], '>=' 5], 'and', [[b], '<', 4]]

Parameters

Name Type Description
expression string The criteria expression.
params? any The dictionary containing parameter values like { p1: 10, p2: 20 }.

Returns

any[]

Defined in

src/q/criteria.ts:694

parseCriteria(strings, ...values): any[]

Parses a criteria expression to Serenity Criteria array format. The expression may contain parameter placeholders like A >= ${p1} where p1 is a variable in the scope.

Example

var a = 5, b = 4;
parseCriteria`A >= ${a} and B < ${b}` // [[[a], '>=' 5], 'and', [[b], '<', 4]]

Parameters

Name Type Description
strings TemplateStringsArray The string fragments.
...values any[] The tagged template arguments.

Returns

any[]

Defined in

src/q/criteria.ts:705


parseDate

parseDate(s, dateOrder?): any

Parameters

Name Type
s string
dateOrder? string

Returns

any

Defined in

src/q/formatting.ts:782


parseDayHourAndMin

parseDayHourAndMin(s): number

Parameters

Name Type
s string

Returns

number

Defined in

src/q/formatting.ts:759


parseDecimal

parseDecimal(s): number

Parameters

Name Type
s string

Returns

number

Defined in

src/q/formatting.ts:460


parseHourAndMin

parseHourAndMin(value): number

Parameters

Name Type
value string

Returns

number

Defined in

src/q/formatting.ts:739


parseISODateTime

parseISODateTime(s): Date

Parameters

Name Type
s string

Returns

Date

Defined in

src/q/formatting.ts:724


parseInteger

parseInteger(s): number

Parameters

Name Type
s string

Returns

number

Defined in

src/q/formatting.ts:449


parseQueryString

parseQueryString(s?): Object

Parameters

Name Type
s? string

Returns

Object

Defined in

src/q/services.ts:153


positionToastContainer

positionToastContainer(create, options?): void

Parameters

Name Type
create boolean
options? ToastrOptions

Returns

void

Defined in

src/q/notify.ts:82


postToService

postToService(options): void

Parameters

Name Type
options PostToServiceOptions

Returns

void

Defined in

src/q/services.ts:169


postToUrl

postToUrl(options): void

Parameters

Name Type
options PostToUrlOptions

Returns

void

Defined in

src/q/services.ts:191


prefixedText

prefixedText(prefix): (text: string, key: string | (p?: string) => string) => string

Parameters

Name Type
prefix string

Returns

fn

▸ (text, key): string

Parameters
Name Type
text string
key string | (p?: string) => string
Returns

string

Defined in

src/q/localtext.ts:25


prop

prop(type, name, getter?, setter?): void

Parameters

Name Type
type any
name string
getter? string
setter? string

Returns

void

Defined in

src/q/system.ts:506


proxyTexts

proxyTexts(o, p, t): Object

Parameters

Name Type
o Record<string, any>
p string
t Record<string, any>

Returns

Object

Defined in

src/q/localtext.ts:63


registerClass

registerClass(type, name, intf?): void

Parameters

Name Type
type any
name string
intf? any[]

Returns

void

Defined in

src/q/system.ts:579


registerEditor

registerEditor(type, name, intf?): void

Parameters

Name Type
type any
name string
intf? any[]

Returns

void

Defined in

src/q/system.ts:584


registerEnum

registerEnum(type, name, enumKey?): void

Parameters

Name Type
type any
name string
enumKey? string

Returns

void

Defined in

src/q/system.ts:589


registerInterface

registerInterface(type, name, intf?): void

Parameters

Name Type
type any
name string
intf? any[]

Returns

void

Defined in

src/q/system.ts:599


reloadLookup

reloadLookup<TItem>(key): Lookup<TItem>

Type parameters

Name Type
TItem any

Parameters

Name Type
key string

Returns

Lookup<TItem>

Defined in

src/q/scriptdata.ts:222


reloadLookupAsync

reloadLookupAsync<TItem>(key): Promise<Lookup<TItem>>

Type parameters

Name Type
TItem any

Parameters

Name Type
key string

Returns

Promise<Lookup<TItem>>

Defined in

src/q/scriptdata.ts:226


removeValidationRule

removeValidationRule(element, eventClass): JQuery

Parameters

Name Type
element JQuery
eventClass string

Returns

JQuery

Defined in

src/q/validation.ts:240


replaceAll

replaceAll(str, find, replace): string

Replaces all occurrences of the search string with the replacement string.

Parameters

Name Type Description
str string String to replace.
find string String to find.
replace string String to replace with.

Returns

string

Replaced string.

Defined in

src/q/strings.ts:111


resolveUrl

resolveUrl(url): string

Parameters

Name Type
url string

Returns

string

Defined in

src/q/services.ts:217


round

round(n, d?, rounding?): number

Parameters

Name Type
n number
d? number
rounding? boolean

Returns

number

Defined in

src/q/formatting.ts:226


safeCast

safeCast(instance, type): any

Parameters

Name Type
instance any
type Type

Returns

any

Defined in

src/q/system.ts:191


serviceCall

serviceCall<TResponse>(options): JQueryXHR

Type parameters

Name Type
TResponse extends ServiceResponse

Parameters

Name Type
options ServiceOptions<TResponse>

Returns

JQueryXHR

Defined in

src/q/services.ts:28


serviceRequest

serviceRequest<TResponse>(service, request?, onSuccess?, options?): JQueryXHR

Type parameters

Name Type
TResponse extends ServiceResponse

Parameters

Name Type
service string
request? any
onSuccess? (response: TResponse) => void
options? ServiceOptions<TResponse>

Returns

JQueryXHR

Defined in

src/q/services.ts:124


setEquality

setEquality(request, field, value): void

Parameters

Name Type
request ListRequest
field string
value any

Returns

void

Defined in

src/q/services.ts:133


setMobileDeviceMode

setMobileDeviceMode(): void

Returns

void

Defined in

src/q/layout.ts:82


setTypeNameProp

setTypeNameProp(type, value): void

Parameters

Name Type
type Type
value string

Returns

void

Defined in

src/q/system.ts:142


single

single<TItem>(array, predicate): TItem

Gets first element in an array that matches given predicate. Throws an error if no matches is found, or there are multiple matches.

Example

first([1, 2, 3], x => x == 2); // 2
first([1, 2, 3], x => x == 4); // throws error.

Type parameters

Name
TItem

Parameters

Name Type Description
array TItem[] Array to test.
predicate (x: TItem) => boolean Predicate to test elements.

Returns

TItem

First element that matches.

Defined in

src/q/arrays.ts:151


splitDateString

splitDateString(s): string[]

Parameters

Name Type
s string

Returns

string[]

Defined in

src/q/formatting.ts:860


startsWith

startsWith(s, prefix): boolean

Checks if the string starts with the prefix

Parameters

Name Type Description
s string String to check.
prefix string Prefix to check.

Returns

boolean

True if the string starts with the prefix.

Defined in

src/q/strings.ts:51


success

success(message, onOk?, options?): void

Obsolete

use successDialog

Parameters

Name Type
message string
onOk? () => void
options? ConfirmOptions

Returns

void

Defined in

src/q/dialogs.ts:548


successDialog

successDialog(message, onOk?, options?): void

Display a success dialog

See

ConfirmOptions

Example

successDialog("Operation complete", () => { 
    // do something when OK is clicked
}

Parameters

Name Type Description
message string The message to display
onOk? () => void Callback for OK button click
options? ConfirmOptions Additional options.

Returns

void

Defined in

src/q/dialogs.ts:548


text

text(key): string

Obsolete

prefer localText for better discoverability

Parameters

Name Type
key string

Returns

string

Defined in

src/q/localtext.ts:4


toGrouping

toGrouping<TItem>(items, getKey): Grouping<TItem>

Maps an array into a dictionary with keys determined by specified getKey() callback, and values that are arrays containing elements for a particular key.

Example

toGrouping([1, 2, 3], x => x % 2 == 0 ? "even" : "odd"); // { odd: [1, 3], even: [2] }

Type parameters

Name
TItem

Parameters

Name Type Description
items TItem[] Array to map.
getKey (x: TItem) => any Function that returns key for each item.

Returns

Grouping<TItem>

Grouping object.

Defined in

src/q/arrays.ts:180


toId

toId(id): any

Parameters

Name Type
id any

Returns

any

Defined in

src/q/formatting.ts:501


toSingleLine

toSingleLine(str): string

Converts the string to single line by removing line end characters

Parameters

Name Type Description
str string String to convert.

Returns

string

Defined in

src/q/strings.ts:59


today

today(): Date

Returns

Date

Defined in

src/q/system.ts:11


toggleClass

toggleClass(el, cls, remove?): void

Toggles the class on the element handling spaces like jQuery addClass does.

Parameters

Name Type Description
el Element the element
cls string the class to toggle
remove? boolean if true, the class will be added, if false the class will be removed, otherwise it will be toggled.

Returns

void

Defined in

src/q/html.ts:132


triggerLayoutOnShow

triggerLayoutOnShow(element): void

Parameters

Name Type
element JQuery

Returns

void

Defined in

src/q/layout.ts:127


trim

trim(s): string

Trims the whitespace characters from the start and end of the string This returns empty string even when the string is null or undefined.

Parameters

Name Type
s string

Returns

string

Defined in

src/q/strings.ts:81


trimEnd

trimEnd(s): any

Trims the whitespace characters from the end of the string

Parameters

Name Type
s string

Returns

any

Defined in

src/q/strings.ts:66


trimStart

trimStart(s): any

Trims the whitespace characters from the start of the string

Parameters

Name Type
s string

Returns

any

Defined in

src/q/strings.ts:73


trimToEmpty

trimToEmpty(s): string

Trims the whitespace characters from the start and end of the string Returns empty string if the string is null or undefined.

Parameters

Name Type
s string

Returns

string

Defined in

src/q/strings.ts:89


trimToNull

trimToNull(s): string

Trims the whitespace characters from the start and end of the string Returns null if the string is null, undefined or whitespace.

Parameters

Name Type
s string

Returns

string

Defined in

src/q/strings.ts:97


trunc

trunc(n): number

Parameters

Name Type
n number

Returns

number

Defined in

src/q/formatting.ts:238


tryFirst

tryFirst<TItem>(array, predicate): TItem

Gets first element in an array that matches given predicate (similar to LINQ's FirstOrDefault). Returns null if no match is found.

Example

tryFirst([1, 2, 3], x => x == 2); // 2
tryFirst([1, 2, 3], x => x == 4); // null

Type parameters

Name
TItem

Parameters

Name Type Description
array TItem[] Array to test.
predicate (x: TItem) => boolean Predicate to test elements.

Returns

TItem

First element that matches.

Defined in

src/q/arrays.ts:204


tryGetText

tryGetText(key): string

Parameters

Name Type
key string

Returns

string

Defined in

src/q/localtext.ts:52


turkishLocaleCompare

turkishLocaleCompare(a, b): number

Parameters

Name Type
a string
b string

Returns

number

Defined in

src/q/formatting.ts:32


turkishLocaleToUpper

turkishLocaleToUpper(a): string

Parameters

Name Type
a string

Returns

string

Defined in

src/q/formatting.ts:124


validateForm

validateForm(form, opt): JQueryValidation.Validator

Parameters

Name Type
form JQuery
opt ValidationOptions

Returns

JQueryValidation.Validator

Defined in

src/q/validation.ts:227


validateOptions

validateOptions(options?): ValidationOptions

Parameters

Name Type
options? ValidationOptions

Returns

ValidationOptions

Defined in

src/q/validateoptions.ts:61


validatorAbortHandler

validatorAbortHandler(validator): void

Parameters

Name Type
validator any

Returns

void

Defined in

src/q/validateoptions.ts:54


warning

warning(message, options?): void

Obsolete

use warningDialog

Parameters

Name Type
message string
options? AlertOptions

Returns

void

Defined in

src/q/dialogs.ts:576


warningDialog

warningDialog(message, options?): void

Display a warning dialog

See

AlertOptions

Example

warningDialog("Something is odd!");

Parameters

Name Type Description
message string The message to display
options? AlertOptions Additional options.

Returns

void

Defined in

src/q/dialogs.ts:576


zeroPad

zeroPad(n, len): string

Pads the start of string to make it the specified length.

Parameters

Name Type Description
n number -
len number Target length of the string.

Returns

string

Defined in

src/q/strings.ts:121